SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 28/07/2012, 06:23 AM   #1
Hervest1998
Little Clucker
 
Join Date: Jul 2012
Posts: 18
Reputation: 4
Default SQLite Ban System

Code:
stock BanPlayer(playerid,AdministratorID,Reason[],Time)
{
	new String[150];
	format(String,150,"INSERT INTO `Bans` SET `BanUserName` = '%s',`BanUserIp` = '%s',`BanAdministratorName` = '%s',`BanReason` = '%s',`BanTime` = '%i'",UserName[playerid],UserIp[playerid],UserName[AdministratorID],Reason,Time);
	new DBResult:DatabaseResult = db_query(Database,String);
	db_free_result(DatabaseResult);
	Kick(playerid);
	return 1;
}
Code:
public OnPlayerConnect(playerid)
{
	GetPlayerName(playerid,UserName[playerid],30);
	GetPlayerIp(playerid,UserIp[playerid],30);
	BanPlayer(playerid,playerid,"Nothing",30324);
	new DBResult:DatabaseResult = db_query(Database,"SELECT * FROM `Bans` WHERE `BanUserReason` = 'Nothing`");
	if(db_num_rows(DatabaseResult))
	{
		new String[150];
		db_get_field_assoc(DatabaseResult,"BanUserName",String,30);
		printf(String);
		db_get_field_assoc(DatabaseResult,"BanUserIp",String,30);
		printf(String);
		db_get_field_assoc(DatabaseResult,"BanAdministratorName",String,30);
		printf(String);
		db_get_field_assoc(DatabaseResult,"BanUserReason",String,150);
		printf(String);
		db_get_field_assoc(DatabaseResult,"BanUserTime",String,30);
		printf(String);
	}
	db_free_result(DatabaseResult);
	return 1;
}
Code:
#include <a_samp>

#define MAXIMAL_PLAYERS 500

new DB:Database;
new UserName[MAXIMAL_PLAYERS][30];
new UserIp[MAXIMAL_PLAYERS][30];

public OnGameModeInit()
{
	Database = db_open("Server.db");
	new DBResult:DatabaseResult = db_query(Database,"CREATE TABLE IF NOT EXISTS `Bans` (`BanUserName` VARCHAR(30),`BanUserIp` VARCHAR(30),`BanAdministratorName` VARCHAR(30),`BanReason` VARCHAR(150),`BanTime` INT(30));");
	db_free_result(DatabaseResult);
	return 1;
}

public OnGameModeExit()
{
	db_close(Database);
	return 1;
}
Ban not added, why?
Hervest1998 is offline   Reply With Quote
Old 28/07/2012, 06:42 AM   #2
ReneG
High-roller
 
Join Date: Oct 2011
Location: Sublime Text 2
Posts: 1,981
Reputation: 337
Default Re: SQLite Ban System

print the query!!!!11!!!111
ReneG is offline   Reply With Quote
Old 28/07/2012, 06:43 AM   #3
Hervest1998
Little Clucker
 
Join Date: Jul 2012
Posts: 18
Reputation: 4
Default Re: SQLite Ban System

What?
Hervest1998 is offline   Reply With Quote
Old 28/07/2012, 07:17 AM   #4
Hervest1998
Little Clucker
 
Join Date: Jul 2012
Posts: 18
Reputation: 4
Default Re: SQLite Ban System

Any help?
Hervest1998 is offline   Reply With Quote
Old 28/07/2012, 10:01 AM   #5
Hervest1998
Little Clucker
 
Join Date: Jul 2012
Posts: 18
Reputation: 4
Default Re: SQLite Ban System

Please help.
Hervest1998 is offline   Reply With Quote
Old 28/07/2012, 01:19 PM   #6
ReVo_
Gangsta
 
ReVo_'s Avatar
 
Join Date: Oct 2009
Posts: 539
Reputation: 73
Default Re: SQLite Ban System

Insert INTO have different syntax, this is UPDATE syntax

I've tried to make another system (i think more efficent than your) use this: http://pastebin.com/PjUt6tDF

Maybe you can improve your code by reading mine

#edit: important fixbug in IsBanned function
ReVo_ is offline   Reply With Quote
Old 28/07/2012, 01:53 PM   #7
Hervest1998
Little Clucker
 
Join Date: Jul 2012
Posts: 18
Reputation: 4
Default Re: SQLite Ban System

Update? I want add ban no update ? How to update if not added?
Code:
INSERT INTO bans (time, reason, nickname) VALUES ('%d', '%s', '%s')
Eh, what thisis querys?
Hervest1998 is offline   Reply With Quote
Old 28/07/2012, 02:14 PM   #8
ReVo_
Gangsta
 
ReVo_'s Avatar
 
Join Date: Oct 2009
Posts: 539
Reputation: 73
Default Re: SQLite Ban System

INSERT INTO `Bans` SET `BanUserName` = '%s',`BanUserIp` = '%s',`BanAdministratorName` = '%s',`BanReason` = '%s',`BanTime` = '%i'


INSERT INTO `Bans`(BanUserName, BanUserIp, BanAdministratorName, BanReason, BanTime) VALUES ('%s', '%s', '%s', '%s', '%d')

This is your query fixed

--

INSERT INTO bans (time, reason, nickname) VALUES ('%d', '%s', '%s')

This is the correct query if you want to add into "bans" table
( time, reason, nickname ) -> where add values?
( values ) -> values
ReVo_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [0.3e] Dynamic ATM System [zcmd, SQLite, streamer] ReneG Filterscripts 27 10/09/2012 11:59 PM
[FilterScript] LorencBank (SQLite Bank system) Lorenc_ Filterscripts 18 13/01/2012 05:11 PM
[FilterScript] zXy_Fights System |SQLite| ZmaXy Filterscripts 1 26/12/2011 04:29 PM
Sqlite Vehicle System Bugging Norn Help Archive 3 02/10/2010 12:42 AM


All times are GMT. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.