Destroyveh command -
Yordan_Kronos - 06.05.2014
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 ?
Re : Destroyveh command -
yusei - 06.05.2014
use an other command and put
PHP код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
DestroyVehicle(GetPlayerVehicleID(playerid);
}
Re: Destroyveh command -
Yordan_Kronos - 06.05.2014
other suggestions ??
Re: Destroyveh command -
Konstantinos - 06.05.2014
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;
}
Re: Destroyveh command -
Yordan_Kronos - 06.05.2014
doesnt works... arond 100 errors
Re: Destroyveh command -
Yordan_Kronos - 06.05.2014
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
Re: Destroyveh command -
Konstantinos - 06.05.2014
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.
Re : Destroyveh command -
yusei - 06.05.2014
PHP код:
CMD:dveh(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "Вие нямате права, за да използвате тази команда.");
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
DestroyVehicle(GetPlayerVehicleID(playerid);
}
return 1; //Tell the server the command executed succesfully.
}
Re: Destroyveh command -
Yordan_Kronos - 06.05.2014
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.
}
Re: Destroyveh command -
Konstantinos - 06.05.2014
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.