SA-MP Forums Archive
compare string - 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: compare string (/showthread.php?tid=297849)



compare string - ombre - 18.11.2011

Hi,

There is more fast that 'strcmp' because I use a command with:
strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0)

it's no at once, result after 0.5 sc.

Thanks


Re: compare string - Sinner - 18.11.2011

1. Zcmd (fast & easy to use)
2. Dcmd (slowest but faster then strcmp & easy to use)
3. Ycmd (fastest but a little harder to use)

Use the search button to search for them.


Re : compare string - ombre - 18.11.2011

Yes but Zcmd is for a command COMMAND:mycommand(playerid, params[]), here if I want to compare my name and the name house, strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0). How to use that?


Re : compare string - ombre - 18.11.2011

someone?


Re: compare string - Unte99 - 18.11.2011

If you will use zcmd:

pawn Code:
CMD:compare(playerid, params[])
{
    if(strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0)
    {
        // if they are the same
    }
    else
    {
        // if they are different
    }
    return 1;
}



Re: compare string - cessil - 18.11.2011

it's most likely not strcmp that's causing the lag, however if you really wanted you could assign a number to each player and index it to the house owners and then do something like this

if(PlayerID[playerid] == HouseInfo[ownerID])


Re : compare string - ombre - 19.11.2011

ok so inside the command, if I want to compare a string the best solution is strcmp?

Ycmd Zcmd...or sccanf can't to be used for that?


Re: compare string - MP2 - 19.11.2011

YCMD and ZCMD are for command processing.
sscanf is for string, erm, scanning? It's not for comparing.

strcmp stands for string compare.


Re: compare string - Juniior - 19.11.2011

Quote:
Originally Posted by Sinner
View Post
1. Zcmd (fast & easy to use)
2. Dcmd (slowest but faster then strcmp & easy to use)
3. Ycmd (fastest but a little harder to use)

Use the search button to search for them.
You provide false information. Take a look at the dcmd definition.

pawn Code:
dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0)
It uses strcmp and since macros or defines are a pre-processor directive I doubt it alters code delay. The specifiers allows what would have been input if using strcmp when declaring a dcmd command.