[QUESTION] How do I check if one string equals to another one? - 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: [QUESTION] How do I check if one string equals to another one? (
/showthread.php?tid=135451)
[QUESTION] How do I check if one string equals to another one? -
borisblat - 20.03.2010
How do I check if one string equals to another one?
thanks,
Re: [QUESTION] How do I check if one string equals to another one? -
MadeMan - 20.03.2010
https://sampwiki.blast.hk/wiki/Strcmp
Re: [QUESTION] How do I check if one string equals to another one? -
jameskmonger - 20.03.2010
pawn Код:
if(string1 == string2) {
//dothis
} else {
//dothis
}
Re: [QUESTION] How do I check if one string equals to another one? -
borisblat - 20.03.2010
thx MadeMan,
and jameskmonger, this thing used only for numbers no?
Re: [QUESTION] How do I check if one string equals to another one? -
Miguel - 20.03.2010
Quote:
Originally Posted by borisblat
thx MadeMan,
and jameskmonger, this thing used only for numbers no?
|
Right.
Re: [QUESTION] How do I check if one string equals to another one? -
borisblat - 20.03.2010
^^
well I used strcmp, here is the code|:
Код:
for(new id = 1; id<=MAX_CLANS; id++)
{
clanname = GetClanName(id);
format(cfile, sizeof(cfile), "Blat/Clans/%s.txt", clanname);
unionname2 = dini_Get(cfile, "Union");
if(strcmp(unionname2,unionname, true) == 0)
dini_Unset(cfile, "Union");
}
and it do crash to the filterscript what's wrong
here is the GetClanName if needed
Код:
stock GetClanName(clanid)
{
new file[256], clanname[256];
format(file, sizeof(file), "Blat/Clans/IDs/%d.txt", clanid);
clanname = dini_Get(file, "Name");
return clanname;
}
Re: [QUESTION] How do I check if one string equals to another one? -
jameskmonger - 20.03.2010
Quote:
Originally Posted by borisblat
and jameskmonger, this thing used only for numbers no?
|
What do you mean?
Re: [QUESTION] How do I check if one string equals to another one? -
Correlli - 20.03.2010
Quote:
Originally Posted by jameskmonger
What do you mean?
|
He means that your code is wrong if you want to compare the two strings.
Quote:
Originally Posted by jameskmonger
pawn Код:
if(string1 == string2) { //dothis } else { //dothis }
|
With this, you could compare integers (numbers).
Re: [QUESTION] How do I check if one string equals to another one? -
jameskmonger - 20.03.2010
Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by jameskmonger
What do you mean?
|
He means that your code is wrong if you want to compare the two strings.
Quote:
Originally Posted by jameskmonger
pawn Код:
if(string1 == string2) { //dothis } else { //dothis }
|
With this, you could compare integers (numbers).
|
Can't you compare strings? (I'm used to Java xD)
Re: [QUESTION] How do I check if one string equals to another one? -
Correlli - 20.03.2010
Quote:
Originally Posted by jameskmonger
Can't you compare strings? (I'm used to Java xD)
|
No, you need to use the strcmp function.