SA-MP Forums Archive
is invalidname - 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: is invalidname (/showthread.php?tid=407771)



is invalidname - speed258 - 15.01.2013

Hey guys i wanna ask you how to check is that player name exist in dialog system. Thanks


Re: is invalidname - Shabi RoxX - 15.01.2013

use " if " statement to check input using strcmp()

Like:
Код:
if(strcmp(inputtext, "AnyName", true) == 0) //name matched
else //name not matched



Re: is invalidname - speed258 - 15.01.2013

but if i want to check if this name/id not exist i get a message ****** what can you say about that?
My idea correct or not?
Quote:

if(sscanf(inputtext,"u",playeridd) == INVALID_PLAYER_ID))

new playeridd[MAX_PLAYER_NAME];


Re: is invalidname - speed258 - 16.01.2013

still not working do that:
Quote:

new play[MAX_PLAYER_NAME];
new playID = StrFind(play);
if(sscanf(inputtext,"u",playID)) return ShowPlayerDialog(playerid,44,DIALOG_STYLE_INPUT,"b la bla
if(playID == INVALID_PLAYER_ID)

what to do?


Re: is invalidname - Threshold - 16.01.2013

Let's give you an example command. You're not interpreting what ****** is actually meaning by this. When you use sscanf, you would only return something if they have got the syntax wrong or are missing a parameter.

For example:
pawn Код:
CMD:kick(playerid, params[]) //My command /kick to kick players
{
    new playersID; //This is what we use to save the ID of the player we want to kick
    if(sscanf(params, "u", playersID)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /kick [playerid]"); //Is returned because I did not add the 'playerid' part of the command
    if(playersID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "Player is not connected."); //Is only returned if you have included all parameters
   //continues...
So your code would be something like:
pawn Код:
new play[MAX_PLAYER_NAME];
new playID;
if(sscanf(inputtext, "u", playID)) return SendClientMessage(playerid, 0xFF0000FF, "You must enter an id.");
if(playID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "Player is not connected.");
//Code continues
Obviously, you don't have to return with SendClientMessage, you can use ShowPlayerDialog if that is what you're wanting to do.