06.01.2014, 15:42
(
Последний раз редактировалось DaniceMcHarley; 01.06.2017 в 02:43.
)
------
new bool:VehiclesByVCommand[2000]; // In your /v command use: VehiclesByVCommand[vehicleid] = true;
new bool:HasUniqueVehicle[MAX_PLAYERS];
CMD:v(playerid, params[])
{
if(HasUniqueVehicle[playerid] == false)
{
// codes here
HasUniqueVehicle[playerid] = true;
}
else
{
SendClientMessage(playerid, -1, "You already have a unique vehicle!");
}
}
CMD:doesplayerhavev(playerid, params[])
{
new target;
if(sscanf(params, "d", target)) return SendClientMessage(playerid, -1, "Usage: /doesplayerhavev <targetid>");
{
if(HasUniqueVehicle[target] == true)
{
SendClientMessage(playerid, -1, "He has a unique vehicle");
}
else
{
SendClientMessage(playerid, -1, "He does not have a unique vehicle");
}
}
}
After that, you could have a command that destroys all vehicles created by /v. Just loop through all vehicles (from 1 to 1999) and check if the VehicleByVCommand is set to "true". If it's "true", destroy the vehicle and set this variable back to "false" (to prevent trying to destroy the vehicle again if the command is used again afterwards). If it's false, do nothing. |
CMD:delv(playerid, params[])
{
for(new v = 0; v < MAX_VEHICLES; ++v)
{
if(VehiclesByVCommand[v] == true)
{
DestroyVehicle(v);
}
}
return 1;
}
Код:
new bool:VehiclesByVCommand[2000]; // In your /v command use: VehiclesByVCommand[vehicleid] = true; Just loop through all vehicles (from 1 to 1999) and check if the VehicleByVCommand is set to "true". If it's "true", destroy the vehicle and set this variable back to "false" (to prevent trying to destroy the vehicle again if the command is used again afterwards). If it's false, do nothing. |
Код:
new bool:VehiclesByVCommand[2000]; // In your /v command use: VehiclesByVCommand[vehicleid] = true; Just loop through all vehicles (from 1 to 1999) and check if the VehicleByVCommand is set to "true". If it's "true", destroy the vehicle and set this variable back to "false" (to prevent trying to destroy the vehicle again if the command is used again afterwards). If it's false, do nothing. |
// In your /v command use:
VehiclesByVCommand[vehicleid - 1] = true;
MAX_VEHICLES is defined as 2000 so why not to use all of them (slots/indexes) but only 1999? I don't see any point of leaving the index 0 unused.
pawn Код:
|
// This command deletes all vehicles that are spawned using /v
COMMAND:cleanupcars(playerid, params[])
{
// If the player didn't login properly, fail the command
if (APlayerData[playerid][LoggedIn] == false) return 0;
// If the player has an insufficient admin-level (he needs level 3), exit the command
if (APlayerData[playerid][AdminLevel] < 3) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only admins level 3 can use this command");
// If the player is on the class-selection menu, block the command
if ((GetPlayerState(playerid) == PLAYER_STATE_WASTED) || (GetPlayerState(playerid) == PLAYER_STATE_NONE)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use this command while using class-selection");
// Setup local variables
new CarsDeleted, Msg[128];
// Loop through all vehicles
for (new vid; vid < MAX_VEHICLES; vid++)
{
// Check if this vehicle was spawned by the /v command
if (AVehicleData[vid][SpawnedByVCommand] == true)
{
// Count the cars that have been deleted
CarsDeleted++;
// Destroy the vehicle and clear the data
DestroyVehicle(vid);
AVehicleData[vid][SpawnedByVCommand] = false;
}
}
// Let the player know how many vehicles have been cleaned up
format(Msg, 128, "{00FF00}Total number of vehicles cleaned up: {FFFF00}%i", CarsDeleted);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
// Let the server know that this was a valid command
return 1;
}
new vehicleid;
if (AVehicleData[vehicleid][SpawnedByVCommand] == true)
{
}
new vehicleid;
if (AVehicleData[vehicleid - 1][SpawnedByVCommand] == true)
{
}
new bool:VehiclesByVCommand[MAX_VEHICLES - 1];
// In your /v command use:
VehiclesByVCommand[vehicleid - 1] = true;
for (new vid; vid < MAX_VEHICLES; vid++)