PDA

View Full Version : CMD /respawncars with radius but I want respawn all cars


JulianWilliams
12/01/2018, 03:26 PM
CMD:respawncars(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 3)
{
new string[128], radius;
if(sscanf(params, "d", radius)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /respawncars [radius]");

if(radius < 1 || radius > 40)
{
SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 41!");
return 1;
}
RespawnNearbyVehicles(playerid, radius);
format(string, sizeof(string), "You have respawned all vehicles within a radius of %d.", radius);
SendClientMessageEx(playerid, COLOR_GREY, string);
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
}
return 1;
}

This is respawncars with a radius of 1-40.
I want a cmd respawnallcars.

jasperschellekens
12/01/2018, 03:36 PM
This will respawn all unused vehicles:

CMD:rac(playerid, params[])
{
if(AdminLevel[playerid] >=2)
{
if(PlayerInfo[playerid][aDuty] == 0) return SendClientMessage(playerid,GREY,"You are not on admin duty.");
new bool:vehicleused[MAX_VEHICLES];
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
vehicleused[GetPlayerVehicleID(i)] = true;
}
}
for(new i=1; i < MAX_VEHICLES; i++)
{
if(!vehicleused[i])
{
SetVehicleToRespawn(i);
}
}
new msg[128];
format(msg, sizeof(msg), "Admin %s (%d) has respawned all unused vehicles", PlayerName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, msg);
}else return SendClientMessage(playerid,GREY,"You are not an admin");
return 1;
}

Lucases
12/01/2018, 03:39 PM
CMD:respawnallcars(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] < 3) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
{
for(new i = 1, j = GetVehiclePoolSize(); i <= j; i++) // vehicleids start at 1
{
SetVehicleToRespawn(i);
}
SendClientMessageEx(playerid, COLOR_GREY, "You have respawned all vehicles");
}
return 1;
}








Don't use this one:

This will respawn all unused vehicles:

CMD:rac(playerid, params[])
{
if(AdminLevel[playerid] >=2)
{
if(PlayerInfo[playerid][aDuty] == 0) return SendClientMessage(playerid,GREY,"You are not on admin duty.");
new bool:vehicleused[MAX_VEHICLES];
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
vehicleused[GetPlayerVehicleID(i)] = true;
}
}
for(new i=1; i < MAX_VEHICLES; i++)
{
if(!vehicleused[i])
{
SetVehicleToRespawn(i);
}
}
new msg[128];
format(msg, sizeof(msg), "Admin %s (%d) has respawned all unused vehicles", PlayerName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, msg);
}else return SendClientMessage(playerid,GREY,"You are not an admin");
return 1;
}



It will give you compiler errors because the user just copied and pasted his vehicle system command.

jasperschellekens
12/01/2018, 03:49 PM
[PHP]CMD:respawnallcars(playerid, params[])

Don't use this one:
It will give you compiler errors because the user just copied and pasted his vehicle system command.
He is supposed to learn from this, he will by editing mine. Its up to him which one he uses.

JulianWilliams
12/01/2018, 04:03 PM
Thanks, two guys, +rep

JulianWilliams
12/01/2018, 04:54 PM
Fixed
CMD:respawnallcars(playerid, params[])
{
new string[128];
new vehicleid = GetPlayerVehicleID(playerid);
if (PlayerInfo[playerid][pAdmin] < 3) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
{
for(new i = 1, j = GetVehicleModel(vehicleid); i <= j; i++) // vehicleids start at 1
{
SetVehicleToRespawn(i);
format(string, sizeof(string), "You have respawned vehicle ID %d.", i);
SendClientMessageEx(playerid, COLOR_GREY, string);
}
}
return 1;
}

Thanks

Jefff
12/01/2018, 10:12 PM
Just modify the function RespawnNearbyVehicles, if radius is 0 then will be respawnall