Forum

> > CS2D > Scripts > Reset Scores for Hc.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Reset Scores for Hc.

5 replies
To the start Previous 1 Next To the start

old Reset Scores for Hc.

Man Of Steel
User Off Offline

Quote
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.

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
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

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

old Re: Reset Scores for Hc.

G3tWr3ck3d
User Off Offline

Quote
Inside
1
hc/modules/playerstats.lua

Search for function
1
function hc.playerstats.init()
Add inside that function:
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:
1
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

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
1
function hc.playerstats.init()
Replace
1
hc.add_menu_command("Reset", hc.playerstats.reset_command, hc.RESET_STATS_LEVEL, hc.COMMAND_MENU_KEY, { category = "Activity" })
With the following:
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 √

old Thnkx

Man Of Steel
User Off Offline

Quote
my problems almost had already solved but thank so you much for taking your time for me.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview