SA-MP Forums Archive
work vehicles. - 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: work vehicles. (/showthread.php?tid=647717)



work vehicles. - zZzTGTzZz - 09.01.2018

I need to make a certain vehicle for a job, I have this code.
If you do not have a job, you can not use it, but if you are from another job that is not this one, it leaves you.

if(Vehicle_Job_1(vehicleid) && Info[playerid][pJob] <= 1)
{
new Float:XV, Float:YV, Float:ZV;
GetPlayerPos(playerid, XV, YV, ZV);
SetPlayerPos(playerid, XV, YV, ZV);
SendClientMessage(playerid, -1, "{ffa500}[INFO] {ffffff}You need to be Pizza Boy to use this vehicle!");
}


Re: work vehicles. - Tord - 09.01.2018

You can use this method to check what model the car is.
we know that a pizzaboy is the id: 448 (https://sampwiki.blast.hk/wiki/Vehicle_Model_ID_List)
Then we can check if the model the player sits in, is equal to 448 by doing the following:

PHP код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 448)
    return 
SendClientMessage(playerid, -1"You need to be in the pizzaboy!"); 
https://sampwiki.blast.hk/wiki/GetVehicleModel
https://sampwiki.blast.hk/wiki/GetPlayerVehicleID

You may also want to check if the player is in a vehicle before doing this. That can be done by using "IsPlayerInVehicle(playerid)" (https://sampwiki.blast.hk/wiki/IsPlayerInVehicle)


Re: work vehicles. - zZzTGTzZz - 09.01.2018

Quote:
Originally Posted by Tord
Посмотреть сообщение
You can use this method to check what model the car is.
we know that a pizzaboy is the id: 448 (https://sampwiki.blast.hk/wiki/Vehicle_Model_ID_List)
Then we can check if the model the player sits in, is equal to 448 by doing the following:

PHP код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 448)
    return 
SendClientMessage(playerid, -1"You need to be in the pizzaboy!"); 
https://sampwiki.blast.hk/wiki/GetVehicleModel
https://sampwiki.blast.hk/wiki/GetPlayerVehicleID

You may also want to check if the player is in a vehicle before doing this. That can be done by using "IsPlayerInVehicle(playerid)" (https://sampwiki.blast.hk/wiki/IsPlayerInVehicle)
Thanks, and if I use == instead of <=, will it work?

here:
if(Vehicle_Job_1(vehicleid) && Info[playerid][pJob] <= 1)


Re: work vehicles. - Tord - 09.01.2018

That statement checks if the "Info[playerid][pJob]" is 1, 0, -1, -2 .... -inf. (Equal or lower than 1).

If you want to check if the player is on a certain job, you should check for one value, and not many different. It solely depends on what the values does