Help me
#1

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
Reply
#2

What's the error?
Reply
#3

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

You forgot one specifier in your sscanf params.

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

pName, name, reason > 3 parameters.
Reply
#5

Код:
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 ?
Reply
#6

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.
Reply
#7

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++ ]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)