SA-MP Forums Archive
What to use to compare to multiple posibilities? - 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: What to use to compare to multiple posibilities? (/showthread.php?tid=422400)



What to use to compare to multiple posibilities? - Nathan_Taylor - 13.03.2013

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?


Re: What to use to compare to multiple posibilities? - Patrick - 13.03.2013

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;
}



Re: What to use to compare to multiple posibilities? - Denying - 13.03.2013

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".


Re: What to use to compare to multiple posibilities? - Patrick - 13.03.2013

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)



Re: What to use to compare to multiple posibilities? - Nathan_Taylor - 13.03.2013

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


Re: What to use to compare to multiple posibilities? - Denying - 13.03.2013

Try mine now, I edited it.


Re: What to use to compare to multiple posibilities? - RajatPawar - 13.03.2013

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.