SA-MP Forums Archive
Why is this wrong?! - 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: Why is this wrong?! (/showthread.php?tid=528372)



Why is this wrong?! - alanhutch - 27.07.2014

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!


Re: Why is this wrong?! - Beckett - 27.07.2014

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.


Re: Why is this wrong?! - d3ll - 27.07.2014

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


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


Re: Why is this wrong?! - Champ - 27.07.2014

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]) "


Re: Why is this wrong?! - Dignity - 27.07.2014

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