Car Spawn 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 Spawn help.. (
/showthread.php?tid=466021)
Car Spawn help.. -
CesarLT - 25.09.2013
Hello everyone, I am trying to make a car spawner, how can I make the car to spawn into the players position. (So he instantly drives it).
Thanks ahead.
Re: Car Spawn help.. -
DanishHaq - 25.09.2013
pawn Код:
CMD:veh(playerid, params[])
{
new vehid, color1, color2, Float:x, Float:y, Float:z, Float:c; // var's
if(sscanf(params, "ddd", vehid, color1, color2)) return SendClientMessage(playerid, color, "Correct usage: /veh [vehid] [color1] [color2]"); // syntax message
GetPlayerPos(playerid, x, y, z); // get the player pos
GetPlayerFacingAngle(playerid, c); // facing angle
new car = CreateVehicle(vehid, x, y, z, c, color1, color2, -1) // create the car with the var of car
PutPlayerInVehicle(playerid, car, 0); // put the player in the new "car" var, the 0 is the seat ID, 0 is the driver
return 1;
}
Try and use some of that command to merge it with your own, i.e. to get the player inside the vehicle.
PS: Made from scratch, untested.
EDIT: Use Konstantinos', it's a bit more complex.
Re: Car Spawn help.. -
Konstantinos - 25.09.2013
pawn Код:
CMD:v( playerid, params[ ] )
{
new
modelid
;
if( sscanf( params, "i", modelid ) ) return SendClientMessage( playerid, -1, "Usage: /v <modelid>" );
if( modelid < 400 || modelid > 611 ) return SendClientMessage( playerid, -1, "Invalid modelid (400-611)" );
new
Float: x,
Float: y,
Float: z,
Float: rotation,
vehicleid
;
switch( GetPlayerState( playerid ) )
{
case PLAYER_STATE_DRIVER:
{
vehicleid = GetPlayerVehicleID( playerid )
GetVehiclePos( vehicleid, x, y, z );
GetVehicleZAngle( vehicleid, rotation );
DestroyVehicle( vehicleid );
}
case PLAYER_STATE_ONFOOT:
{
GetPlayerPos( playerid, x, y, z );
GetPlayerFacingAngle( playerid, rotation );
}
default: return SendClientMessage( playerid, -1, "You cannot spawn a vehicle" );
}
vehicleid = CreateVehicle( modelid, x, y, z, rotation, -1, -1, 60 );
LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) );
SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) );
PutPlayerInVehicle( playerid, vehicleid, 0 );
return 1;
}
Re: Car Spawn help.. -
CesarLT - 25.09.2013
Quote:
Originally Posted by DanishHaq
pawn Код:
CMD:veh(playerid, params[]) { new vehid, color1, color2, Float:x, Float:y, Float:z, Float:c; // var's if(sscanf(params, "ddd", vehid, color1, color2)) return SendClientMessage(playerid, color, "Correct usage: /veh [vehid] [color1] [color2]"); // syntax message GetPlayerPos(playerid, x, y, z); // get the player pos GetPlayerFacingAngle(playerid, c); // facing angle new car = CreateVehicle(vehid, x, y, z, c, color1, color2, -1) // create the car with the var of car PutPlayerInVehicle(playerid, car, 0); // put the player in the new "car" var, the 0 is the seat ID, 0 is the driver return 1; }
Try and use some of that command to merge it with your own, i.e. to get the player inside the vehicle.
PS: Made from scratch, untested.
EDIT: Use Konstantinos', it's a bit more complex.
|
Quote:
Originally Posted by Konstantinos
pawn Код:
CMD:v( playerid, params[ ] ) { new modelid ; if( sscanf( params, "i", modelid ) ) return SendClientMessage( playerid, -1, "Usage: /v <modelid>" ); if( modelid < 400 || modelid > 611 ) return SendClientMessage( playerid, -1, "Invalid modelid (400-611)" );
new Float: x, Float: y, Float: z, Float: rotation, vehicleid ;
switch( GetPlayerState( playerid ) ) { case PLAYER_STATE_DRIVER: { vehicleid = GetPlayerVehicleID( playerid ) GetVehiclePos( vehicleid, x, y, z ); GetVehicleZAngle( vehicleid, rotation ); DestroyVehicle( vehicleid ); } case PLAYER_STATE_ONFOOT: { GetPlayerPos( playerid, x, y, z ); GetPlayerFacingAngle( playerid, rotation ); } default: return SendClientMessage( playerid, -1, "You cannot spawn a vehicle" ); }
vehicleid = CreateVehicle( modelid, x, y, z, rotation, -1, -1, 60 ); LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) ); SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) ); PutPlayerInVehicle( playerid, vehicleid, 0 ); return 1; }
|
Thank you both, really helpfull!