08.10.2014, 01:24
(
Последний раз редактировалось Threshold; 08.10.2014 в 02:21.
)
Okay, so I've modified the script a little bit.
At the top of your script, put this:
Under OnGameModeInit, add this:
Under OnPlayerDisconnect:
Then you have the two commands:
You've seem to got AdminCars2 and AdminCars confused, and you're not using them in the proper fashion. This fixes that. If this is quite confusing to you, here is the script as a whole:
EDIT: I decided that AdminCars2 is unnecessary and doesn't really hold any value in this code, so I removed it.
At the top of your script, put this:
pawn Код:
#define MAX_ADMIN_CARS 10
new AdminCars[MAX_PLAYERS], carcount;
pawn Код:
carcount = 0;
pawn Код:
if(AdminCars[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(AdminCars[playerid]);
AdminCars[playerid] = INVALID_VEHICLE_ID;
carcount--;
}
pawn Код:
CMD:veh(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorised to use that command.");
if(!GetPVarInt(playerid, "AdminDuty") && pInfo[playerid][pAdminLevel] < 8) return SendClientMessage(playerid, COLOR_GREY, "You need to be on admin duty to use the commands.");
new carid, col1, col2;
if(sscanf(params, "iI(0)I(0)", carid, col1, col2)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /veh [ID] [COL1] [COL2]");
if(carcount >= MAX_ADMIN_CARS) return SendClientMessage(playerid, COLOR_GREY, "You must use /vehdestroy because you have reached the maximum Admin cars");
if(!(400 <= carid <= 611)) return SendClientMessage(playerid, COLOR_GREY, "Vehicle number can't be below 400 or above 611!");
if(!((0 <= col1 <= 256) && (0 <= col2 <= 256))) return SendClientMessage(playerid, COLOR_GREY, "Color number can't be below 0 or above 256!");
if(AdminCars[playerid] != INVALID_VEHICLE_ID && pInfo[playerid][pAdminLevel] < 8) return SendClientMessage(playerid, COLOR_GREY, "You already have a spawned vehicle.");
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
AdminCars[playerid] = CreateVehicle(carid, X + 2, Y + 2, Z + 1, 0.0, col1, col2, 60000);
gVehicleFuel[AdminCars[playerid]] = 100;
carcount++;
new string[50];
format(string, sizeof(string), "Vehicle %d spawned. Total of %d cars spawned.", AdminCars[playerid], carcount);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
CMD:vehdestroy(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] < 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorised to use that command.");
if(!GetPVarInt(playerid, "AdminDuty") && pInfo[playerid][pAdminLevel] < 8) return SendClientMessage(playerid, COLOR_GREY, "You need to be on admin duty to use that command.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(AdminCars[i] == INVALID_VEHICLE_ID) continue;
DestroyVehicle(AdminCars[i]);
AdminCars[i] = INVALID_VEHICLE_ID;
carcount--;
}
SendClientMessage(playerid, COLOR_GREY, "All admin cars have been removed.");
return 1;
}
pawn Код:
#define MAX_ADMIN_CARS 10
new AdminCars[MAX_PLAYERS], carcount;
public OnGameModeInit()
{
carcount = 0;
//Rest of the code
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(AdminCars[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(AdminCars[playerid]);
AdminCars[playerid] = INVALID_VEHICLE_ID;
carcount--;
}
//Rest of the code
return 1;
}
CMD:veh(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorised to use that command.");
if(!GetPVarInt(playerid, "AdminDuty") && pInfo[playerid][pAdminLevel] < 8) return SendClientMessage(playerid, COLOR_GREY, "You need to be on admin duty to use the commands.");
new carid, col1, col2;
if(sscanf(params, "iI(0)I(0)", carid, col1, col2)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /veh [ID] [COL1] [COL2]");
if(carcount >= MAX_ADMIN_CARS) return SendClientMessage(playerid, COLOR_GREY, "You must use /vehdestroy because you have reached the maximum Admin cars");
if(!(400 <= carid <= 611)) return SendClientMessage(playerid, COLOR_GREY, "Vehicle number can't be below 400 or above 611!");
if(!((0 <= col1 <= 256) && (0 <= col2 <= 256))) return SendClientMessage(playerid, COLOR_GREY, "Color number can't be below 0 or above 256!");
if(AdminCars[playerid] != INVALID_VEHICLE_ID && pInfo[playerid][pAdminLevel] < 8) return SendClientMessage(playerid, COLOR_GREY, "You already have a spawned vehicle.");
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
AdminCars[playerid] = CreateVehicle(carid, X + 2, Y + 2, Z + 1, 0.0, col1, col2, 60000);
gVehicleFuel[AdminCars[playerid]] = 100;
carcount++;
new string[50];
format(string, sizeof(string), "Vehicle %d spawned. Total of %d cars spawned.", AdminCars[playerid], carcount);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
CMD:vehdestroy(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] < 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorised to use that command.");
if(!GetPVarInt(playerid, "AdminDuty") && pInfo[playerid][pAdminLevel] < 8) return SendClientMessage(playerid, COLOR_GREY, "You need to be on admin duty to use that command.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(AdminCars[i] == INVALID_VEHICLE_ID) continue;
DestroyVehicle(AdminCars[i]);
AdminCars[i] = INVALID_VEHICLE_ID;
carcount--
}
SendClientMessage(playerid, COLOR_GREY, "All admin cars have been removed.");
return 1;
}