CMD /respawncars with radius but I want respawn all cars
#1

PHP код:
CMD:respawncars(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] >= 3)
    {
        new 
string[128], radius;
        if(
sscanf(params"d"radius)) return SendClientMessageEx(playeridCOLOR_GREY"USAGE: /respawncars [radius]");
        if(
radius || radius 40)
        {
            
SendClientMessageEx(playeridCOLOR_WHITE"Radius must be higher than 0 and lower than 41!");
            return 
1;
        }
        
RespawnNearbyVehicles(playeridradius);
        
format(stringsizeof(string), "You have respawned all vehicles within a radius of %d."radius);
        
SendClientMessageEx(playeridCOLOR_GREYstring);
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_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.
Reply
#2

This will respawn all unused vehicles:
PHP код:
CMD:rac(playeridparams[])
{
    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=0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            
vehicleused[GetPlayerVehicleID(i)] = true;
        }
    }
    for(new 
i=1MAX_VEHICLESi++)
    {
        if(!
vehicleused[i])
        {
            
SetVehicleToRespawn(i);
        }
    }
    new 
msg[128];
    
format(msgsizeof(msg), "Admin %s (%d) has respawned all unused vehicles"PlayerName(playerid), playerid);
    
SendClientMessageToAll(COLOR_YELLOWmsg);
    }else return 
SendClientMessage(playerid,GREY,"You are not an admin");
    return 
1;

Reply
#3

PHP код:
CMD:respawnallcars(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] < 3) return SendClientMessageEx(playeridCOLOR_GRAD1"You are not authorized to use that command.");
    {
                for(new 
1GetVehiclePoolSize(); <= ji++) // vehicleids start at 1
                
{
                              
SetVehicleToRespawn(i);
                }
        
SendClientMessageEx(playeridCOLOR_GREY"You have respawned all vehicles");
    }
    return 
1;







Don't use this one:

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
This will respawn all unused vehicles:
PHP код:
CMD:rac(playeridparams[])
{
    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=0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            
vehicleused[GetPlayerVehicleID(i)] = true;
        }
    }
    for(new 
i=1MAX_VEHICLESi++)
    {
        if(!
vehicleused[i])
        {
            
SetVehicleToRespawn(i);
        }
    }
    new 
msg[128];
    
format(msgsizeof(msg), "Admin %s (%d) has respawned all unused vehicles"PlayerName(playerid), playerid);
    
SendClientMessageToAll(COLOR_YELLOWmsg);
    }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.
Reply
#4

Quote:
Originally Posted by Lucases
Посмотреть сообщение
[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.
Reply
#5

Thanks, two guys, +rep
Reply
#6

Fixed
PHP код:
CMD:respawnallcars(playeridparams[])
{
    new 
string[128];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if (
PlayerInfo[playerid][pAdmin] < 3) return SendClientMessageEx(playeridCOLOR_GRAD1"You are not authorized to use that command.");
    {
                for(new 
1GetVehicleModel(vehicleid); <= ji++) // vehicleids start at 1
                
{
                              
SetVehicleToRespawn(i);
                              
format(stringsizeof(string), "You have respawned vehicle ID %d."i);
                              
SendClientMessageEx(playeridCOLOR_GREYstring);
                }
    }
    return 
1;

Thanks
Reply
#7

Just modify the function RespawnNearbyVehicles, if radius is 0 then will be respawnall
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)