Respawn all unused vehicles?
#1

How to set this cmd to respawn only unused vehicles,curently it respawns vehicles that are being driven (its anyoning). REP +1 who helps
CMD:
PHP код:
COMMAND:opetvozila(playerid,params[])
{
    
SendAdminText(playerid"/opetvozila"params);
    if (
APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 9)
    {
        for(new 
iMAX_VEHICLESi++)
        {
            
SetVehicleToRespawn(i);
        }
        
SendClientMessageToAll(0xFFFFFF"Vozila su opet ucitana. Mozete ih naci na mjestu gdje su parkirani.");
        return 
1;
    }
    return 
0;

Reply
#2

Hey! You should use a 'Nested Loop'. Let me know if this works.

pawn Код:
COMMAND:opetvozila(playerid,params[])
{
    SendAdminText(playerid, "/opetvozila", params);
    if (APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 9)
    {
        for(new i; i < MAX_VEHICLES; i++)
        {
            for(new x; x < MAX_PLAYERS; x++)
            {
                if(!IsPlayerInVehicle(x, i))
        {
            SetVehicleToRespawn(i);
        }
        }
        }
        SendClientMessageToAll(0xFFFFFF, "Vozila su opet ucitana. Mozete ih naci na mjestu gdje su parkirani.");
        return 1;
    }
    return 0;
}
Reply
#3

Tested,it respawns vehicles that are being used again...
Reply
#4

One second, will take a look.
Reply
#5

pawn Код:
COMMAND:opetvozila(playerid,params[])
{
    SendAdminText(playerid, "/opetvozila", params);
    if (APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 9)
    {
        for(new i; i < MAX_VEHICLES; i++)
        {
            for(new x; x < MAX_PLAYERS; x++)
            {
                if(GetPlayerVehicleID(x) != i)
        {
            SetVehicleToRespawn(i);
        }
        }
        }
        SendClientMessageToAll(0xFFFFFF, "Vozila su opet ucitana. Mozete ih naci na mjestu gdje su parkirani.");
        return 1;
    }
    return 0;
}
Reply
#6

Same again
Reply
#7

I noticed that, this is a little strange.
Reply
#8

PHP код:
COMMAND:opetvozila(playerid,params[])
{
    
SendAdminText(playerid,"/opetvozila",params);
    if(
APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 9)
    {
        new 
bool:UnsedVehicle[MAX_VEHICLES];
        for(new 
i;i<MAX_PLAYERS;i++)
        {
            if(
IsPlayerInAnyVehicle(i))UnusedVehicle[GetPlayerVehicleID(i)] = true;
        }
        for(new 
i;i<MAX_VEHICLES;i++)
        {
            if(
UnusedVehicle[i] == false)
            {
                
SetVehicleToRespawn(i);
            }
        }
    }
    return 
1;

Take this. It will work.
Reply
#9

Try this

pawn Код:
CMD:opetvozila(playerid,params[])
{
    if (APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 9)
    {
        for (new j = 1; j <= MAX_VEHICLES; j++)
        {
            if (GetVehicleModel(j) == 0) continue;
            new moneys1 = 0;
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
                if (!IsPlayerInVehicle(i, j)) continue;
                moneys1 ++;
                break;
            }
            if (moneys1 == 0)
            {
                SetVehicleToRespawn(j);
            }
        }
        SendClientMessageToAll(0xFFFFFF, "Vozila su opet ucitana. Mozete ih naci na mjestu gdje su parkirani.");
    }
    else return 0;
    return 1;
}
Reply
#10

Thanks to all of you guys who helped,at the end IceBilizard's cmd worked all REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)