IsPlayerInVehicle
#1

I'm wanting this command to only work in vehicle 403, I'm sure it's with IsPlayerInVehicle, but I can't get my head around how it works. Any help is appreciated, thanks.

Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry packaging.\nMainstreet ammunation.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    return 1;
}
Reply
#2

Right exact there is just an example for you out there

https://sampwiki.blast.hk/wiki/Function:IsPlayerInVehicle

so

pawn Код:
if(IsPlayerInVehicle(playerid, 403))
pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    if(IsPlayerInVehicle(playerid, 403))
    {
         ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry packaging.\nMainstreet ammunation.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, -1, "You are not in a truck!");
    return 1;
}
Reply
#3

Quote:
Originally Posted by Cypress
Посмотреть сообщение
Right exact there is just an example for you out there

https://sampwiki.blast.hk/wiki/Function:IsPlayerInVehicle

so

pawn Код:
if(IsPlayerInVehicle(playerid, 403))
pawn Код:
CMD:tduty(playerid, params[])//Trucker-duty dialog
{
    if(IsPlayerInVehicle(playerid, 403))
    {
         ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose a route.", "Blueberry packaging.\nMainstreet ammunation.\nOff-duty (Removes the CP)", "Confirm", "Close list");
    }
    else return SendClientMessage(playerid, -1, "You are not in a truck!");
    return 1;
}
It stops the command working in other vehicles and on foot like I wanted, but it doesn't work in vehicle 403 either. Any ideas why?
Reply
#4

Something like that.
pawn Код:
if(GetVehicleModel(vehicleid) == 403)
{
    // your code
}
Reply
#5

Quote:
Originally Posted by Matnix
Посмотреть сообщение
Something like that.
pawn Код:
if(GetVehicleModel(vehicleid) == 403)
{
    // your code
}
Na, that doesn't compile mate.
Reply
#6

I fogor to something here's your script.
pawn Код:
CMD:tduty(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid); // I forgot that line
    if(GetVehicleModel(vehicleid) == 403)
    {
        // BLABLA
    }
    else return SendClientMessage(playerid, -1, "blabla");
    return 1;
}
Reply
#7

Quote:
Originally Posted by Matnix
Посмотреть сообщение
I fogor to something here's your script.
pawn Код:
CMD:tduty(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid); // I forgot that line
    if(GetVehicleModel(vehicleid) == 403)
    {
        // BLABLA
    }
    else return SendClientMessage(playerid, -1, "blabla");
    return 1;
}
Thanks for the help, works a charm
Reply
#8

Always remember that you MUST get the vehicles MODEL if you are using the modelid to check/act against (in this case 403)

The vehicleid paramater in IsPlayerInVehicle references the ID the server gives the vehicle when its created, not the model id of the vehicle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)