Ok.. wtf? I was just playing a lone and it worked fine, some random asshole (not really i'm just upset) joined then it doesn't work... Relevant code follows:
Code:
public DoNewRound()
{
for(new i=1;i<=32;i++)
{ if(is_user_alive(i))
//debug
client_print(0, print_console, "Testing player #%i", i)
RefreshExperience(i)
CheckLevel(i)
UpdateFocus(i)
}
}
public RefreshExperience(id)
{
//kaput (gebroken) lol
new ExpMessage[128]
format(ExpMessage, 127, "Exp: %i / %i", PlayerExp[id], ExperienceForLevel[PlayerLevel[id] + 1])
message_begin(MSG_ONE, get_user_msgid("StatusText"), {0, 0, 0}, id);
write_byte(0);
write_string(ExpMessage);
message_end();
}//works fine
public CheckLevel(id)
{
//debug
client_print(0, print_console, "Checking player %i's level (%i) exp", id, PlayerExp[id])
if (PlayerLevel[id]<100)
{
if (PlayerExp[id] >= ExperienceForLevel[PlayerLevel[id]+1])
{
PlayerLevel[id] += 1
set_hudmessage(255, 255, 255, 2.0, 1.0, 1, 6.0, 15.0, 0.1, 0.2, 4)
show_hudmessage(id, "Congratulations on achieving level #%i", PlayerLevel[id])//broken
PlayerMaxFocus[id] = PlayerLevel[id] +10
PlayerFocus[id] = PlayerMaxFocus[id]
//debug
client_print(id, print_console, "Player #%i reached level #%i", id, PlayerLevel[id])//works
CheckLevel(id)
}
}
if (PlayerLevel[id]>0)
{
if (PlayerExp[id] < ExperienceForLevel[PlayerLevel[id]])
{
PlayerLevel[id] -= 1
set_hudmessage(255, 255, 255, 2.0, 1.0, 1, 6.0, 15.0, 0.1, 0.2, 4)
show_hudmessage(id, "You've lost a level! You are now level #%i", PlayerLevel[id])//broken
//debug
client_print(id, print_console, "Player #%i lost a level. They are now level #%i", id, PlayerLevel[id])//works
PlayerMaxFocus[id] = PlayerLevel[id] +10
PlayerFocus[id] = PlayerMaxFocus[id]
CheckLevel(id)
}
}
}
public UpdateFocus(id)
{
if(is_user_alive(id))
{
PlayerMaxFocus[id] = PlayerLevel[id] + 10//check required for admin set exp command
PlayerFocus[id] = PlayerFocus[id] + 2
//debug
client_print(id, print_console, "Setting maxfocus to Level(%i) + 10 (=%i)", PlayerLevel[id], PlayerMaxFocus[id])
if (PlayerFocus[id] > PlayerMaxFocus[id])
{
PlayerFocus[id] = PlayerMaxFocus[id]
}
//debug
//client_print(i, print_chat, "set focus to: %i", PlayerFocus[id])
new Message[128] = ""
format(Message, 127, "FOCUS: %i/%i", PlayerFocus[id], PlayerMaxFocus[id])
set_hudmessage(255, 255, 255, 0.05, 0.75, 2, 0.02, 3.0, 0.01, 0.1, 2)
show_hudmessage(id, Message)
}
new ident[1]
ident[0] = id
set_task(1.0, "RefreshFocus", 451+id, ident, 1)
}
//for timed function only
public RefreshFocus(ident[],TaskID)
{
new id = ident[0]
UpdateFocus(id)
}
There we go, that's done at the begining of every round, now please tell me why the messages only work when there is only 1 person in the server (game is not officialy started). And why in God's name does the focus update for only me, and never anyone else?