*Apparently doing math on high_score_table[2] after loading it makes it work properly... What am i missing in my knowledge here?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- loading the highscores into a table on server start -- for line in io.lines("sys/lua/highscore/highscore.txt") do table.insert (high_score_table, line); end function update_scores(id) in_game_player_score[id]=(player(id,"score")*120)+(((player(id,"score")*2)*score_multiplier[id])+snowball_hit_score_bonus[id]) parse('hudtxt2 '..id..' 3 "©000230000Score: '..in_game_player_score[id]..'" 300 18 0') 	if in_game_player_score[id] > high_score_table[2] then -- offending line 	high_score_table[1] = player(id,"name") 	high_score_table[2] = in_game_player_score[id] 	high_score_save = io.open("sys/lua/highscore/highscore.txt", "w") 	high_score_save:write(""..high_score_table[1].."\n") 	high_score_save:write(""..high_score_table[2].."\n") 	high_score_save:close() 	parse('hudtxt 8 "©230000000Highscore - '..high_score_table[1]..': '..high_score_table[2]..'" 475 18 0') 	end end
LUA ERROR: sys/lua/autorun/score.lua:41: attempt to compare string with number
-> sys/lua/autorun/score.lua:41: in function 'update_scores'
-> sys/lua/autorun/score.lua:62: in function <sys/lua/autorun/score.lua:53>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- There's also this that runs on server start which might be relevant -- check_high_score_exists = io.open("sys/lua/highscore/highscore.txt","r") if check_high_score_exists ~= nil then io.close(check_high_score_exists) parse("sv_msg Highscore loaded") else high_score_table[1] = "no highscore set" high_score_table[2] = 0 high_score_save = io.open("sys/lua/highscore/highscore.txt", "w") high_score_save:write(""..high_score_table[1].."\n") high_score_save:write(""..high_score_table[2].."\n") high_score_save:close() parse('hudtxt 8 "©230000000Highscore - '..high_score_table[1]..': '..high_score_table[2]..'" 475 18 0') end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
-- here's where the update_scores function is being called from -- addhook ("spawn","reset_scores") function reset_scores(id) score_multiplier[id] = 1 in_game_player_score[id] = 0 snowball_hit_score_bonus[id] = 0 parse('hudtxt2 '..id..' 4 "©000215000Score multiplier: '..score_multiplier[id]..'" 300 0 0') glow_by_score_amount[id] = image("gfx/sprites/flare.png",1,0,200+id) imageblend(glow_by_score_amount[id],1)								 imagealpha(glow_by_score_amount[id],0.5) imagecolor(glow_by_score_amount[id],0,0,0) update_scores(id) end
edited 7×, last 30.11.17 03:09:11 am