Help with strcmp, nick.
#1

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 ;(
Reply
#2

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.

Reply
#3

Thanks dude!
+REP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)