Car system help - 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: Car system help (
/showthread.php?tid=437102)
Car system help -
BossZk - 14.05.2013
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
AW: Car system help -
HurtLocker - 14.05.2013
PutPlayerInVehicle
Re: AW: Car system help -
RajatPawar - 14.05.2013
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.
Re: AW: Car system help -
BossZk - 14.05.2013
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?
AW: Re: AW: Car system help -
HurtLocker - 14.05.2013
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.