/vrespawn help
#1

Well i made /vrespawn so if admin uses it. Vehicles that is not used will be respawn and if players are driving vehicle, nothing will happen! when i use the cmd while im driving vehicle, the vehicle respawns
pawn Код:
CMD:vrespawn(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] > 1)
    {
            for(new v = 1; v <= MAX_VEHICLES; v++)
            {
            SetVehicleToRespawn(v);
            }
            SendClientMessage(playerid,0xFF9900AA,"SERVER: An Administrator has respawned all vehicle!");
    }
    else return SendClientMessage(playerid,0xFF0000FF,"ERROR: Your admin level isn't high enough!");
    return 1;
}
Reply
#2

i think you have 2 make a loop to all player to and check if player is state driver or not
Reply
#3

ok i did
pawn Код:
CMD:vrespawn(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] > 1)
    {
            for(new v = 1; v <= MAX_VEHICLES; v++)
            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
            SetVehicleToRespawn(v);
            }
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
            }
            SendClientMessage(playerid,0xFF9900AA,"SERVER: An Administrator has respawned all vehicle!");
    }
    else return SendClientMessage(playerid,0xFF0000FF,"ERROR: Your admin level isn't high enough!");
    return 1;
}
but when im in a vehicle and do /vrespawn, vehicles that are not used doesnt respawn
Reply
#4

Ofcourse not, you didn't make a loop, you made it check for the player who types /vrespawn only.

Try this:
pawn Код:
CMD:vrespawn(playerid, params[])
{
    new Unusedcar[MAX_VEHICLES];
    if(PlayerData[playerid][AdminLevel] > 1)  
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(IsPlayerInAnyVehicle(i))
                {
                    Unused[GetPlayerVehicleID(i)]=1; // 1 = false, which means it's used
                }
            }
        }
        for(new carid = 0; carid < MAX_VEHICLES; carid++)
        {
            if(unused[carid]==0) // 0 = true which means it's unused.
            {
                SetVehicleToRespawn(carid);
            }
        }
    }
return 1;
}
Reply
#5

pawn Код:
CMD:resetv(playerid, params[])
{
        SendClientMessage(playerid, 0xFFFF00AA, "|- Your have Successfully Respawned all Vehicles!");
        GameTextForAll("~n~~n~~n~~n~~n~~n~~r~Vehicles ~g~Respawned!", 3000,3);
        for(new cars=0; cars<MAX_VEHICLES; cars++)
           {
               if(!VehicleOccupied(cars))
               {
                   SetVehicleToRespawn(cars);
               }
           }
        SendClientMessage(playerid, 0xFFFF00AA, "All vehicles has been respawned, Please do not abuse this command unless all agrees to respawn.");
    }
    return 1;
}
And this somewhere in ya script:-

pawn Код:
public VehicleOccupied(vehicleid)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerInVehicle(i,vehicleid)) return 1;
}
return 0;
}
Reply
#6

1 error and 1 warrning


Код:
C:\Documents and Settings\galina\щемзп дтбегд\ъйчйдщм чйшйм\server\filterscripts\car.pwn(57) : error 010: invalid function or declaration
C:\Documents and Settings\galina\щемзп дтбегд\ъйчйдщм чйшйм\server\filterscripts\car.pwn(59) : warning 235: public function lacks forward declaration (symbol "VehicleOccupied")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#7

its already fixed by Biesam, dave. Thmx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)