SA-MP Forums Archive
STRCMP problem - 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)
+--- Thread: STRCMP problem (/showthread.php?tid=573765)



STRCMP problem - Lirbo - 10.05.2015

pawn Код:
if(strcmp(DOF2_GetString(pFile(playerid),"Clan"), "None")) return SetPlayerColor(playerid,C_WHITE);
if(strcmp(DOF2_GetString(pFile(playerid),"Clan"), "Accuracy")) return SetPlayerColor(playerid,C_A);
why i always get the white color even if i'm in Accuracy?


AW: STRCMP problem - Mencent - 10.05.2015

Hello!

Does it work like this?
PHP код:
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"), "None")) return SetPlayerColor(playerid,C_WHITE);
if(!
strcmp(DOF2_GetString(pFile(playerid),"Clan"), "Accuracy")) return SetPlayerColor(playerid,C_A); 



Re: STRCMP problem - X337 - 10.05.2015

Код:
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"), "None")) return SetPlayerColor(playerid,C_WHITE);
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"), "Accuracy")) return SetPlayerColor(playerid,C_A);



Re: AW: STRCMP problem - Lirbo - 10.05.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Does it work like this?
PHP код:
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"), "None")) return SetPlayerColor(playerid,C_WHITE);
if(!
strcmp(DOF2_GetString(pFile(playerid),"Clan"), "Accuracy")) return SetPlayerColor(playerid,C_A); 
wow thanks hahaha by the way why I have to add that "!"?


AW: STRCMP problem - Mencent - 10.05.2015

The operator "!" means the same as == 0.
Look here:
PHP код:
if(strcmp(DOF2_GetString(pFile(playerid),"Clan"), "None") == 0) return SetPlayerColor(playerid,C_WHITE);// with == 0
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"), "Accuracy")) return SetPlayerColor(playerid,C_A);// with the operator "!" 
There are both options.

EDIT:
If strcmp return 0, the both strings are equal.
Both strings aren't equal, if strcmp return 1.


Re: AW: STRCMP problem - Macluawn - 10.05.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
If strcmp return 0, the both strings are equal.
Both strings aren't equal, if strcmp return 1.
In addition to what you said, strcmp can also return -1


Re: AW: STRCMP problem - Lirbo - 10.05.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Does it work like this?
PHP код:
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"), "None")) return SetPlayerColor(playerid,C_WHITE);
if(!
strcmp(DOF2_GetString(pFile(playerid),"Clan"), "Accuracy")) return SetPlayerColor(playerid,C_A); 
Quote:
Originally Posted by Mencent
Посмотреть сообщение
The operator "!" means the same as == 0.
Look here:
PHP код:
if(strcmp(DOF2_GetString(pFile(playerid),"Clan"), "None") == 0) return SetPlayerColor(playerid,C_WHITE);// with == 0
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"), "Accuracy")) return SetPlayerColor(playerid,C_A);// with the operator "!" 
There are both options.

EDIT:
If strcmp return 0, the both strings are equal.
Both strings aren't equal, if strcmp return 1.
Ahh thanks

btw.. what can I do if I want to Get color from a file?
example:
pawn Код:
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"),"Accuracy")) return SetPlayerColor(playerid,DOF2_GetString,"Clans/Accuracy.ini","Color");
error 076: syntax error in the expression, or invalid function call :3


AW: STRCMP problem - Mencent - 10.05.2015

@Macluawn:
Thanks!

@Lirbo:
Try this:
PHP код:
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"),"Accuracy"))return SetPlayerColor(playerid,DOF2_GetString("Clans/Accuracy.ini","Color")); 



Re: STRCMP problem - J4Rr3x - 10.05.2015

pawn Код:
if(!strcmp(DOF2_GetString(pFile(playerid),"Clan"),"Accuracy"))return SetPlayerColor(playerid,DOF2_GetInt("Clans/Accuracy.ini","Color"));
You need to use GetInt instead of strval