Vehicle keys.
#1

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!
Reply
#2

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;
}
Reply
#3

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.
Reply
#4

Bump...
Reply
#5

Bump...
Reply
#6

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
}
Reply
#7

Store vehicle data in variables, and then check those when performing the ownership check(s).
Reply
#8

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)
Reply
#9

Any ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)