Vehicle keys. - 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: Vehicle keys. (
/showthread.php?tid=543988)
Vehicle keys. -
mkmk - 30.10.2014
Does anyone know how to make something along the lines of vehicle keys? I've searched on ******, but couldn't find any tutorials. I'd really appreciate it if someone could link me or give me some ideas on how to make it as I'm finding it rather hard.
Thanks!
Re: Vehicle keys. -
Quickie - 30.10.2014
hope this will give you some ideas
pawn Код:
new VehKeys[MAX_PLAYERS]; // we will have a player variable vehkeys which is based on the vehicle id
CMD:buyveh(playerid,params[])
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
VehKeys[playerid]=CreateVehicle(520, X, Y, Z, 82.2873, 0, 1, 60);// storing the vehicle id to the player variable
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(VehKeys[playerid]!=vehicleid)// this checks if the player have the keys to the vehicle hes about to enter
{
ClearAnimations(playerid);// this stops the player from entering the vehicle if he dont have the keys for the vehicle
SendClientMessage(playerid,-1,"you cant enter this car because you dont have the key to this vehicle");
}
else
{
SendClientMessage(playerid,-1,"You are the owner of this vehicle");
}
return 1;
}
Re: Vehicle keys. -
mkmk - 30.10.2014
Quote:
Originally Posted by Quickie
hope this will give you some ideas
pawn Код:
new VehKeys[MAX_PLAYERS]; // we will have a player variable vehkeys which is based on the vehicle id
CMD:buyveh(playerid,params[]) { new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid,X,Y,Z); VehKeys[playerid]=CreateVehicle(520, X, Y, Z, 82.2873, 0, 1, 60);// storing the vehicle id to the player variable } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(VehKeys[playerid]!=vehicleid)// this checks if the player have the keys to the vehicle hes about to enter { ClearAnimations(playerid);// this stops the player from entering the vehicle if he dont have the keys for the vehicle SendClientMessage(playerid,-1,"you cant enter this car because you dont have the key to this vehicle"); } else { SendClientMessage(playerid,-1,"You are the owner of this vehicle"); } return 1; }
|
Cheers mate, repped. But how would I make certain keys for only Emergency Medical Services and Sheriff's Department? (when you are to be invited to the faction you acquire them, and it's the same key id for every faction member, yet different keys for EMS and SD.) Sorry if that didn't make sense.
Re: Vehicle keys. -
mkmk - 30.10.2014
Bump...
Re: Vehicle keys. -
mkmk - 30.10.2014
Bump...
Re: Vehicle keys. -
Quickie - 31.10.2014
same way....check the vehicle id's
because all vehicles have unique id's

they acquire it after they have created
pawn Код:
vehformedic=CreateVehicle(520, X, Y, Z, 82.2873, 0, 1, 60);// storing the vehicle id to the globalvar variable
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehformedic==vehicleid&&IsPlayerMedic(playerid)&&!ispassenger)
{
// let them enter
}
else
{
ClearAnimations(plyerid);
// dont let them
}
Re: Vehicle keys. -
Abagail - 31.10.2014
Store vehicle data in variables, and then check those when performing the ownership check(s).
Re: Vehicle keys. -
mkmk - 31.10.2014
Cheers, repped both of you. Also, how would I make it so when you talk down the radio and say "Permission to enter the garage, over." You'd be telepored inside the garage? I tried using SetPlayerPos etc but I honestly couldn't figure it out.
One last thing lol, how would I make a /setrank command for FACTION LEADERS.
pawn Код:
Player[playerid][IsLeader] == 1)
Re: Vehicle keys. -
mkmk - 31.10.2014
Any ideas?