Another Respawn all unused cars command help
#1

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
Reply
#2

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

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.
Reply
#4

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.
Reply
#5

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
Reply
#6

Try doing

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

dcmd_rac(playerid,params[])?

samp respawn unused cars?

Don't work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)