SA-MP Forums Archive
Help me - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help me (/showthread.php?tid=599045)



Help me - ChickenCrazy - 20.01.2016

I just wanted to make that his ban go into SQLite but instead an error, Please help her [ REP + ]
Код:
CMD:banaccount(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 4)
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "ADMIN : Anda di larang menggunakan CMD ini");
		return 1;
	}

	new string[128], DBResult:result, Query[240], pName[24],  reason[64], name[MAX_PLAYER_NAME], bannedby[MAX_PLAYER_NAME], datestring[24], timestring[24];
	if(sscanf(params, "s[24]s[48]", pName, name, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /banaccount [name] [reason]");
	
	format(Query, sizeof(Query), "SELECT `NAME` FROM `BANNED` WHERE `NAME` = '%s'", pName);
	result = db_query(bans, Query);

	if(doesAccountExist(name))
	{
		OnPlayerOfflineLogin(name);
		if( CheckBan(name) == 1 )
		{
			SendClientMessageEx( playerid, COLOR_WHITE, "Player telah di ban!" );
			return 1;
		}
		if( PlayerInfo[MAX_PLAYERS][pAdmin] >= 2 )
		{
			SendClientMessageEx( playerid, COLOR_WHITE, "Tidak bisa /banaccount id admin!" );
			return 1;
		}
		
		PlayerInfo[MAX_PLAYERS][pWarns] += 3;
		if(PlayerInfo[MAX_PLAYERS][pWarns] >= 3)
		{
			new year, month,day;
			getdate(year, month, day);
			format(string, sizeof(string), "AdmCmd: %s (IP:%s) telah di offline banned oleh %s, alasan: %s (%d-%d-%d)", name, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid), reason,month,day,year);
			Log("logs/ban.log", string);
			format(string, sizeof(string), "AdmCmd: %s telah di offline banned oleh %s, alasan: %s", name, GetPlayerNameEx(playerid), reason);
			ABroadCast(COLOR_LIGHTRED,string,2);
			PlayerInfo[MAX_PLAYERS][pBanned] = 1;
			GetPlayerName(playerid,bannedby,sizeof(bannedby));
			format(string, sizeof(string),"had 3 Warning, reason: %s",reason);
			OnPlayerOfflineSave(name);
			return 1;
		}
		else if (!db_num_rows(result))
		{
			new day, month, year, second, minute, hour;
			getdate(day, month, year), gettime(hour, minute, second);
			format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year), format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
			
			format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '0', '%s', '%s', '%s', '%s')", DB_Escape(pName), reason, DB_Escape(GetName(playerid)), datestring, timestring);
			result = db_query(bans, Query);
			if(result)
				{
					format(string, sizeof(string), "BAN: %s has been offline banned by %s(%d) due to %s", pName, GetName(playerid), playerid, reason);
					SendClientMessageToAll(-1, string), string = "\0";

					printf("[ban] [%s]: offlinebanned %s due to %s", GetName(playerid), pName, reason);
				}
				else
				{
					format(string, sizeof(string), "SERVER: Failed to ban '%s'..", pName), SendClientMessage(playerid, -1, string);
					printf("[ban] [%s]: failed to offlineban %s due to %s", GetName(playerid), pName, reason);
				}
			db_free_result(result);
		return 1;
		}
		new year, month, day;
		getdate(year, month, day);
		format(string, sizeof(string), "AdmCmd: %s telah di offline banned oleh %s, reason: %s", name, GetPlayerNameEx(playerid), reason);
		ABroadCast(COLOR_LIGHTRED, string, 2);
		format(string, sizeof(string), "AdmCmd: %s telah di offline banned oleh %s, reason: %s (%d-%d-%d)", name, GetPlayerNameEx(playerid), reason,month, day, year);
		Log("logs/admin.log", string);
		OnPlayerOfflineSave(name);	
		return 1;
	}
	db_free_result(result);
	return 1;
}
" Simple Ban System & Ban SQLite "
HERE : PasteBin


Re: Help me [ REP + ] - FreAkeD - 20.01.2016

What's the error?


Re: Help me [ REP + ] - ChickenCrazy - 20.01.2016

Fix, But now: sscanf warning: format specifier does not match the parameter count, here is a solution?


