Is name connected (not ID) - 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 name connected (not ID) (
/showthread.php?tid=445497)
Is name connected (not ID) -
jakejohnsonusa - 21.06.2013
I'm working on a better MDC for my RP script. The only area I'm getting stuck on is how to detect if the (inputtext) is online. (inputtext) = name typed.
I tried turning the (inputtext) into an integer using strval, but if the name isn't connected the integer just turns it into a player ID that is online.
So I'm working on doing somthing like this:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new name[64];
if(GetPlayerName(i, name, sizeof(name)) == (inputtext))// Error Line
{
}
else
{
return ShowPlayerDialog(playerid, 9130,DIALOG_STYLE_INPUT,"Name Lookup","Error: No record of this name exists!\nType a valid name that you would like to lookup.","Search","Cancel");
}
}
}
However, I get this error when I do that:
Код:
error 033: array must be indexed (variable "inputtext")
Anyone know how I can do this without errors, or know of a better way to check the name?
Respuesta: Is name connected (not ID) -
JustBored - 21.06.2013
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new name[64];
if(strcmp(GetPlayerName(i, name, sizeof(name)), inputtext, false)// Error Line
{
}
else
{
return ShowPlayerDialog(playerid, 9130,DIALOG_STYLE_INPUT,"Name Lookup","Error: No record of this name exists!\nType a valid name that you would like to lookup.","Search","Cancel");
}
}
}
Re: Is name connected (not ID) -
jakejohnsonusa - 21.06.2013
Oh perfect, I had to change it up a bit (because of error's and I also had it a bit backwards).
Here is the working version (for anyone who ever needs this):
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new name[64];
GetPlayerName(i, name, sizeof(name))
if(strcmp(name, (inputtext), true))
{
return ShowPlayerDialog(playerid, 9130,DIALOG_STYLE_INPUT,"Name Lookup","Error: No record of this name exists!\nType a valid name that you would like to lookup.","Search","Cancel");
}
}
}
Thanks!
+1 Rep for the help