How to make player owned vehicles? - 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: How to make player owned vehicles? (
/showthread.php?tid=401018)
How to make player owned vehicles? -
Michael_Cuellar - 21.12.2012
How to i make it so I can give a player his/hers own vehicle and it will stay that way?
Re: How to make player owned vehicles? -
LarzI - 21.12.2012
Example snippet:
pawn Код:
//global
new
gPlayerVehicle[ MAX_PLAYERS ];
pawn Код:
//onplayerconnect
gPlayerVehicle[ MAX_PLAYERS ] = -1;
pawn Код:
//command to get
CMD:getv(playerid, params[])
{
new
vID,
Float: pPos[ 3 ];
GetPlayerPos( playerid, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
if( gPlayerVehicle[ playerid ] != -1 )
{
SetVehiclePos( gPlayerVehicle[ playerid ], pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
return SendClientMessage( playerid, 0x00FF00FF, "[INFO] Your personal vehicle has been teleported to your location" );
}
else if( sscanf( params, "i", vID ))
return SendClientMessage( playerid, 0xFFFF00FF, "[USAGE] /getv <model>" );
// this player doesn't have a car, and the parameter is fullfilled:
gPlayerVehicle[ playerid ] = CreateVehicle( vID, ( pPos[ 0 ] + 5.0 ), ( pPos[ 1 ] + 5.0 ), ( pPos[ 2 ] + 1.0 ), 0.0, -1, -1, 999999 );
SendClientMessage( playerid, 0x00FF00FF, "[SUCCESS] You have created your own personal vehicle!" );
return SendClientMessage( playerid, 0xFFFF00FF, "Type /getv to teleport it back to you, or /delv to delete it" );
}
pawn Код:
//command to remove
CMD:delv(playerid, params[])
{
if( gPlayerVehicle[ playerid ] != -1 )
{
DestroyVehicle( gPlayerVehicle[ playerid ] );
SendClientMessage( playerid, 0x00FF00FF, "[SUCCESS] You have deleted your vehicle - do /getv for a new one" );
return gPlayerVehicle[ playerid ] = -1;
}
return SendClientMessage( playerid, 0xFF0000FF, "[ERROR] You don't have a personal vehicle" );
}
This should do the trick
Re: How to make player owned vehicles? -
deffo - 21.12.2012
@larzi:
that does not save the stuff or does it?
Re: How to make player owned vehicles? -
LarzI - 21.12.2012
Quote:
Originally Posted by deffo
@larzi:
that does not save the stuff or does it?
|
Currently it only saves to playerid.