Destroyveh command
#1

pawn Код:
CMD:veh(playerid, params[])
{
     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Error. Usage: /veh [modelid]"); //Check if the parameter exists.
     if(strval(params) > 611 || strval(params) < 400) return SendClientMessage(playerid, COLOR_RED, "Error. Models are between 400 and 611."); //Check if it's between 400 and 611.
     if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Трябва да влезите в профила си, за да използвате командите.");
     if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "Вие нямате права, за да използвате тази команда.");
     new Float:x, Float:y, Float:z; //Declare position variables.
     GetPlayerPos(playerid, x, y, z); //Get the players position, the vehicle will spawn in this position.
     PutPlayerInVehicle(playerid, CreateVehicle(strval(params), x, y, z, 0.0, -1, -1, -1), 0); //Create the vehicle, put the player in it as the driver.
     return 1; //Tell the server the command executed succesfully.
}
That's my command for veh. How must to be command for destroyveh ?
Reply
#2

use an other command and put

PHP код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
    
DestroyVehicle(GetPlayerVehicleID(playerid);

Reply
#3

other suggestions ??
Reply
#4

pawn Код:
CMD:destroyveh(playerid, params[])
{
    new
        vehicleid;
   
    if (sscanf(params, "i", vehicleid)) return SendClientMessage(playerid, -1, "Usage: /destroyveh <vehicleid>");
    if (!GetVehicleModel(vehicleid)) return SendClientMessage(playerid, -1, "Invalid vehicleid");
    DestroyVehicle(vehicleid);
    return 1;
}
Reply
#5

doesnt works... arond 100 errors
Reply
#6

pawn Код:
CMD:veh(playerid, params[])
{
     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Error. Usage: /veh [modelid]"); //Check if the parameter exists.
     if(strval(params) > 611 || strval(params) < 400) return SendClientMessage(playerid, COLOR_RED, "Error. Models are between 400 and 611."); //Check if it's between 400 and 611.
     if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Трябва да влезите в профила си, за да използвате командите.");
     if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "Вие нямате права, за да използвате тази команда.");
     new Float:x, Float:y, Float:z; //Declare position variables.
     GetPlayerPos(playerid, x, y, z); //Get the players position, the vehicle will spawn in this position.
     PutPlayerInVehicle(playerid, CreateVehicle(strval(params), x, y, z, 0.0, -1, -1, -1), 0); //Create the vehicle, put the player in it as the driver.
     return 1; //Tell the server the command executed succesfully.
}
That's my command. How can i when i exit from vehicle. Vehicle to be destroyed automatic
Reply
#7

Quote:
Originally Posted by Yordan_Kronos
Посмотреть сообщение
doesnt works... arond 100 errors
The command works fine and it will not give any warnings if you placed it correctly (out of callbacks) and you have sscanf included.

If you want to destroy the vehicle when a players exits:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) DestroyVehicle(vehicleid);
    return 1;
}
If the vehicle is destroyed too fast, then use a timer.
Reply
#8

PHP код:
CMD:dveh(playeridparams[])
{
     if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playeridCOLOR_GREY"Вие нямате права, за да използвате тази команда.");
     if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
     {
        
DestroyVehicle(GetPlayerVehicleID(playerid);
     }
     return 
1//Tell the server the command executed succesfully.

Reply
#9

Okay listen me now.. Command /veh is only for admin. I want when admin exit from vehicle which he is spawned.. vehicle to be destroyed. Only for spawned cars with /veh.. not for all cars.

pawn Код:
CMD:veh(playerid, params[])
{
     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Error. Usage: /veh [modelid]"); //Check if the parameter exists.
     if(strval(params) > 611 || strval(params) < 400) return SendClientMessage(playerid, COLOR_RED, "Error. Models are between 400 and 611."); //Check if it's between 400 and 611.
     if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Трябва да влезите в профила си, за да използвате командите.");
     if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "Вие нямате права, за да използвате тази команда.");
     new Float:x, Float:y, Float:z; //Declare position variables.
     GetPlayerPos(playerid, x, y, z); //Get the players position, the vehicle will spawn in this position.
     PutPlayerInVehicle(playerid, CreateVehicle(strval(params), x, y, z, 0.0, -1, -1, -1), 0); //Create the vehicle, put the player in it as the driver.
     return 1; //Tell the server the command executed succesfully.
}
Reply
#10

You need an array with size of MAX_VEHICLES and if the vehicle was spawned by the command, set it to true. When a player exits, check if the state is driver, the player is admin and the vehicle was spawned by an admin and destroy it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)