I need a little help.
Saving the players stats and updating them works fine using the functions from _stattracking.gsc (the non mysql version). Now i am trying to add a hud for displaying them. So because my coding experience is limited i tried modifying _hud_playerscore.gsc to test. I made a file called _myhud.gsc that contains :
Code:
init()
{
level thread onPlayerConnect();
}
onPlayerConnect()
{
for(;;)
{
level waittill("connecting", player);
player thread onPlayerSpawned();
player thread onJoinedTeam();
player thread onJoinedSpectators();
player thread onUpdatePlayerScoreHUD();
}
}
onJoinedTeam()
{
self endon("disconnect");
for(;;)
{
self waittill("joined_team");
self thread removePlayerHUD();
}
}
onJoinedSpectators()
{
self endon("disconnect");
for(;;)
{
self waittill("joined_spectators");
self thread removePlayerHUD();
}
}
onPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned_player");
if(!isdefined(self.hud_deaths))
{
self.hud_deaths = newClientHudElem(self);
self.hud_deaths.horzAlign = "left";
self.hud_deaths.vertAlign = "top";
self.hud_deaths.x = 36;
self.hud_deaths.y = 46;
self.hud_deaths.font = "default";
self.hud_deaths.fontscale = 2;
self.hud_deaths.archived = false;
}
self thread updatePlayerScoreHUD();
}
}
onUpdatePlayerScoreHUD()
{
for(;;)
{
self waittill("update_playerscore_hud");
self thread updatePlayerScoreHUD();
}
}
updatePlayerScoreHUD()
{
if(isDefined(self.hud_deaths))
deaths = self getstat("deaths");
self.hud_deaths setValue(deaths);
}
removePlayerHUD()
{
if(isDefined(self.hud_deaths))
self.hud_deaths destroy();
}
I tried calling _myhud.gsc within _stattracking.gsc in the init function.
Code:
init()
{
game["menu_clientcmd"] = "clientcmd";
precacheMenu(game["menu_clientcmd"]);
init_stattracking();
init_ranks();
thread waitforconnect();
thread scanForBan();
thread maps\mp\gametypes\_myhud::init();
}
When i try to run server i get this error:
Code:
******* script compile error *******
uninitialised variable 'deaths': (file 'maps/mp/gametypes/_myhud.gsc', line 86)
self.hud_deaths setValue(deaths);
*
************************************
********************
ERROR: script compile error
(see console for details)
********************
----- Server Shutdown -----
Sending heartbeat to cod2master.activision.com
==== ShutdownGame ====
Any help would be highly appreciated