Automatic Car respawn every X time in rp server
#1

also i need a code that the server respawns the car every 3 hours, automatically, please.
Reply
#2

PHP код:
    SetTimer("Rac",180000,false)
    {
            new 
bool:unwanted[CAR_AMOUNT];
            for(new 
player=0player<MAX_PLAYERSplayer++)
             {
                if(
IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
             }
            for(new 
car 1car <= 268car++)
            {
                if(!
unwanted[car]) SetVehicleToRespawn(car);
            }
            
GetPlayerName(playeridsendernamesizeof(sendername));
            
format(stringsizeof(string), "SERVER: All unused cars Automaticly respawned by The Server.", );
            
BroadCast(COLOR_WHITE,string);
        }
        return 
1
try this im probaly thing that will not work i just started to scripting and i just wrote it from my minde xD hope it will help you or give you an idea! Good Luck!.
Reply
#3

where to put that under o.o
Reply
#4

@Armada
You pasted a invalid code.

pawn Код:
#define RESPAWN_TIME 20 // Twenty minutes

public OnGameModeInit() {
     SetTimer("VehicleRespawn", RESPAWN_TIME * 60000, 1);
     return 1;
}

forward VehicleRespawn();
public VehicleRespawn() {
    for(new i = 0; i < MAX_VEHICLES; i ++ ) {
         SetVehicleToRespawn(i);
    }
    return 1;
}
Reply
#5

that will respawn all cars>?[i think] he wants unused cars
Reply
#6

pawn Код:
#define RESPAWN_TIME 20 // Twenty minutes

public OnGameModeInit() {
     SetTimer("VehicleRespawn", RESPAWN_TIME * 60000, 1);
     return 1;
}

forward VehicleRespawn();
public VehicleRespawn() {
    for(new i = 0; i < MAX_VEHICLES; i ++ ) {
         for(new o = 0; o < GetMaxPlayers(); o ++ ) {
              if(!IsPlayerConnected(o)) continue;
              if(IsAnyBodyInVehicle(i)) continue;
              SetVehicleToRespawn(i);
         }
    }
    return 1;
}

stock IsAnyBodyInVehicle(vid) {
  for(new i = 0; i < GetMaxPlayers(); i ++ ) {
       if(IsPlayerInVehicle(i, vid)) return 1;
  }
  return 0;
}
Reply
#7

Thank you so much dude, and if i want to ad more minutes, what i have to do?
Reply
#8

change the #define from 20 to what ever minutes valse you want
Reply
#9

And how can i put, 2 minutes Before a mesage like this:

In 2 minutes the vehicles will be respawned
Reply
#10

Quote:
Originally Posted by Carlton
Посмотреть сообщение
@Armada
pawn Код:
#define RESPAWN_TIME 20 // Twenty minutes
#define RESPAWN_MESSAGE_TIME 2 //Minutes before the respawn

public OnGameModeInit() {
     SetTimer("VehicleRespawn", RESPAWN_TIME * 60000, 1);
     SetTimer("VehicleRespawnMessage", (RESPAWN_TIME-RESPAWN_MESSAGE_TIME) * 60000, 0)
     return 1;
}

forward VehicleRespawn();
public VehicleRespawn() {
    for(new i = 0; i < MAX_VEHICLES; i ++ ) {
         for(new o = 0; o < GetMaxPlayers(); o ++ ) {
              if(!IsPlayerConnected(o)) continue;
              if(IsAnyBodyInVehicle(i)) continue;
              SetVehicleToRespawn(i);
         }
    }
    SetTimer("VehicleRespawnMessage", (RESPAWN_TIME-RESPAWN_MESSAGE_TIME) * 60000, 0)
    return 1;
}

stock IsAnyBodyInVehicle(vid) {
  for(new i = 0; i < GetMaxPlayers(); i ++ ) {
       if(IsPlayerInVehicle(i, vid)) return 1;
  }
  return 0;
}


forward VehicleRespawnMessage();
public VehicleRespawnMessage() {
    //Message
    return 1;
}
I edited the code from Carlton for your needs
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)