SA-MP Forums Archive
Command returns an invalid error - 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: Command returns an invalid error (/showthread.php?tid=647342)



Command returns an invalid error - Parallex - 03.01.2018

Hey there everyone,

So this is the offline ban command from my script. There is one problem with the command. Even if the account which we are attempting to ban exists, it gives us the message "* User not found!"* even though it exists. This is the code:

Код:
YCMD:oban(playerid, params[], help) {
	if(help) {
		SendClientMessage(playerid, X11_WHITE, "Bans an offline player");
		return 1;
	}
	new username[(MAX_PLAYER_NAME*2)+1],reason[128];
	if(!sscanf(params,"s[" #MAX_PLAYER_NAME "]s[128]",username,reason)) {
		mysql_real_escape_string(username, username);
		format(query, sizeof(query), "select INET_NTOA(`ip`),a.id FROM connections ca INNER JOIN characters c on c.id = ca.charid inner join accounts a on a.id = c.accountid where (c.username = \"%s\" OR a.username = \"%s\") ORDER BY ca.id DESC LIMIT 0,1",username,username);
		mysql_function_query(g_mysql_handle, query, true, "OnOfflineBanPlayer", "dss",playerid,username,reason);
	} else {
		SendClientMessage(playerid, X11_WHITE, "USAGE: /oban [username] [reason]");
	}
	return 1;
}

public OnOfflineBanPlayer(playerid, name[],reason[]) {
	new ip[16],accid[16];
	new rows, fields;
	cache_get_data(rows, fields);
	if(rows < 1) {
		SendClientMessage(playerid, X11_TOMATO_2, "* User not found");
		return 1;
	}
	cache_get_row(0,0,ip);
	cache_get_row(0,1,accid);
	format(query, sizeof(query),"INSERT INTO `bans` SET `bannerid` = %d,`reason` = \"%s\",`accountid` = %d,`ip` = INET_ATON(\"%s\")",GetPVarInt(playerid, "AccountID"), reason, strval(accid),ip);
	mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
	format(query, sizeof(query), "[AdmWarn]: %s has OBanned %s: %s",GetPlayerNameEx(playerid, ENameType_AccountName), name, reason);
	ABroadcast(X11_TOMATO_2, query, EAdminFlags_All);
	return 1;
}
Any help would be appreciated as to why it does that.


Re: Command returns an invalid error - Hunud - 03.01.2018

Try this.

Код:
public OnOfflineBanPlayer(playerid, name[],reason[]) {
	new ip[16],accid[16];
	new rows, fields;
	cache_get_data(rows, fields);
	if(rows > 0) {
		SendClientMessage(playerid, X11_TOMATO_2, "* User not found");
		return 1;
	}
	cache_get_row(0,0,ip);
	cache_get_row(0,1,accid);
	format(query, sizeof(query),"INSERT INTO `bans` SET `bannerid` = %d,`reason` = \"%s\",`accountid` = %d,`ip` = INET_ATON(\"%s\")",GetPVarInt(playerid, "AccountID"), reason, strval(accid),ip);
	mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
	format(query, sizeof(query), "[AdmWarn]: %s has OBanned %s: %s",GetPlayerNameEx(playerid, ENameType_AccountName), name, reason);
	ABroadcast(X11_TOMATO_2, query, EAdminFlags_All);
	return 1;
}



Re: Command returns an invalid error - Parallex - 04.01.2018

Quote:
Originally Posted by Hunud
Посмотреть сообщение
Try this.

Код:
public OnOfflineBanPlayer(playerid, name[],reason[]) {
	new ip[16],accid[16];
	new rows, fields;
	cache_get_data(rows, fields);
	if(rows > 0) {
		SendClientMessage(playerid, X11_TOMATO_2, "* User not found");
		return 1;
	}
	cache_get_row(0,0,ip);
	cache_get_row(0,1,accid);
	format(query, sizeof(query),"INSERT INTO `bans` SET `bannerid` = %d,`reason` = \"%s\",`accountid` = %d,`ip` = INET_ATON(\"%s\")",GetPVarInt(playerid, "AccountID"), reason, strval(accid),ip);
	mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
	format(query, sizeof(query), "[AdmWarn]: %s has OBanned %s: %s",GetPlayerNameEx(playerid, ENameType_AccountName), name, reason);
	ABroadcast(X11_TOMATO_2, query, EAdminFlags_All);
	return 1;
}
As expected, it does not seem to work.

It does say that the user has been offline banned yet the user is still not banned. Moreover, even if the account doesn't exist, it still shows the message that the account has been banned.