Problem with strcmp?
#1

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)