SA-MP Forums Archive
My /respawncars respawn used vehicles too... - 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: My /respawncars respawn used vehicles too... (/showthread.php?tid=671151)



My /respawncars respawn used vehicles too... - albert12 - 12.12.2019

Hello, i'm new with scripting and I can't actually code but i've succeeded on fixing bugs instead, you know it's all about switching values 1 to 0 and shit.. things like that
Anyways, this is my respawncar cmd from Horizon script, how can I make it not respawn used cars?

PHP Code:
CMD:respawncars(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 3)
    {
         if(
AdminDuty[playerid] != && PlayerInfo[playerid][pAdmin] < 4)
        {
            
SendClientMessage(playerid,COLOR_WHITE"You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
            return 
1;
        }
        new 
string[128], radius;
        if(
sscanf(params"d"radius)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /respawncars [radius]");
        if(
radius || radius 99999999)
        {
            
SendClientMessage(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);
        
SendClientMessage(playeridCOLOR_GREYstring);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GRAD1"You are not authorized to use this command.");
    }
    return 
1;




Re: My /respawncars respawn used vehicles too... - EAGLE - 12.12.2019

you need to check if a vehicle is used by player


Re: My /respawncars respawn used vehicles too... - Joe Staff - 12.12.2019

You'll need to show us 'RespawnNearbyVehicles'


Re: My /respawncars respawn used vehicles too... - Mattski - 12.12.2019

PHP Code:
    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);
        }
    }