IsPlayerInVehicle - 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: IsPlayerInVehicle (
/showthread.php?tid=462215)
IsPlayerInVehicle -
JonesyFoCoTDM - 05.09.2013
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;
}
Re: IsPlayerInVehicle -
Cypress - 05.09.2013
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;
}
Re: IsPlayerInVehicle -
JonesyFoCoTDM - 05.09.2013
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?
Re : IsPlayerInVehicle -
Matnix - 05.09.2013
Something like that.
pawn Код:
if(GetVehicleModel(vehicleid) == 403)
{
// your code
}
Re: Re : IsPlayerInVehicle -
JonesyFoCoTDM - 05.09.2013
Quote:
Originally Posted by Matnix
Something like that.
pawn Код:
if(GetVehicleModel(vehicleid) == 403) { // your code }
|
Na, that doesn't compile mate.
Re : IsPlayerInVehicle -
Matnix - 05.09.2013
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;
}
Re: Re : IsPlayerInVehicle -
JonesyFoCoTDM - 05.09.2013
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
Re: IsPlayerInVehicle -
kaisersouse - 05.09.2013
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.