strcmp...
#1

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?
Reply
#2

pawn Код:
if(strcmp(PlayerGang, OtherGang, true) == 0)
strcmp returns a negative value when strings are the same.
Reply
#3

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?
Reply
#4

i dno but probably something like
if(PlayerGang == OtherGang)
xD coz i know == means if left is equal to right..
Reply
#5

To above, didn't work.
Reply
#6

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)
Reply
#7

edit: i think it works now.. Going to tell if something goes wrong anyways :P.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)