What to use to compare to multiple posibilities?
#1

So, I have this around the top of my GM
pawn Код:
new LSPDvehicles[] =
{
    596, 597, 598, 599, 601, 497, 528, 490
};
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    //get vehicle id
    new vid;
    vid = GetVehicleModel(vehicleid);
    //check for factions
    if(vehicleid == LSPDvehicles[vid]){
        SendClientMessage(playerid, -1, "police car");
    }
   
    return 1;
}
So, when I enter any vehicle with the model ids listed in the LSPDvehicles, it should simply give me "hello world" message saying "police car" a test. However, it doesn't send me the message. Why is it not detecting that I am getting into a police car?
Reply
#2

create a loop for that array LSPDvehicles and instead of GetVehicleModel(vehicleid) try to change it to GetPlayerVehicleID(playerid) as your checking the vehicle id.

EDIT
try this
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    for(new i = 0; i < sizeof(LSPDvehicles); i++)
    {
        if(GetPlayerVehicleID(playerid) == LSPDvehicles[i])
        {
            SendClientMessage(playerid, -1, "police car");
            return 1;
        }
    }
    return 1;
}
Reply
#3

Try this.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    //get vehicle id
    new vid;
    vid = GetVehicleModel(vehicleid);
    //check for factions
    for(new i = 0; i <= 7; i++)
    {
        if(vehicleid == LSPDvehicles[i])
        {
            SendClientMessage(playerid, -1, "police car");
        }
    }
    return 1;
}
You are telling it to check LSPDvehicles at the cell number "vid".
Reply
#4

Try Denying or Mine. those 2 code must work.

EDIT
you can try using your's
pawn Код:
GetVehicleModel(vehicleid)
or if it doesn't work try using
pawn Код:
GetPlayerVehicleID(playerid)
Reply
#5

Quote:
Originally Posted by pds2012
Посмотреть сообщение
create a loop for that array LSPDvehicles and instead of GetVehicleModel(vehicleid) try to change it to GetPlayerVehicleID(playerid) as your checking the vehicle id.

EDIT
try this
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    for(new i = 0; i < sizeof(LSPDvehicles); i++)
    {
        if(GetPlayerVehicleID(playerid) == LSPDvehicles[i])
        {
            SendClientMessage(playerid, -1, "police car");
            return 1;
        }
    }
    return 1;
}
Actually, I'm checking for the model ID
Reply
#6

Try mine now, I edited it.
Reply
#7

pds, getting the vehicle ID is different - it's an unique ID assigned to a vehicle in your server. An Infernus spawned alone in a server will have the ID 0, and MODEL 411.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)