SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/01/2018, 03:26 PM   #1
JulianWilliams
Big Clucker
 
Join Date: Dec 2017
Location: Nevada
Posts: 76
Reputation: 0
Default CMD /respawncars with radius but I want respawn all cars

PHP Code:
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.
JulianWilliams is offline   Reply With Quote
Old 12/01/2018, 03:36 PM   #2
jasperschellekens
Gangsta
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Gehenna
Posts: 803
Reputation: 79
Default Re: CMD /respawncars with radius but I want respawn all cars

This will respawn all unused vehicles:
PHP Code:
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;

__________________
Coming soon (5-21-2020):

Undead Wasteland Roleplay - Heavily mapped desert zombie apocalypse roleplay
Official Live Beta Release Date: 21th of May, 2020
Discord
jasperschellekens is online now   Reply With Quote
Old 12/01/2018, 03:39 PM   #3
Lucases
Huge Clucker
 
Join Date: Jul 2017
Posts: 216
Reputation: 11
Default Re: CMD /respawncars with radius but I want respawn all cars

PHP Code:
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 View Post
This will respawn all unused vehicles:
PHP Code:
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.
Lucases is offline   Reply With Quote
Old 12/01/2018, 03:49 PM   #4
jasperschellekens
Gangsta
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Gehenna
Posts: 803
Reputation: 79
Default Re: CMD /respawncars with radius but I want respawn all cars

Quote:
Originally Posted by Lucases View Post
[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.
__________________
Coming soon (5-21-2020):

Undead Wasteland Roleplay - Heavily mapped desert zombie apocalypse roleplay
Official Live Beta Release Date: 21th of May, 2020
Discord
jasperschellekens is online now   Reply With Quote
Old 12/01/2018, 04:03 PM   #5
JulianWilliams
Big Clucker
 
Join Date: Dec 2017
Location: Nevada
Posts: 76
Reputation: 0
Default Re: CMD /respawncars with radius but I want respawn all cars

Thanks, two guys, +rep
JulianWilliams is offline   Reply With Quote
Old 12/01/2018, 04:54 PM   #6
JulianWilliams
Big Clucker
 
Join Date: Dec 2017
Location: Nevada
Posts: 76
Reputation: 0
Default Re: CMD /respawncars with radius but I want respawn all cars

Fixed
PHP Code:
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
JulianWilliams is offline   Reply With Quote
Old 12/01/2018, 10:12 PM   #7
Jefff
Banned
 
Join Date: Dec 2007
Posts: 2,594
Reputation: 326
Default Re: CMD /respawncars with radius but I want respawn all cars

Just modify the function RespawnNearbyVehicles, if radius is 0 then will be respawnall
Jefff is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[REP++] Respawn cars cmd maksicnm Scripting Help 0 28/12/2017 04:09 PM
cars never respawn Lirbo Scripting Help 5 05/05/2014 08:24 PM
[HELP] Respawn cars V4at Scripting Help 6 01/03/2014 11:01 PM
Respawn Vehicles don't respawn spawned cars JaKe Elite Scripting Help 6 20/05/2013 07:17 AM
Tuned cars --after respawn--> normal cars Edna Krabapel Help Archive 8 31/01/2010 06:52 PM


All times are GMT. The time now is 12:30 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.