PDA

View Full Version : Comapre strings with online players - is it possible?


denNorske
26/01/2014, 12:25 PM
Hello!

I am currently making a command that will allow the owners of a server to be able to change the password of an offline player (my script is made so the command wont work if the player is online)

So, i am wondering, can you compare a string with if it's an invalid player id ?

new passname[MAX_PLAYER_NAME+1];

//then i use the sscanf line to define that the passname is the name of the account
if(sscanf(params, "s[MAX_PLAYER_NAME+1]s[130]", passname, password))
{
//send an error here ofc
}

//then i tried this, but it didn't work out so well, because the error tells me that it must be indexed.
if(passname == INVALID_PLAYER_ID)
//But, since it is the PLAYER_ID - Do i have to use a stock that retrieves the id of the name?




Oh well, not that hard but, am i right i need a stock there?

Ranshand
26/01/2014, 12:37 PM
GetPlayerOnLine(Name[])
{
for(new Slots = GetMaxPlayers(), P; P < Slots; P++)
{
if(IsPlayerConnect(P))
{
new PlayerName[MAX_PLAYER_NAME + 1];
GetPlayerName(P,PlayerName,MAX_PLAYER_NAME);
if(!strcmp(Name,PlayerName,false)) return 1;
}
}
return 0;
}


if(!GetPlayerOnLine(passname))
{
//Code
}

denNorske
26/01/2014, 01:20 PM
Thankyou for that one, and as far as i can see, this is your own stock for checking if the name is online.

I guess i found out, that you can compare strings with INVALID_PLAYER_ID then ^^