/putincar [playerid/part of name]
playerid/part of name - ID or name of the player you want to put yourself into
This command uses ZCMD and SSCANF,
[iurl=#seat]IsSeatTaken(vehicleid, seatid);[/iurl]
by Mikep and
[iurl=#pname]PlayerName(playerid);[/iurl]
by Dracoblue:
pawn Код:
CMD:putincar(playerid, params[])
{
if( !IsPlayerAdmin( playerid ))
return SendClientMessage( playerid, 0xFF0000FF, "[ERROR]Admins only!" );
new
iPlayer,
iSeat,
szSuccess;
if( sscanf( params, "ui", iPlayer, iSeat ))
return SendClientMessage( playerid, 0xFFFF00FF, "[ERROR]USAGE: \"/putincar [playerid/part of name]\" - Put you inside this player's vehicle" );
if( !IsPlayerConnected( iPlayer ))
return SendClientMessage( playerid, 0xFF0000FF, "[ERROR]Invalid ID!" );
if( !IsPlayerInAnyVehicle( iPlayer ))
return SendClientMessage( playerid, 0xFF0000FF, "[ERROR]This player isn't inside any vehicle!" );
if( iSeat < 0 || iSeat > 4 )
return SendClientMessage( playerid, 0xFF0000FF, "[ERROR]Seats are 0-4!" );
if( IsSeatTaken( GetPlayerVehicleID( iPlayer ), iSeat ))
return SendClientMessage( playerid, 0xFF0000FF, "[ERROR]This seat is already taken!" );
PutPlayerInVehicle( playerid, GetPlayerVehicleID( iPlayer ), iSeat );
format( szSuccess, sizeof( szSuccess ), "[SUCCESS]You have put yourself in (%d)%s's vehicle, in seat %d", iPlayer, PlayerName( iPlayer ), iSeat );
SendClientMessage( playerid, 0x00FF00FF, szSuccess );
return true;
}
[anchor=seat]IsSeatTake(vehicleid, seatid);
pawn Код:
stock IsSeatTaken(vehicleid, seatid)
{
for(new i=0; i<MAX_PLAY; i++)
{
if(GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == seatid) return 1;
}
return 0;
}
[anchor=pname]PlayerName(playerid);
pawn Код:
stock PlayerName(playerid)
{
new name[24];
GetPlayerName(playerid, name, 24);
return name;
}
NOTE: This isn't bug free, there are vehicles who only have 1-2 seats and maybe more than 4 (ambulance?).
Enjoy, lol :P