Assigning two zombies - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Assigning two zombies (
/showthread.php?tid=592249)
Assigning two zombies -
JaKe Elite - 22.10.2015
I am creating the 6th game for my minigames server.
It is a type of zombie mod, So it needs to be related to zombies right? That is why it's called zombie mod? lmao

(Aight am talkin to mahself again)
I was wondering if it is possible to assign two random players to be zombie.
I have created a variable already to determine how many survivors there are.
Do i have to loop it, or .. ??
Re: Assigning two zombies -
Crystallize - 22.10.2015
PHP код:
new Mode[MAX_PLAYERS]; //top of your script
forward RandomZombie();
SetTimer("RandomZombie",1000,false); //when map starts
public RandomZombie() return Half();
stock Half()
{
new Humans;
foreach(Player, i)
{
if(Humans < 3)
{
if(Mode[i] == 1)
{
HumanSetup(i);
printf("Selected humans");
Humans ++;
}
}
else
{
if(Mode[i] == 1)
{
ZombieSetup2(i);
Humans = 0;
}
}
}
printf("Finished Selecting teams");
return 1;
}
stock ZombieSetup(playerid)
{
if(Mode[playerid] == 1)
{
SetPlayerTeam(playerid,TEAM_ZOMBIE);
team[playerid] = TEAM_ZOMBIE;
SetPlayerColor(playerid,COLOR_ZOMBIE);
}
return 1;
}
stock ZombieSetup2(playerid)
{
if(Mode[playerid] == 1)
{
SetPlayerTeam(playerid,TEAM_ZOMBIE);
SetPlayerHealth(playerid,100.0);
team[playerid] = TEAM_ZOMBIE;
SetPlayerColor(playerid,COLOR_ZOMBIE);
SpawnPlayer(playerid);
}
return 1;
}
compile this and change the variables to yours
Re: Assigning two zombies -
JaKe Elite - 23.10.2015
I am not so sure the above code would work so i tried out making my own version using the Iter_Random from foreach, doe i am not sure if i coded it properly, or if it works.
PHP код:
forward AssignZombie();
public AssignZombie()
{
if(survivors <= 2)
{
EndGame();
SendClientMessageToAll(COLOR_RED, "Not enough players, Server might cause some issues on assigning the zombies.");
SendClientMessageToAll(-1, "Next game is loaded instead...");
print("AssignZombie(): Due to lack of players, We will skip this game.");
print("Reason Sended out: Server might cause some issues on assigning the zombies.");
print("The game has been skipped and the next game will be played instead.");
}
else
{
survivor_time = false;
new id = Iter_Random(Player);
new id2 = Iter_Random(Player);
if(id == id2) id = Iter_Random(Player);
if(id2 == id) id2 = Iter_Random(Player);
// Then codes to set id and id2 to zombie.
}
return 1;
}
Did i do it right?