strcmp... - 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: strcmp... (
/showthread.php?tid=179746)
strcmp... -
rbN. - 28.09.2010
I got this:
pawn Код:
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof(name));
format(IsTheSame, sizeof(IsTheSame), "Gangs/Users/%s",name);
SendClientMessageToAll(COLOR_RED, IsTheSame);
if(dini_Isset(IsTheSame, "Gangname"))
{
format(PlayerGang, sizeof(PlayerGang), "%s",dini_Get(string1, "Gangname"));
format(OtherGang, sizeof(OtherGang), "%s",dini_Get(IsTheSame, "Gangname"));
if(strcmp(PlayerGang, OtherGang, false) == 0)
{
SendClientMessageToAll(COLOR_RED, "You are teleported! (1)");
SetPlayerPos(i, -478.9131,-560.6674,25.5234);
SetPlayerHealth(i, 100);
SetPlayerSkin(i, 105);
GivePlayerWeapon(i, 42, 1000);
GivePlayerWeapon(i, 25, 1000);
}
format(PlayerGang, sizeof(PlayerGang), "%s",dini_Get(string2, "Gangname"));
if(strcmp(PlayerGang, OtherGang, false) == 0)
{
SendClientMessageToAll(COLOR_RED, "You are teleported! (2)");
SetPlayerPos(i, -480.1998,-540.8129,25.5296);
SetPlayerHealth(i, 100);
SetPlayerSkin(i, 102);
GivePlayerWeapon(i, 42, 1000);
GivePlayerWeapon(i, 25, 1000);
}
SendClientMessageToAll(COLOR_RED, PlayerGang);
SendClientMessageToAll(COLOR_RED, memberscount);
}
}
}
Problem is, even though PlayerGang and OtherGang is not the same, it will still teleport the guy. I only want to teleport the person if PlayerGang is the same as OtherGang.. How to do that?
Re: strcmp... -
[XST]O_x - 28.09.2010
pawn Код:
if(strcmp(PlayerGang, OtherGang, true) == 0)
strcmp returns a negative value when strings are the same.
Re: strcmp... -
rbN. - 28.09.2010
Quote:
Originally Posted by [XST]O_x
pawn Код:
if(strcmp(PlayerGang, OtherGang, true) == 0)
strcmp returns a negative value when strings are the same.
|
Well, how to make it check if its equal then :S?
Re: strcmp... -
Mike_Peterson - 28.09.2010
i dno but probably something like
if(PlayerGang == OtherGang)
xD coz i know == means if left is equal to right..
Re: strcmp... -
rbN. - 28.09.2010
To above, didn't work.
Re: strcmp... -
[XST]O_x - 28.09.2010
Quote:
Originally Posted by RobinOwnz
Well, how to make it check if its equal then :S?
|
I just showed you.
pawn Код:
if(strcmp(PlayerGang, OtherGang, true) == 0)
Re: strcmp... -
rbN. - 28.09.2010
edit: i think it works now.. Going to tell if something goes wrong anyways :P.