Text match (Enum & String)
#1

Hi Everyone. Need a help from you guys. ^_^

Here are the part of my codes:
pawn Код:
enum EInfo
{
        AText[26]; // Imagine it contains "yay!".
}

new PlayerInfo[MAX_PLAYERS][EInfo];


//In a Command:
CMD:test(playerid, params[])
{
        new string[26];
        if(!sscanf(params, "s[26]", string)
                if(strcmp(string,PlayerInfo[playerid][AText],true) == 0)
                {
                        SendClientMessage(playerid, COLOR_WHITE, "Matches!");
                }
        }
        return true;
}
But whenever i use /test bla bla.. it says "matches..."
/test anything.. it matches. -__-


Any Help?
Reply
#2

*bump*.. Been too long.. no replies. Any help would be appreciated.
Reply
#3

This command should return a message with the text typed ?
Reply
#4

if the enum string matches with the command input string, it will say "matches!"..

like if "PlayerInfo[playerid][AText]" is same as "string", it will return true..
Reply
#5

try
pawn Код:
if(!strcmp(string,PlayerInfo[playerid][AText],true) && strlen(PlayerInfo[playerid][AText]))
or

pawn Код:
if(!strcmp(string,PlayerInfo[playerid][AText],true) && PlayerInfo[playerid][AText][0] != '\0')
and show how U add text into playerinfo
Reply
#6

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
if(!strcmp(string,PlayerInfo[playerid][AText],true) && PlayerInfo[playerid][AText][0] != '\0')
and show how U add text into playerinfo
This worked, thanks man.

to your question, i can't directly add text in playerinfo, so i format a string with similar size and add it.

---

Could you explain me a bit why you added [0] != '\0' there? Will help me learn something.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)