Respawning unused cars problem
#1

So here is a prob, I got cmd like that

pawn Код:
CMD:respawnveh(playerid, unused[])
{
    if(PlayerInfo[playerid][Admin] < 4)
        return SendClientMessage(playerid, COLOR_RED, "You are not a Public Safety Member! Or your PSM level is too low!");
        SendClientMessageToAll(COLOR_RED, "All unused vehicles have been respawned by Public Safety Member!");
        RespawnAllEmptyCars();
    #pragma unused unused
    for(new i; (++ i) != MAX_VEHICLES; ) {
        SetVehicleToRespawn(i);
    }
    return true;
}
and here is

pawn Код:
//=============Respawn Vehs====================//
stock IsVehicleInUse(vid)
{
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
    if(IsPlayerInVehicle(i, vid)) return 1;
    }
    return 0;
}

stock RespawnAllEmptyCars()
{
    for(new i=0; i < 700; i++)
    {
    if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
    }
}
//=============Respawn Vehs====================//
So this is suppose to respawn ONLY unused cars as I used "RespawnAllEmptyCars" but it respawns everycar even if player is inside them.

Any solution?
Reply
#2

pawn Код:
stock RespawnAllEmptyCars()
{
    for(new i=0; i < 700; i++)
    {
    if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by dr.pepper
Посмотреть сообщение
pawn Код:
stock RespawnAllEmptyCars()
{
    for(new i=0; i < 700; i++)
    {
    if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
    }
    return 1;
}
Nope still respawns used cars
Reply
#4

Anyone got any ideas?
Reply
#5

pawn Код:
stock RespawnAllEmptyCars()
{
    for(new i=0; i < 700; i++)
    {
    if(IsVehicleInUse(i) == 0) SetVehicleToRespawn(i);
    }
}
Try that.
Reply
#6

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
pawn Код:
stock RespawnAllEmptyCars()
{
    for(new i=0; i < 700; i++)
    {
    if(IsVehicleInUse(i) == 0) SetVehicleToRespawn(i);
    }
}
Try that.
Nope it still respawns every car but I want only unused ones to be...
Reply
#7

pawn Код:
//=============Respawn Vehs====================//
stock IsVehicleInUse(vid)
{
    for(new i=0;i<GetMaxPlayers();i++)
    {
    if(IsPlayerInVehicle(i,vid)) return 1;
    }
    return 0;
}

stock RespawnAllEmptyCars()
{
    for(new i=1;i<MAX_VEHICLES;i++)
    {
    if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
    }
}
//=============Respawn Vehs====================//
Not tested.

Use "Usefull Function to make it easier.
Reply
#8

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
pawn Код:
//=============Respawn Vehs====================//
stock IsVehicleInUse(vid)
{
    for(new i=0;i<GetMaxPlayers();i++)
    {
    if(IsPlayerInVehicle(i,vid)) return 1;
    }
    return 0;
}

stock RespawnAllEmptyCars()
{
    for(new i=1;i<MAX_VEHICLES;i++)
    {
    if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
    }
}
//=============Respawn Vehs====================//
Not tested.

Use "Usefull Function to make it easier.
Still nothing but faster respawn than others...
Reply
#9

pawn Код:
CMD:vrespawn(playerid, params[])
{
    #pragma unused params
    if(!IsPlayerAdmin(playerid)) return 0;
    new bool:VehicleUsed[MAX_VEHICLES] = false;
    foreach(Character, i)//for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i)) VehicleUsed[GetPlayerVehicleID(i)] = true;
    }
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(VehicleUsed[i] == false) SetVehicleToRespawn(i);
    }
    return SendClientMessageToAll(COLOR_YELLOW,"All Unccupied Vehicles Have Been Respawned");
}
Reply
#10

Quote:
Originally Posted by Donya
Посмотреть сообщение
pawn Код:
CMD:vrespawn(playerid, params[])
{
    #pragma unused params
    if(!IsPlayerAdmin(playerid)) return 0;
    new bool:VehicleUsed[MAX_VEHICLES] = false;
    foreach(Character, i)//for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i)) VehicleUsed[GetPlayerVehicleID(i)] = true;
    }
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(VehicleUsed[i] == false) SetVehicleToRespawn(i);
    }
    return SendClientMessageToAll(COLOR_YELLOW,"All Unccupied Vehicles Have Been Respawned");
}
And we got a winner! that one works!
Tho if possible could you explain to me what was wrong and what was needed to change? :O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)