01.09.2013, 12:40
Don't use strcmp for commands, it's slow. Use ZCMD instead. It can be combined with sscanf and it's really easy and fast to make commands. There are many tutorials about how to use zcmd + sscanf for commands.
pawn Код:
CMD:spawn( playerid, params[ ] )
{
new
modelid
;
if( sscanf( params, "i", modelid ) ) return SendClientMessage( playerid, -1, "Usage: /spawn <modelid>" );
if( modelid < 400 || modelid > 611 ) return SendClientMessage( playerid, -1, "Modelids: 400-611" );
new
Float: p[ 4 ]
;
GetPlayerPos( playerid, p[ 0 ], p[ 1 ], p[ 2 ] );
GetPlayerFacingAngle( playerid, p[ 3 ] );
switch( GetPlayerState( playerid ) )
{
case PLAYER_STATE_DRIVER: DestroyVehicle( GetPlayerVehicleID( playerid ) );
case PLAYER_STATE_PASSENGER: RemovePlayerFromVehicle( playerid );
}
new
vehicleid = CreateVehicle( modelid, p[ 0 ], p[ 1 ] + 2, p[ 2 ] + 2, p[ 3 ], -1, -1, 60 )
;
LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) );
SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) );
PutPlayerInVehicle( playerid, vehicleid, 0 );
return 1;
}