25.09.2013, 15:59
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.
Thanks ahead.
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;
}
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;
}
pawn Код:
PS: Made from scratch, untested. EDIT: Use Konstantinos', it's a bit more complex. |
pawn Код:
|