Reset Scores for Hc.
5 replies



10.07.18 10:16:32 am
Hi folks,
i came here for ask some help and fix my lua code for Hc Admin script.
i want to replace Reset Stats option to Reset scores respectively.
Code sys > lua > hc > modules > playerstats in Line 234 code of Reset Stats.
i want remove reset stats system and add reset scores.
Replace " Yes Reset my stats" to "Yes" And "No!" to 'No"
If click on "Yes" so our scores reset and msg appear "Scores reset" or if click on "No" so nothing happen
i really hard to did it myself but i got errors and was some confutions in parse fuction
Please help me.
i came here for ask some help and fix my lua code for Hc Admin script.
i want to replace Reset Stats option to Reset scores respectively.
Code sys > lua > hc > modules > playerstats in Line 234 code of Reset Stats.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function hc.playerstats.reset_command(p)
local entries = {
{ title = "Yes: Reset my stats!", value = true, id = p },
{ title = "No!", value = false, id = p }
}
hc.show_menu(p, "Reset Stats?", entries, hc.playerstats.reset_cb)
end
function hc.playerstats.reset_cb(p, _, item)
if item.value then
hc.players[p].playerstats = hc.playerstats.get_empty_stats();
hc.players[p].playerstats.next_lvl = 1
hc.players[p].playerstats.saved = hc.playerstats.get_empty_stats();
local usgn = hc.get_usgn(p)
if hc.playerstats.usgn[usgn] ~= nil then
-- Move players up on the top list
for pos=hc.playerstats.usgn[usgn].position,#hc.playerstats.top - 1 do
hc.playerstats.top[pos] = hc.playerstats.top[pos + 1]
hc.playerstats.top[pos].position = pos
end
hc.playerstats.usgn[usgn] = nil
hc.playerstats.top[#hc.playerstats.top] = nil
end
hc.event(p, "\169255255000[SERVER]\169255255255: Your statistics have been reset.")
else
hc.event(p, "\169255255000[SERVER]\169255255255: Your statistics were not reset.")
end
end
local entries = {
{ title = "Yes: Reset my stats!", value = true, id = p },
{ title = "No!", value = false, id = p }
}
hc.show_menu(p, "Reset Stats?", entries, hc.playerstats.reset_cb)
end
function hc.playerstats.reset_cb(p, _, item)
if item.value then
hc.players[p].playerstats = hc.playerstats.get_empty_stats();
hc.players[p].playerstats.next_lvl = 1
hc.players[p].playerstats.saved = hc.playerstats.get_empty_stats();
local usgn = hc.get_usgn(p)
if hc.playerstats.usgn[usgn] ~= nil then
-- Move players up on the top list
for pos=hc.playerstats.usgn[usgn].position,#hc.playerstats.top - 1 do
hc.playerstats.top[pos] = hc.playerstats.top[pos + 1]
hc.playerstats.top[pos].position = pos
end
hc.playerstats.usgn[usgn] = nil
hc.playerstats.top[#hc.playerstats.top] = nil
end
hc.event(p, "\169255255000[SERVER]\169255255255: Your statistics have been reset.")
else
hc.event(p, "\169255255000[SERVER]\169255255255: Your statistics were not reset.")
end
end
i want remove reset stats system and add reset scores.
Replace " Yes Reset my stats" to "Yes" And "No!" to 'No"
If click on "Yes" so our scores reset and msg appear "Scores reset" or if click on "No" so nothing happen
i really hard to did it myself but i got errors and was some confutions in parse fuction
Please help me.
edited 1×, last 11.07.18 05:57:45 am
FRiendly boYy.
Inside
Search for function
Add inside that function:
Scroll down and find a place to add the new functions:
This should add you a new menu without removing the Reset Activity Menu. If you want to Disable the Reset Activity Menu then do the following:
Inside
Replace
With the following:
And you should be good to go
Code:
1
hc/modules/playerstats.lua
Search for function
Code:
1
function hc.playerstats.init()
Add inside that function:
Code:
1
hc.add_menu_command("Reset Score", hc.playerstats.reset_score_command, hc.USER, hc.COMMAND_MENU_KEY, { category = "Activity" })
Scroll down and find a place to add the new functions:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function hc.playerstats.reset_score_command(p)
local entries = {
{ title = "Yes: Reset my score!", value = true, id = p },
{ title = "No!", value = false, id = p }
}
hc.show_menu(p, "Reset Score?", entries, hc.playerstats.reset_score_cb)
end
function hc.playerstats.reset_score_cb(p, _, item)
if item.value then
if player(p,"deaths") > 0 or player(p,"score") > 0 then
parse("setscore "..p.." 0")
parse("setdeaths "..p.." 0")
hc.event(p, "Your score has been reset.")
else
hc.event(p, "Your score is already nullified.")
end
else
hc.event(p, "Your score did not reset.")
end
end
local entries = {
{ title = "Yes: Reset my score!", value = true, id = p },
{ title = "No!", value = false, id = p }
}
hc.show_menu(p, "Reset Score?", entries, hc.playerstats.reset_score_cb)
end
function hc.playerstats.reset_score_cb(p, _, item)
if item.value then
if player(p,"deaths") > 0 or player(p,"score") > 0 then
parse("setscore "..p.." 0")
parse("setdeaths "..p.." 0")
hc.event(p, "Your score has been reset.")
else
hc.event(p, "Your score is already nullified.")
end
else
hc.event(p, "Your score did not reset.")
end
end
This should add you a new menu without removing the Reset Activity Menu. If you want to Disable the Reset Activity Menu then do the following:
Inside
Code:
1
function hc.playerstats.init()
Replace
Code:
1
hc.add_menu_command("Reset", hc.playerstats.reset_command, hc.RESET_STATS_LEVEL, hc.COMMAND_MENU_KEY, { category = "Activity" })
With the following:
Code:
1
-- hc.add_menu_command("Reset", hc.playerstats.reset_command, hc.RESET_STATS_LEVEL, hc.COMMAND_MENU_KEY, { category = "Activity" })
And you should be good to go

Mess with the best, die like the rest. ༼ つ ◕_◕ ༽つ
22.05.19 07:22:57 pm
my problems almost had already solved but thank so you much for taking your time for me.
FRiendly boYy.



