I did like last man standing, when a player dies it respawn as an observer, and when another match begins it automatically teleports to a spawn spot on the map.
And, I put that dollar thing because you can bet from between 1 and 255 dollars using a pre-impulse command. If you're the last man standing, you receive all money the others have bet.
When I start a map and connect 4 bots, the match starts normally, but the second or more matches doesn't start even if everybody gave their bets.
Can someone tell me what's wrong in my code?
PlaceBets(), called from impulse 50 and any other impulse that's the value of your bets.
Code: Select all
void(float howmany) PlaceBets =
{
self.t_length = 0;
self.last_impulse = 0;
self.impulse = 0;
if (howmany > self.cash)
howmany = self.cash; // lost all cash
self.cash = self.cash - howmany;
self.bet = howmany;
bet_placed = bet_placed + 1;
if (bet_placed == total_players)
{
bprint ("Everybody placed their bets. Let's fight!!\n");
everybody_placed = 1;
}
bprint (self.netname);
bprint (" bets ");
bprint (ftos(howmany));
bprint (" dollars.\n");
};
My modifed StartFrame():
Code: Select all
void() StartFrame =
{
local entity p, bot, oself;
local float bets;
local string s;
teamplay = cvar("teamplay");
skill = cvar("skill");
framecount = framecount + 1;
bot = find(world, classname, "player");
while (bot != world)
{
if (!bot.human)
{
oself = self;
self = bot;
BotThink ();
self = oself;
}
bot = find(bot, classname, "player");
}
if (dead_players >= total_players - 1 && total_players > 1)
{
dead_players = 0;
everybody_placed = 0;
p = find(world, classname, "player");
while (p != world)
{
bets = bets + p.bet;
if (p.health > 0)
{
bprint (p.netname);
bprint (" wins! He gained ");
s = ftos(bets);
bprint (s);
bprint (" dollars!\n");
p.bet = p.bet + bets;
}
p.spec = 0;
p.betted = 0;
oself = spawn ();
oself.owner = p;
oself.nextthink = time + 1 + random()*2;
oself.think = ReSpawn;
p = find(p, classname, "player");
}
PrintCash ();
}
if (!everybody_placed)
cease_fire = 1;
else
cease_fire = 0;
if (everybody_placed)
bet_placed = 0;
};
Any help would be appreciated.