10.05.2013, 10:13
Here's my codes
So if the number of online players isn't 2 then the players will have infinite health and will see a message, when another player joins, only the first player gets weapon, only the first player re-spawns, in another words only the first player gets the timer
I do not want to send the timers individually. I want to send a server timer and when the timer hits 0 the function will be called and every player will run that function
EDIT:
If I use loop will it work? I loop the function code through every player
Код:
public ServerPlayersCount(playerid) { ServerMaxPlayers = CountConnectedPlayers(); if(ServerMaxPlayers < 2) { if(GetPVarInt(playerid, "WaitingMSG") != 1) { SendClientMessage(playerid, COLOR_YELLOW, "Waiting for players to join"); SetPVarInt(playerid, "WaitingMSG", 1); } GameTextForPlayer(playerid, "Waiting for players", 2000, 3); SetPlayerHealth(playerid, 99999); ServerPlayersCountTimer = SetTimer("ServerPlayersCount", 1500, false); } else if (ServerMaxPlayers >= 2) { KillTimer(ServerPlayersCountTimer); GameTextForPlayer(playerid, "Initiating New Round", 950, 3); if (RoundStarted != 1) { InitiateNewRoundTimer = SetTimer("InitiateNewRound", 2000, false); } else { SetTimer("PlayerSpawner", 2000, false); } } else if (ServerMaxPlayers == 0) { KillTimer(ServerPlayersCountTimer); } }
Код:
public InitiateNewRound(playerid) { KillTimer(InitiateNewRoundTimer); TogglePlayerControllable(playerid,0); SetCameraBehindPlayer(playerid); SendClientMessageToAll(COLOR_BLUE, "New Round Started!"); ResetPlayerWeapons(playerid); SetPlayerTeam(playerid,0); ShowTeamPlayerNameTags(playerid, 0); SetPlayerColor(playerid,COLOR_BLUE); SetPlayerSkin(playerid,285); SetPlayerArmour(playerid, 0); SetPlayerChatBubble(playerid, "Spawn Protected!", COLOR_RED, 100.0, 4000); GivePlayerWeapon(playerid,24,56); GivePlayerWeapon(playerid,25,50); GivePlayerWeapon(playerid,31,150); GivePlayerWeapon(playerid,28,300); GivePlayerWeapon(playerid,17,5); GameTextForPlayer(playerid, "~r~Kill all the Zombies!", 150, 0); new Random = random(sizeof(RandomSpawns)); SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]); GivePlayerMoney(playerid, 3000); DisablePlayerCheckpoint(playerid); RoundStarted = 1; EnableSpawnMovementTimer = SetTimer("EnableSpawnMovement", 1500, false); EnableAntiSpawnKillTimer = SetTimer("EnableAntiSpawnKill", 500, false); InfectPlayerTimer = SetTimer("InfectPlayer", 25000, false); }
Код:
public PlayerSpawner(playerid) { if(RoundStarted == 1) { TogglePlayerControllable(playerid,0); SetCameraBehindPlayer(playerid); ResetPlayerWeapons(playerid); SetPlayerTeam(playerid,0); ShowTeamPlayerNameTags(playerid, 0); SetPlayerColor(playerid,COLOR_BLUE); SetPlayerSkin(playerid,285); SetPlayerArmour(playerid, 0); SetPlayerChatBubble(playerid, "Spawn Protected!", COLOR_RED, 100.0, 4000); GivePlayerWeapon(playerid,24,56); GivePlayerWeapon(playerid,25,50); GivePlayerWeapon(playerid,31,150); GivePlayerWeapon(playerid,28,300); GivePlayerWeapon(playerid,17,5); GameTextForPlayer(playerid, "~r~Kill all the Zombies!", 150, 0); new Random = random(sizeof(RandomSpawns)); SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]); GivePlayerMoney(playerid, 3000); DisablePlayerCheckpoint(playerid); EnableSpawnMovementTimer = SetTimer("EnableSpawnMovement", 1500, false); EnableAntiSpawnKillTimer = SetTimer("EnableAntiSpawnKill", 500, false); } }
Код:
stock CountConnectedPlayers() { new PlayerCount = 0; for(new L = 0; L <= MAX_PLAYERS; L ++) { if(GetPlayerState(L) == PLAYER_STATE_NONE) continue; if(IsPlayerConnected(L)) PlayerCount++; } return PlayerCount; }
I do not want to send the timers individually. I want to send a server timer and when the timer hits 0 the function will be called and every player will run that function
EDIT:
If I use loop will it work? I loop the function code through every player