SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 20/03/2010, 05:26 PM   #1
borisblat
Big Clucker
 
Join Date: Apr 2009
Posts: 155
Reputation: 0
Default [QUESTION] How do I check if one string equals to another one?

How do I check if one string equals to another one?

thanks,
borisblat is offline  
Old 20/03/2010, 06:04 PM   #2
MadeMan
High-roller
 
MadeMan's Avatar
 
Join Date: Jun 2007
Posts: 3,488
Reputation: 256
Default Re: [QUESTION] How do I check if one string equals to another one?

http://wiki.sa-mp.com/wiki/Strcmp
MadeMan is offline  
Old 20/03/2010, 06:09 PM   #3
jameskmonger
High-roller
 
jameskmonger's Avatar
 
Join Date: Nov 2009
Location: London, England
Posts: 1,113
Reputation: 76
Default Re: [QUESTION] How do I check if one string equals to another one?

pawn Code:
if(string1 == string2) {
//dothis
} else {
//dothis
}
jameskmonger is offline  
Old 20/03/2010, 07:45 PM   #4
borisblat
Big Clucker
 
Join Date: Apr 2009
Posts: 155
Reputation: 0
Default Re: [QUESTION] How do I check if one string equals to another one?

thx MadeMan,

and jameskmonger, this thing used only for numbers no?
borisblat is offline  
Old 20/03/2010, 07:53 PM   #5
Miguel
High-roller
 
Miguel's Avatar
 
Join Date: Dec 2009
Posts: 1,571
Reputation: 50
Default Re: [QUESTION] How do I check if one string equals to another one?

Quote:
Originally Posted by borisblat
thx MadeMan,
and jameskmonger, this thing used only for numbers no?
Right.
Miguel is offline  
Old 20/03/2010, 07:56 PM   #6
borisblat
Big Clucker
 
Join Date: Apr 2009
Posts: 155
Reputation: 0
Default Re: [QUESTION] How do I check if one string equals to another one?

^^
well I used strcmp, here is the code|:
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
Code:
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;
}
borisblat is offline  
Old 20/03/2010, 08:02 PM   #7
jameskmonger
High-roller
 
jameskmonger's Avatar
 
Join Date: Nov 2009
Location: London, England
Posts: 1,113
Reputation: 76
Default Re: [QUESTION] How do I check if one string equals to another one?

Quote:
Originally Posted by borisblat
and jameskmonger, this thing used only for numbers no?
What do you mean?
jameskmonger is offline  
Old 20/03/2010, 08:05 PM   #8
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Location: Slovenia
Posts: 6,340
Reputation: 365
Default Re: [QUESTION] How do I check if one string equals to another one?

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 Code:
if(string1 == string2) {
//dothis
} else {
//dothis
}
With this, you could compare integers (numbers).
Correlli is offline  
Old 20/03/2010, 08:08 PM   #9
jameskmonger
High-roller
 
jameskmonger's Avatar
 
Join Date: Nov 2009
Location: London, England
Posts: 1,113
Reputation: 76
Default Re: [QUESTION] How do I check if one string equals to another one?

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 Code:
if(string1 == string2) {
//dothis
} else {
//dothis
}
With this, you could compare integers (numbers).
Can't you compare strings? (I'm used to Java xD)
jameskmonger is offline  
Old 20/03/2010, 08:09 PM   #10
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Location: Slovenia
Posts: 6,340
Reputation: 365
Default Re: [QUESTION] How do I check if one string equals to another one?

Quote:
Originally Posted by jameskmonger
Can't you compare strings? (I'm used to Java xD)
No, you need to use the strcmp function.
Correlli is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
string check dont work Headshot1108 Help Archive 16 17/03/2010 04:45 PM
String-Question Stas92 Help Archive 0 04/03/2010 09:13 AM
[SOLVED] How to check string? SiJ Help Archive 2 21/12/2009 03:24 PM
String/Log Question acade Help Archive 0 04/07/2009 06:01 PM
if strlen equals AdminPW. shitbird Help Archive 4 30/05/2009 08:43 PM


All times are GMT. The time now is 01:14 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.