I have still no clue whats wrong now. Please just update the error message instead of referencing to older ones (with the correspondending source code).
I have still no clue whats wrong now. Please just update the error message instead of referencing to older ones (with the correspondending source code).
timescale 0.01
Then you need to post all your other huds as well so we can see where you've gone wrong. If the other ones are like the one I just worked on, then it is because you aren't doing any checks on the values, and the game simply wont stand for it.
The important thing is for you to post your code. If you don't post it, how are we supposed to help you? We are modders. Not mind readers. If you don't want to post your code, then don't expect any help. It really is as simple as that.
Okay here's just everything, all scripts, all errors, whatever you need
_file.gsc:
tdm.gsc:Code:init() { thread onPlayerConnect(); } onPlayerConnect() { level waittill("connecting",player); player thread load(); } load() { guid = self getGuid(); if(guid != 0) { file = openFile(guid + ".txt", "read"); if(file != -1) { freadln(file); self.kills = int(fgetarg(file,0)); closeFile(file); } else { self.kills = 0; self write(); } } else if(guid == 0) return; } write() { guid = self getGuid(); if(guid != 0) { file = openFile(guid + ".txt", "write"); closeFile(file); file = openFile(guid + ".txt", "append"); fPrintln(file,self.kills); closeFile(file); } else if(guid == 0) return; }
callback_startgametype
callback_playerkilledCode:thread maps\mp\gametypes\_file::init();
updatehudCode:attacker.kills++; attacker maps\mp\gametypes\_file::write(); attacker updatehud();
spawnplayerCode:updateHud() { self.killhud setValue(self.kills); }
hudCode:self thread kills();
Error:Code:kills() { self endon("joined_spectators"); self endon("disconnect"); if(!isDefined(self.killhud)) { self.killhud = newClientHudElem(self); self.killhud.vertAlign = "fullscreen"; self.killhud.horzAlign = "fullscreen"; self.killhud.alignX = "left"; self.killhud.alignY = "middle"; self.killhud.x = 25; self.killhud.y = 474; self.killhud.sort = 1; self.killhud.alpha = 1; self.killhud.fontScale = 0.8; self.killhud.archived = true; self.killhud.label = (game["ratio"]); self.killhud setValue(self.kills); } }
Well i still cant figure out whats the problem, and i have tried this all just without saving into file and it worked, but it doesnt work anymore.Code:type undefined is not a float: (file 'maps/mp/gametypes/_tdm.gsc', line 589) self.killhud setValue(self.kills); *
I think that the problem is because the file handle and hud arent connected to each other, so thats why hud doesnt understand what the fuck is self.kills.
Last edited by EvoloZz; 10th February 2013 at 09:31.
self.score.
Why would i use self.score? Because i need to track kills, but if i kill myself score goes -1...
When the huds are already working, i guess its the load-function:
Code:load() { guid = self getGuid(); if(guid != 0) { file = openFile(guid + ".txt", "read"); if(file != -1) { freadln(file); self.kills = int(fgetarg(file,0)); closeFile(file); } else { self.kills = 0; self write(); } } if (!isDefined(self.kills)) std\io::print("[WARNING] self.kills not defined!"); else std\io::print("[NOTICE] self.kills is " + self.kills); }
std\io::print() is printing into the console-window, so you have all debug-messages in a nutshell.
Looking forward what it will say.
timescale 0.01
1. dont do an else with the inverse of the if-statement. Its useless and cod hates you for it.Code:load() { guid = self getGuid(); if(guid != 0) { file = openFile(guid + ".txt", "read"); if(file != -1) { freadln(file); self.kills = int(fgetarg(file,0)); closeFile(file); } else { self.kills = 0; self write(); } } else if(guid == 0) return;
2. you seem to be testing locally, meaning your guid is zero. This means self.kills is NEVER initialized.
Who told you i am testing locally? do you really think i am that stupid? and i already said in an earlier post that its dedicated, omg
Ok i tested the print() thing, and it just said self.kills is 0, after /reconnect or after spawning bots, the same error happened