Re: Help me [ REP + ] - FreAkeD - 20.01.2016

You forgot one specifier in your sscanf params.

s[24]s[48] > 2 specifiers.

pName, name, reason > 3 parameters.


Re: Help me [ REP + ] - ChickenCrazy - 20.01.2016

Код:
CMD:banaccount(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 4)
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "ADMIN : Anda di larang menggunakan CMD ini");
		return 1;
	}

	new string[128], DBResult:result, Query[240], pName[24],  reason[64], name[MAX_PLAYER_NAME], bannedby[MAX_PLAYER_NAME], datestring[24], timestring[24];
	if(sscanf(params, "s[24]s[24]s[48]", pName, name, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /banaccount [name] [reason]");
	
	format(Query, sizeof(Query), "SELECT `NAME` FROM `BANNED` WHERE `NAME` = '%s'", pName);
	result = db_query(bans, Query);

	if(doesAccountExist(name))
	{
		OnPlayerOfflineLogin(name);
		if( CheckBan(name) == 1 )
		{
			SendClientMessageEx( playerid, COLOR_WHITE, "Player telah di ban!" );
			return 1;
		}
		if( PlayerInfo[MAX_PLAYERS][pAdmin] >= 2 )
		{
			SendClientMessageEx( playerid, COLOR_WHITE, "Tidak bisa /banaccount id admin!" );
			return 1;
		}
		
		PlayerInfo[MAX_PLAYERS][pWarns] += 3;
		if(PlayerInfo[MAX_PLAYERS][pWarns] >= 3)
		{
			new year, month,day;
			getdate(year, month, day);
			format(string, sizeof(string), "AdmCmd: %s (IP:%s) telah di offline banned oleh %s, alasan: %s (%d-%d-%d)", name, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid), reason,month,day,year);
			Log("logs/ban.log", string);
			format(string, sizeof(string), "AdmCmd: %s telah di offline banned oleh %s, alasan: %s", name, GetPlayerNameEx(playerid), reason);
			ABroadCast(COLOR_LIGHTRED,string,2);
			PlayerInfo[MAX_PLAYERS][pBanned] = 1;
			GetPlayerName(playerid,bannedby,sizeof(bannedby));
			format(string, sizeof(string),"had 3 Warning, reason: %s",reason);
			OnPlayerOfflineSave(name);
			return 1;
		}
		else if (!db_num_rows(result))
		{
			new day, month, year, second, minute, hour;
			getdate(day, month, year), gettime(hour, minute, second);
			format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year), format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
			
			format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '0', '%s', '%s', '%s', '%s')", DB_Escape(pName), reason, DB_Escape(GetName(playerid)), datestring, timestring);
			result = db_query(bans, Query);
			if(result)
				{
					format(string, sizeof(string), "BAN: %s has been offline banned by %s(%d) due to %s", pName, GetName(playerid), playerid, reason);
					SendClientMessageToAll(-1, string), string = "\0";

					printf("[ban] [%s]: offlinebanned %s due to %s", GetName(playerid), pName, reason);
				}
			db_free_result(result);
		return 1;
		}
		new year, month, day;
		getdate(year, month, day);
		format(string, sizeof(string), "AdmCmd: %s telah di offline banned oleh %s, reason: %s", name, GetPlayerNameEx(playerid), reason);
		ABroadCast(COLOR_LIGHTRED, string, 2);
		format(string, sizeof(string), "AdmCmd: %s telah di offline banned oleh %s, reason: %s (%d-%d-%d)", name, GetPlayerNameEx(playerid), reason,month, day, year);
		Log("logs/admin.log", string);
		OnPlayerOfflineSave(name);	
		return 1;
	}
	db_free_result(result);
	return 1;
}
Now the even does not work ?


Re: Help me [ REP + ] - FreAkeD - 20.01.2016

if(sscanf(params, "s[24]s[64]", name, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /banaccount [name] [reason]");

Why do you look for the name twice? Try what's above.


Re: Help me [ REP + ] - ChickenCrazy - 20.01.2016

Quote:
Originally Posted by FreAkeD
Посмотреть сообщение
if(sscanf(params, "s[24]s[64]", name, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /banaccount [name] [reason]");

Why do you look for the name twice? Try what's above.
Thanks WORK [ REP++ ]