Get last vehicle used
#1

Using command /v2 load last vehicle player used.

Let's say player 1 spawn vehicle infernus, then he leave/exit the vehicle. If player 1 use command /v2 it load the last vehicle infernus or it depends of what player 1 use last vehicle.
Reply
#2

WTF,sorry,i double posted accidentaly(MY INTERNET IS NOT GOOD today),sorry admin,I was not intending to bump,sorry for double post,I pressed POST only once,and I double posted :O.
Reply
#3

pawn Код:
new LastVehicle[MAX_PLAYERS];
OnPlayerConnect(playerid)
{
   LastVehicle[playerid]=-1;
   return 1;
}
OnPlayerExitVehicle(playerid,vehicleid)
{
   LastVehicle[playerid]=GetVehicleModel(vehicleid);
   return 1;
}
COMMAND:v2(playerid,params[])
{
   if(LastVehicle[playerid]!=-1)
   {
        new LastCar;
        new model=LastVehicle[playerid];
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        LastCar=CreateVehicle(model,x,y,z,0,random(100),random(100),0);
        SendClientMessage(playerid,COLOR_GREEN,"You spawned the last vehicle you were in!");
        PutPlayerInVehicle(playerid,LastCar,0);
    }
 return 1;
}
That should do the trick...
Reply
#4

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
pawn Код:
new LastVehicle[MAX_PLAYERS];
OnPlayerConnect(playerid)
{
   LastVehicle[playerid]=-1;
   return 1;
}
OnPlayerExitVehicle(playerid,vehicleid)
{
   LastVehicle[playerid]=GetVehicleModel(vehicleid);
   return 1;
}
COMMAND:v2(playerid,params[])
{
   if(LastVehicle[playerid]!=-1)
   {
        new LastCar;
        new model=LastVehicle[playerid];
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        LastCar=CreateVehicle(model,x,y,z,0,random(100),random(100),0);
        SendClientMessage(playerid,COLOR_GREEN,"You spawned the last vehicle you were in!");
        PutPlayerInVehicle(playerid,LastCar,0);
    }
 return 1;
}
That should do the trick...
I haven't tested it yet. But I knew this should to the trick. Anyway I put you in our server credits for always helping me
Reply
#5

I tested it and it working partially. When you enter car and exit and type /v2 it's working.
What about when your car is destroyed and you were in and you used /v2. It won't work because there is no OnPlayerExitVehicle. Or when you change your car without exiting (using spawn car command and PutPlayerInVehicle). Think of it a little.
Reply
#6

pawn Код:
new LastVehicle[MAX_PLAYERS];
OnPlayerConnect(playerid)
{
   LastVehicle[playerid]=-1;
   return 1;
}
OnPlayerEnterVehicle(playerid,vehicleid)
{
   LastVehicle[playerid]=GetVehicleModel(vehicleid);
   return 1;
}
COMMAND:v2(playerid,params[])
{
   if(LastVehicle[playerid]!=-1)
   {
        new LastCar;
        new model=LastVehicle[playerid];
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        LastCar=CreateVehicle(model,x,y,z,0,random(100),random(100),0);
        SendClientMessage(playerid,COLOR_GREEN,"You spawned the last vehicle you were in!");
        PutPlayerInVehicle(playerid,LastCar,0);
    }
 return 1;
}
Reply
#7

@Deal-or-die = A little problem. yes the script work nice. but it has possibility to spam vehicles. I mean when I do /v2 then it spawn my last car. after I do /v2 again the other last vehicle didn't destroy. How do I destroy the last vehicle?

@Redjohn - Okay thanks redjohn, any idea how to destroy the last vehicle? after using /v2 again?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)