Is name connected (not ID)
#1

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)