sscanf help
#1

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

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)
Reply
#3

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)