SA-MP Forums Archive
sscanf help - 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: sscanf help (/showthread.php?tid=513361)



sscanf help - KevinPRINCE - 15.05.2014

Ok so I been recently getting a "u" bug. I made a temporary fix for this.
Код:
new named[MAX_PLAYER_NAME], idfix, kickid;
	kickid = playerid;
	sscanf(kickid, "u", idfix);
	if(idfix == INVALID_PLAYER_ID)
	{
	    SendClientMessageEx(playerid, COLOR_WHITE, "Server: Sorry you have been kicked due to a bug, relog.");
	    SetTimerEx("KickEx", 1000, 0, "i", kickid);
	    return 1;
	}
However sscanf(); is made for strings. How do I GetPlayerName? Ex: Kev_Klipz not Kev Klipz cause then sscanf might return other players with the name Kev.


Re: sscanf help - RenSoprano - 15.05.2014

You can use strcmp to find player name just set bool to true and it will player name.

Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));

if(strcmp(name, "Kevin_Blahblah", true, sizeof(name)) == 0)



Re: sscanf help - KevinPRINCE - 16.05.2014

Gahh you don't get it look at the script 20 times, I need the name with a _ for space. Not looking for a specific name.


Re: sscanf help - KevinPRINCE - 16.05.2014

@Ralfie I want it to search exactly the player's name. Full name. Not partial since if its partial it can check someone else with that partial name and their IDs might not be INVALID and the player's might and still pass this test. So something like this.
Код:
new input[MAX_PLAYER_NAME+1], named[MAX_PLAYER_NAME], idfix, kickid;
	format(input, sizeof(input), "%s", GetPlayerNameEx(playerid);
	kickid = playerid;
	sscanf(input, "u", idfix);
	if(idfix == INVALID_PLAYER_ID)
	{
	    SendClientMessageEx(playerid, COLOR_WHITE, "Server: Sorry you have been kicked due to a bug, relog.");
	    SetTimerEx("KickEx", 1000, 0, "i", kickid);
	    return 1;
	}
However this function for GetPlayerName returns the name with a space so the params are not together.