String in if() statements - Riddy - 21.12.2012
How can I add stirng in 'if' statements?
I am trying to check if a certain var contains 'None'...
Re: String in if() statements -
Lapon - 21.12.2012
Can you please tell a bit more clearly actually what your wanting?
Re: String in if() statements -
Lordzy - 21.12.2012
wiki.sa-mp.com/wiki/strcmp
Example:
pawn Код:
new Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
if(!strcmp(Lname, "None", true)) return SendClientMessageToAll(-1, "None");
Re: String in if() statements - Riddy - 21.12.2012
The thing is, am looking for something like this:
if(hInfo[h][hOwner] == "None")
{
CreateObject(blah blah);
}
Re: String in if() statements -
ikey07 - 21.12.2012
use strfind function
if(!strfind(string,"None", true))
Re: String in if() statements - Riddy - 21.12.2012
Quote:
Originally Posted by ikey07
use strfind function
if(!strfind(string,"None", true))
|
Ah never though of that, thanks ikey
Re: String in if() statements -
wups - 21.12.2012
Quote:
Originally Posted by Riddy
Ah never though of that, thanks ikey
|
No, for the reason you need it - use strcmp(like in the example above).
Re: String in if() statements - Riddy - 21.12.2012
Quote:
Originally Posted by wups
No, for the reason you need it - use strcmp(like in the example above).
|
I dont see why I should use strcmp, considering am only looking for 'None' in the variables hInfo[h][hOwner]...
if(strfind(hInfo[h][hOwner], "None", true)), this looks for 'None' in the variables as for as I know...
Re: String in if() statements -
AndreT - 21.12.2012
What the hell is the problem with you? If your property does not have an owner, make the string "*" by simply assigning the value (no format, no strcat, no whatsoever, just simply = to assign).
To check if the property is unowned, do if(hInfo[h][hOwner][0] == '*'). Simple and quick, voila.
And there's really nothing to justify using strfind instead of strcmp if you've designed the system yourself and are aware of the array contents
Re: String in if() statements - Riddy - 21.12.2012
Quote:
Originally Posted by AndreT
What the hell is the problem with you? If your property does not have an owner, make the string "*" by simply assigning the value (no format, no strcat, no whatsoever, just simply = to assign).
To check if the property is unowned, do if(hInfo[h][hOwner][0] == '*'). Simple and quick, voila.
And there's really nothing to justify using strfind instead of strcmp if you've designed the system yourself and are aware of the array contents 
|
The thing is, I never made the system, but I know whats the data suppose to be.. and am just looking if 'None' is in there and yes am wrong, I should be using strcmp not strfind.