ID of last vehicle entered
#1

How can i get the vehicle id of the last vehicle the player was in?

Example: I get into an elegy ID: 20, then i exit, and do /lock, then it locks car ID:20
Reply
#2

For yourself or for a player like,

/lastvehicle [ID] [CarID]?
Reply
#3

Well its not a command to see the last id, its used so the player, once he leaves the car, he can use /lock and it locks that car. "that car" is the ID of the last car he was in
Reply
#4

Oh? So like a string sent to the player of his vehicle ID?

I'm honestly not understanding your question/request.
Reply
#5

Okay, so, a player enters vehicle ID: 20, (not the actual model id but the unique id it is given when spawned). So now he has "ownership" of vehicle ID: 20. When he exits the car, and does: /lock, it locks ONLY vehicle ID: 20. And another player tries to enter it, and it says "blah blah car is locked"
Reply
#6

Quote:
Originally Posted by SnG.Scot_MisCuDI
Посмотреть сообщение
How can i get the vehicle id of the last vehicle the player was in?

Example: I get into an elegy ID: 20, then i exit, and do /lock, then it locks car ID:20
Make a global variable:

new LastVehicle[MAX_PLAYERS];

OnPlayerStateChange, when he actually enters a vehicle, do:

LastVehicle[playerid] = GetVehicleID(playerid);

Then it will just set that variable to every vehicle he enters, and it won't change until he enters a new vehicle. So to view the last vehicle a player entered, use LastVehicle[playerid]
Reply
#7

Okay, so how would i check to see if another player (not ownership of that ID) enters it while its locked and he gets ejected?
Reply
#8

My guess would be you have the array PlayerInfo assigned to MAX_PLAYERS with enumerator of pKeys.
So it would go.
pawn Код:
OnPlayerExitVehicle //bla bla
Lastcar[playerid] = vehicleid //bla blah
CMD:lock(playerid, params[])
{
     if(lastcar[playerid] != PlayerInfo[playerid][pKeys]) return SendClientMessage(playerid, COLOR_WHITE, "You do not own that vehicle.");
     else
     {
             //lock
      }
      return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)