SA-MP Forums Archive
Another Respawn all unused cars command help - 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: Another Respawn all unused cars command help (/showthread.php?tid=327413)



Another Respawn all unused cars command help - nickdodd25 - 21.03.2012

Well has the title states i need help with a command that respawns all non owned unused vehicles to there spawn point, i have the command working but it respawned vehicles that had people in them and trailers too, so i added this
pawn Код:
if((IsVehicleEmpty(vid) && IsTrailerAttachedToVehicle(vid);
then i started getting this code...
Код:
: error 017: undefined symbol "IsVehicleEmpty"
here is my command...
pawn Код:
COMMAND:rac(playerid, params[])
{

    SendAdminText(playerid, "/rac", params);

    if (APlayerData[playerid][LoggedIn] == true)
    {
        if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            for (new vid; vid < 2000; vid++)
            {
                if (AVehicleData[vid][Owned] == false)
                {
                    if((IsVehicleEmpty(vid) && IsTrailerAttachedToVehicle(vid)))//<--Here is the line thats causing the problems
                    {

                       
                        SetVehicleToRespawn(vid);
                        AVehicleData[vid][Owned] = false;
                        AVehicleData[vid][Owner] = 0;
                        AVehicleData[vid][Model] = 0;
                        AVehicleData[vid][PaintJob] = 0;
                        for (new i; i < 14; i++)
                            AVehicleData[vid][Components][i] = 0;
                        AVehicleData[vid][SpawnX] = 0.0;
                        AVehicleData[vid][SpawnY] = 0.0;
                        AVehicleData[vid][SpawnZ] = 0.0;
                        AVehicleData[vid][SpawnRot] = 0.0;
                        AVehicleData[vid][BelongsToHouse] = 0;
                    }
                }
            }

        }
        else
            return 0;
    }
    else
        return 0;

    return 1;
}
And i of course searched around and tryed different methods to define "IsVehicleEmpty" but failed and made more errors, most likely overseeing something simple.
Any suggestions
Thanks
Nick


Re: Another Respawn all unused cars command help - Tanush123 - 21.03.2012

Did you find this code on samp forum? Search for IsVehicleEmpty, it will start with Stock IsVehicleEmpty i think


Re: Another Respawn all unused cars command help - nickdodd25 - 21.03.2012

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
Did you find this code on samp forum? Search for IsVehicleEmpty, it will start with Stock IsVehicleEmpty i think
Hmm thats weird i was looking earlyer and i found different stocks but they didnt work, now i found the right one, thanks!!
But now i have another problem, first it started off when i did /rac in a any vehicle it worked fine but when i got in a truck and hooked to a trailer it respawned both, so i changed......
pawn Код:
if((IsVehicleEmpty(vid)||IsTrailerAttachedToVehicle(vid))
to
pawn Код:
if((IsVehicleEmpty(vid)||!IsTrailerAttachedToVehicle(vid)))
and now it respawns the trailer, how would i make it so all trailers stay attached when they are in use but when not in use the respawn.


Re: Another Respawn all unused cars command help - MP2 - 21.03.2012

You'd have to loop through every vehicle and see if the trailer is attached to it. If you did it inefficiently, you're looking at a 2000x2000 loop = 400,000 iterations.


Re: Another Respawn all unused cars command help - nickdodd25 - 21.03.2012

Quote:
Originally Posted by MP2
Посмотреть сообщение
You'd have to loop through every vehicle and see if the trailer is attached to it. If you did it inefficiently, you're looking at a 2000x2000 loop = 400,000 iterations.
Wow, well do you have any sugestions on how to make it correctly? Atm i only have about 250 vehicles in my gamemode so far if that helps. but i did find out a way where everything respawns exept trailers,

pawn Код:
if((IsVehicleEmpty(vid) && !IsTrailerAttachedToVehicle(vid) && GetVehicleModel(vid) !=435 && GetVehicleModel(vid) !=450 && GetVehicleModel(vid) !=584 && GetVehicleModel(vid) !=591) || (IsVehicleEmpty(vid) && IsTrailerAttachedToVehicle(vid) !=GetVehicleTrailer(vid)))
Prolly going to use this for a while till i get the loop figured out and made properly and just do my /respawn (id) command for abandoned trailers.

Thanks
Nick


Re: Another Respawn all unused cars command help - Joshb93 - 21.03.2012

Try doing

pawn Код:
if(!IsVehicleEmpty(vid) && IsTrailerAttachedToVehicle(vid))



Re: Another Respawn all unused cars command help - Tween73 - 01.03.2015

dcmd_rac(playerid,params[])?

samp respawn unused cars?

Don't work