SA-MP Forums Archive
Problem with 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)
+--- Thread: Problem with strcmp? (/showthread.php?tid=405741)



Problem with strcmp? - thefatshizms - 07.01.2013

Hey, im trying to see if the vehicle you enter is your vehicle. Doesnt send a message at all even if i am not the owner

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new Vehicleid = GetPlayerVehicleID(playerid);
        if(VehicleInfo[Vehicleid][owned] == true && strcmp(VehicleInfo[Vehicleid][owner], PlayerName(playerid), true))
        {
            SendClientMessage(playerid, -1, "This is your vehicle");
        }
    }
    return 1;
}
And i am setting the vehicle you just bought owned before you ask


Re: Problem with strcmp? - Fabio11 - 07.01.2013

strcmp returns 0 if the strings are the same, so:

pawn Код:
if(VehicleInfo[Vehicleid][owned] == true && strcmp(VehicleInfo[Vehicleid][owner], PlayerName(playerid), true))
Becomes
pawn Код:
if(VehicleInfo[Vehicleid][owned] == true && strcmp(VehicleInfo[Vehicleid][owner], PlayerName(playerid), true) == false)