Why is this wrong?!
#1

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        new id = GetVehicleID(vehicleid);
        if(IsValidVehicle(id) && VehicleCreated[id] == VEHICLE_PLAYER)
        {
            if(PlayerName(playerid) =! VehicleOwner[id])
            {
            new msg[128];
            format(msg, sizeof(msg), "You don't have the keys of this vehicle");
            SendClientMessage(playerid, COLOR_GREY, msg);
            RemovePlayerFromVehicle(playerid);
            }
            else
            {
            SendClientMessage(playerid, COLOR_GREY, "This vehicle is yours.");
            }
        }
    }
    return 1;
}
I get warning
Код:
C:\Users\Nicolas\Downloads\samp03z_svr_R1_win32\filterscripts\avs.pwn(1782) : warning 211: possibly unintended assignment
And in-game this don't work, it says always "This vehicle is yours"
Thanks in advance!
Reply
#2

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        new id = GetVehicleID(vehicleid);
        if(IsValidVehicle(id) && VehicleCreated[id] = VEHICLE_PLAYER)
        {
            if(PlayerName(playerid) =! VehicleOwner[id])
            {
                new msg[128];
                format(msg, sizeof(msg), "You don't have the keys of this vehicle");
                SendClientMessage(playerid, COLOR_GREY, msg);
                RemovePlayerFromVehicle(playerid);
            }
            else
            {
            SendClientMessage(playerid, COLOR_GREY, "This vehicle is yours.");
            }
        }
    }
    return 1;
}
Try this.
Reply
#3

pawn Код:
if(!strcmp(PlayerName(playerid), VehicleOwner[id], false))
You can't compare two strings with integer operators.


EDIT: just fyi.. =! isn't an operator. !=
Reply
#4

check this :

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        new id = GetVehicleID(vehicleid);
        if(IsValidVehicle(id) && VehicleCreated[id] == VEHICLE_PLAYER)
        {
            if(PlayerName(playerid) != VehicleOwner[id])
            {
                new msg[128];
                format(msg, sizeof(msg), "You don't have the keys of this vehicle");
                SendClientMessage(playerid, COLOR_GREY, msg);
                RemovePlayerFromVehicle(playerid);
            }
            else
            {
            SendClientMessage(playerid, COLOR_GREY, "This vehicle is yours.");
            }
        }
    }
    return 1;
}
its " if(PlayerName(playerid) != VehicleOwner[id]) "
not " if(PlayerName(playerid) =! VehicleOwner[id]) "
Reply
#5

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        new id = GetVehicleID(vehicleid);
        if(IsValidVehicle(id) && VehicleCreated[id] = VEHICLE_PLAYER)
        {
            if(PlayerName(playerid) =! VehicleOwner[id])
            {
                new msg[128];
                format(msg, sizeof(msg), "You don't have the keys of this vehicle");
                SendClientMessage(playerid, COLOR_GREY, msg);
                RemovePlayerFromVehicle(playerid);
            }
            else
            {
            SendClientMessage(playerid, COLOR_GREY, "This vehicle is yours.");
            }
        }
    }
    return 1;
}
Try this.
That will just create another issue since his first operator (==) was actually correct.

OT: You used =! while the operator is !=.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        new id = GetVehicleID(vehicleid);
        if(IsValidVehicle(id) && VehicleCreated[id] == VEHICLE_PLAYER)
        {
            if(PlayerName(playerid) != VehicleOwner[id])
            {
                SendClientMessage(playerid, COLOR_GREY, "You don't have the keys of this vehicle!");
                RemovePlayerFromVehicle(playerid);
            }

            else return SendClientMessage(playerid, COLOR_GREY, "This vehicle is yours.");
        }
    }
   
    return 1;
}
EDIT: Optimised your code abit

See: https://sampwiki.blast.hk/wiki/Control_Structures#Operators
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)