How do you pass var throughout the gamemode?
#1

DELETE
Reply
#2

your "game mode copy" is server side only!
Sending it to players will not do anything.(even if u do how will the run/link it with urs ?)

So if you want to use a timer for individual players then use
pawn Код:
SetTimerEx("PlayerSpawner", 1000, false, "i", playerid);
Reply
#3

What the heck are you talking?

Quote:

I just realize that every SAMP player will have their "own copy" of the game mode

Isn't true. The gamemode will be on YOUR server, the players just get the executed functions from the server, which doesn't even can get loged. So there isn't a need to make this what you want.
Reply
#4

Here's my codes

Код:
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;
}
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
Reply
#5

Nevermind, solved it with loop
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)