13.11.2015, 00:43
I'm trying to make a command so when you do /vrespawn [car id] it despawns the admin car.
To spawn an admin car you use /spawncar. For some reason it only stocks one car in to the
variable and I can only despawn the first car I spawned with that command. I want to make it
so when you type /vrespawn it respawns what ever admin car you spawned by ID.
/spawncar command
/vrespawn command
To spawn an admin car you use /spawncar. For some reason it only stocks one car in to the
variable and I can only despawn the first car I spawned with that command. I want to make it
so when you type /vrespawn it respawns what ever admin car you spawned by ID.
/spawncar command
Код:
CMD:spawncar(playerid, params[])
{
if(playerVariables[playerid][pAdminLevel] >= 1)
{
if(!isnull(params))
{
new
carid = strval(params),
Float: carSpawnPos[4], // 3 for the usual dimensions, +1 for the rotation/angle.
messageString[64];
new message2[64];
if(carid < 400 || carid > 611)
return SendClientMessage(playerid, COLOR_WHITE, "Valid car IDs start at 400, and end at 611.");
if(systemVariables[vehicleCounts][0] + systemVariables[vehicleCounts][1] + systemVariables[vehicleCounts][2] < MAX_VEHICLES) {
GetPlayerPos(playerid, carSpawnPos[0], carSpawnPos[1], carSpawnPos[2]);
GetPlayerFacingAngle(playerid, carSpawnPos[3]);
AdminSpawnedVehicles[vehCount] = CreateVehicle(carid, carSpawnPos[0], carSpawnPos[1], carSpawnPos[2], carSpawnPos[3], -1, -1, -1);
systemVariables[vehicleCounts][2]++;
SetVehicleNumberPlate(AdminSpawnedVehicles[vehCount], "ADMCAR");
LinkVehicleToInterior(AdminSpawnedVehicles[vehCount], GetPlayerInterior(playerid));
SetVehicleVirtualWorld(AdminSpawnedVehicles[vehCount], GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid, AdminSpawnedVehicles[vehCount], 0);
switch(carid) {
case 427, 428, 432, 601, 528: SetVehicleHealth(AdminSpawnedVehicles[vehCount], 5000.0);
}
format(messageString, sizeof(messageString), "You have spawned a %s (vehicle ID %d).", VehicleNames[carid - 400], AdminSpawnedVehicles[vehCount]);
SendClientMessage(playerid, COLOR_WHITE, messageString);
format(message2, sizeof(message2), "AdmCmd: %s has used /spawncar.",GetName(playerid));
submitToHelpersAndAdmins(message2, COLOR_HOTORANGE);
vehCount++;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "(error) 01x08");
printf("ERROR: Vehicle limit reached (MODEL %d, MAXIMUM %d, TYPE ADMIN) [01x08]", carid, MAX_VEHICLES);
}
}
else {
return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/spawncar [vehicleid]");
}
}
else return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
return 1;
}
Код:
CMD:vrespawn(playerid, params[]) {
new carid2, deez22[64];
if(sscanf(params, "d", carid2)) return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/vrespawn [car id]");
if(playerVariables[playerid][pAdminLevel] >= 1)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
new carid3 = AdminSpawnedVehicles[i];
if(carid2 == carid3)
{
format(szMessage, sizeof(szMessage), "You have successfully despawned vehicle %d.", AdminSpawnedVehicles[i]);
SendClientMessage(playerid, COLOR_WHITE, szMessage);
DestroyVehicle(carid2);
AdminSpawnedVehicles[i]--;
systemVariables[vehicleCounts][2]--;
format(deez22, sizeof(deez22), "AdmCmd: %s has used /spawncar.",GetName(playerid));
submitToHelpersAndAdmins(deez22, COLOR_HOTORANGE);
return 1;
}
else return SendClientMessage(playerid, COLOR_GREY, "The car ID you have entered is invalid.");
}
}
else return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
return 1;
}


