SA-MP Forums Archive
ID 0 Bug. - 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: ID 0 Bug. (/showthread.php?tid=618741)



ID 0 Bug. - ChristolisTV - 09.10.2016

Hello, please read carefully.

I have a /kick command. When I'm ID 0 on the server and kick ID 1 for example it says on a message that I kicked myself but actually it kicked the target. // Or when there is a player ID 0 connected and ID 2 tries to kick ID 4 for example it says that ID 2 kicked ID 0 but it actually kicked the correct target.

I tried updating sscanf and downgrading it, but still the same.

Kick command: (This also happens with other types of commands like this)

PHP код:
CMD:kick(playeridparams[])
{
    new
        
targetid,
        
Reason[256],
        
pName[MAX_PLAYER_NAME],
        
tName[MAX_PLAYER_NAME],
        
string[256]
    ;
    
GetPlayerName(playeridpNamesizeof(pName));
    
GetPlayerName(targetidtNamesizeof(tName));
    
format(stringsizeof(string), "{4286f4}(Information):{FFFFFF} Administrator {FF0000}%s{FFFFFF} has kicked {00FF00}%s{FFFFFF}! | Reason: {FFFF00}%s"pNametNameReason);
    
    if(
P_DATA[playerid][aLevel] < 1)return SendClientMessage(playerid, -1"{FF0000}(ERROR):{FFFFFF} You must be Moderator to use this command!");
    if(
sscanf(params"ds[256]"targetidReason))return SendClientMessage(playerid, -1"{FF9900}(Usage):{FFFFFF} /kick [ID] [Reason]");
    if(!
IsPlayerConnected(targetid))return SendClientMessage(playerid, -1"{FF0000}(ERROR):{FFFFFF} This player is not connected!");
    
    
SendClientMessageToAll(-1string);
    
SetTimerEx("KickTimer"1000false"i"targetid);
    return 
1;

(If someone helps me, he earns a rep from me)


Re: ID 0 Bug. - Konstantinos - 09.10.2016

Getting the player's name before sscanf will always get the name of the player with ID 0 as "targetid" will be by default 0 and hasn't been assigned a value yet. Move it after sscanf and IsPlayerConnected check.

Checking if "targetid" is INVALID_PLAYER_ID is much better than calling IsPlayerConnected function.


Re: ID 0 Bug. - ChristolisTV - 09.10.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Getting the player's name before sscanf will always get the name of the player with ID 0 as "targetid" will be by default 0 and hasn't been assigned a value yet. Move it after sscanf and IsPlayerConnected check.

Checking if "targetid" is INVALID_PLAYER_ID is much better than calling IsPlayerConnected function.
Thanks! This solved my problem! (+1 Rep)