SA-MP Forums Archive
CMD /respawncars with radius but I want respawn all cars - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CMD /respawncars with radius but I want respawn all cars (/showthread.php?tid=647872)



CMD /respawncars with radius but I want respawn all cars - JulianWilliams - 12.01.2018

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.


Re: CMD /respawncars with radius but I want respawn all cars - jasperschellekens - 12.01.2018

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;




Re: CMD /respawncars with radius but I want respawn all cars - Lucases - 12.01.2018

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.


Re: CMD /respawncars with radius but I want respawn all cars - jasperschellekens - 12.01.2018

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.


Re: CMD /respawncars with radius but I want respawn all cars - JulianWilliams - 12.01.2018

Thanks, two guys, +rep


Re: CMD /respawncars with radius but I want respawn all cars - JulianWilliams - 12.01.2018

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


Re: CMD /respawncars with radius but I want respawn all cars - Jefff - 12.01.2018

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