Comapre strings with online players - is it possible?
#1

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 ?

pawn Код:
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?
Reply
#2

Код:
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
}
Reply
#3

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 ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)