Text match (Enum & 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Text match (Enum & String) (
/showthread.php?tid=264731)
Text match (Enum & String) -
iPLEOMAX - 27.06.2011
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?
Re: Text match (Enum & String) -
iPLEOMAX - 28.06.2011
*bump*.. Been too long.. no replies. Any help would be appreciated.
Re: Text match (Enum & String) -
Shadoww5 - 28.06.2011
This command should return a message with the text typed ?
Re: Text match (Enum & String) -
iPLEOMAX - 28.06.2011
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..
Re: Text match (Enum & String) -
Jefff - 28.06.2011
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
Re: Text match (Enum & String) -
iPLEOMAX - 28.06.2011
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.