SA-MP Forums Archive
Help with strcmp, nick. - 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: Help with strcmp, nick. (/showthread.php?tid=576541)



[+REP] Help With Me Playernick, Using strcmp - Airman123 - 05.06.2015

Hello, i just made my house system.

I also introduced house key, so the player having key can enter the house.
But there's a little problem with it.

House owner can give maximum 10 keys, all good.

There is a command /ghk [slot] [playerid] to be used to give some one a key.
Im using dini to save data. so in saving file its like, KeyHolder1: (playername) [PlAyErName],

Its get written in exactly the same alphabets (captial, small), as the player chooses at samp cilent, before connecting to the server. (eg: SuPeR_MaN)

But, the problem is that, if the player changes (capital, small) alphabets, he won't be able to enter the house?

How can i fix it, so it ignore capital small thing.

Under Onplayerenterdynamiccp, im using following code.

Код:
if(!strcmp(hInfo[x][hKeyOwner1], PlayerInfo[playerid][pName], CASE_SENSETIVE)

//enter code
help me to fix it ;(


Re: Help with strcmp, nick. - Evocator - 05.06.2015

You can either capitalize (or minimize) both and compare them:

Here is a function i use to capitalize names (you can use tolower to minimize)
Код:
stock Capitalize(name[])
{
    new string[MAX_PLAYER_NAME+1];
    for (new i, j = strlen(name); i < j; i++)
    {
        format(string, sizeof (string), "%s%c", string, toupper(name[i]));
    }
    return string;
}
Or you can easily set the ignore case to true so it wont matter if its capitalized or not in strcmp:

Код:
strcmp(const string1[], const string2[], bool:ignorecase, length)
Quote:

When set to true, the case doesn't matter - HeLLo is the same as Hello. When false, they're not the same.




Re: Help with strcmp, nick. - Airman123 - 05.06.2015

Thanks dude!
+REP.