PDA

View Full Version : work vehicles.


zZzTGTzZz
09/01/2018, 03:43 PM
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!");
}

Tord
09/01/2018, 03:50 PM
You can use this method to check what model the car is.
we know that a pizzaboy is the id: 448 (http://wiki.sa-mp.com/wiki/Vehicle_Model_ID_List)
Then we can check if the model the player sits in, is equal to 448 by doing the following:


if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 448)
return SendClientMessage(playerid, -1, "You need to be in the pizzaboy!");


http://wiki.sa-mp.com/wiki/GetVehicleModel
http://wiki.sa-mp.com/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)" (http://wiki.sa-mp.com/wiki/IsPlayerInVehicle)

zZzTGTzZz
09/01/2018, 04:02 PM
You can use this method to check what model the car is.
we know that a pizzaboy is the id: 448 (http://wiki.sa-mp.com/wiki/Vehicle_Model_ID_List)
Then we can check if the model the player sits in, is equal to 448 by doing the following:


if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 448)
return SendClientMessage(playerid, -1, "You need to be in the pizzaboy!");


http://wiki.sa-mp.com/wiki/GetVehicleModel
http://wiki.sa-mp.com/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)" (http://wiki.sa-mp.com/wiki/IsPlayerInVehicle)


Thanks, and if I use == instead of <=, will it work?

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

Tord
09/01/2018, 04:24 PM
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 :)