Car system help
#1

I already know how to make a dialog to purchase vehicles, but i want that so only the people who bought them can sit in them and if the car is blown up or dissapeared they can respawn it again, if i could get some help for that
Reply
#2

PutPlayerInVehicle
Reply
#3

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
PutPlayerInVehicle
Shittiest advice ever.

My advice would be to do something like (Assuming you have a player enum)
pawn Код:
my_PLAYER_enum[ playerid ][ p_car_var ] = CreateVehicle( .. ) // when you buy it
Then,
pawn Код:
public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
{
     if(vehicleid != my_PLAYER_enum[ playerid ][ p_car_var ] )
     {
               RemovePlayerFromVehicle( playerid );
     }
     return 1;
}
For respawning:-
pawn Код:
enum pi
{
     p_car_var,
     p_model
}

public OnVehicleDeath( vehicleid, reason )
{
       for( new i; i < MAX_VEHICLES; i++)
       {
             if(vehicleid == my_PLAYER_enum[ i ][ p_car_var ]
             {
                 GetPlayerPos( i , x, y, z );
                 CreateVehicle( p_model, x, y, z .. );
              }
        }
       return 1;
}
Make sure to set the p_model variable as the GetVehicleModel when you create the vehicle where YOU BUY THE CAR.
Reply
#4

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Shittiest advice ever.

My advice would be to do something like (Assuming you have a player enum)
pawn Код:
my_PLAYER_enum[ playerid ][ p_car_var ] = CreateVehicle( .. ) // when you buy it
Then,
pawn Код:
public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
{
     if(vehicleid != my_PLAYER_enum[ playerid ][ p_car_var ] )
     {
               RemovePlayerFromVehicle( playerid );
     }
     return 1;
}
For respawning:-
pawn Код:
enum pi
{
     p_car_var,
     p_model
}

public OnVehicleDeath( vehicleid, reason )
{
       for( new i; i < MAX_VEHICLES; i++)
       {
             if(vehicleid == my_PLAYER_enum[ i ][ p_car_var ]
             {
                 GetPlayerPos( i , x, y, z );
                 CreateVehicle( p_model, x, y, z .. );
              }
        }
       return 1;
}
Make sure to set the p_model variable as the GetVehicleModel when you create the vehicle where YOU BUY THE CAR.
The player info is being stored by the filterscript i am using, can this be done in any other way?
Reply
#5

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Shittiest advice ever.
Why do you say that? He wants to spawn the car and automatically getting inside. What's more reasonable than using the putplayerinvehicle function?

EDIT: and concerning your suggestion, using removeplayerfromvehicle should be used when player is already in vehicle but right after it you should add the purplayerinvehicle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)