Forum

> > CS2D > Scripts > Reset Score Script --
Forums overviewCS2D overview Scripts overviewLog in to reply

English Reset Score Script --

7 replies
To the start Previous 1 Next To the start

old Re: Reset Score Script --

TrialAndError
User Off Offline

Quote
Please use code tags or something, and look up other scripts instead of creating a new thread, there are too many similiar threads and/or files here.

1
2
3
4
5
6
7
8
9
addhook("say","reset") 
function reset(id, txt) 
	if(txt=="!rs") then
		parse ("setscore "..id.." 0")
		parse ("setdeaths "..id.." 0")
		parse ("sv_msg2 "..id.." ©255255255Scores Reset")
		return 1 -- Add this
	end 
end

old Re: Reset Score Script --

VADemon
User Off Offline

Quote
cs2d lua hook say
The documentation says that you must "return 1" by the function to hide the message.
However there's a cs2d limitation that the return value will only count for the first function of cs2d lua hook say. If you addhook many functions for "say" it won't work as expected.

old Re: Reset Score Script --

jerezinho
User Off Offline

Quote
user Man Of Steel, use this if you want

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
--Reset Score--

addhook("say","rs")
function rs(p,txt)
     if txt=="!resetscore" or txt=="!rs" then
          if player(p,'deaths')>0 then
               parse("setscore "..p.." 0")
               parse("setdeaths "..p.." 0")
               msg2(p,'\169150255150[Server]:\169255255255 You have just reset your score')
          else
               msg2(p,'\169150255150[Error]:\169255255255 No need to reset your score')
          end
          return 1
     end
end

old Re: Reset Score Script --

Gaios
Reviewer Off Offline

Quote
user VADemon has written
cs2d lua hook say
The documentation says that you must "return 1" by the function to hide the message.
However there's a cs2d limitation that the return value will only count for the first function of cs2d lua hook say. If you addhook many functions for "say" it won't work as expected.

Unless you use CS2D Framework

old 2018 Reset score system

Ranu
User Off Offline

Quote
Special Thanks to @user Hajt:

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
--Script by Ranw--

commands = {}
permit = 0

addhook("say","ranwsay", 999)
addhook("sayteam","ranwsay", 999)

white = "\169255255255"
red = "\169255000000"
green = "\169000255000"

function errranw(id, txt)
    if id == 0 then
        msg("" .. red .. "[Error]:" .. white .. " "..txt)
    else
        msg2(id, "" .. red .. "[Error]:" .. white .. " "..txt)
    end
end

function sucranw(id, txt)
    if id == 0 then
        msg("" .. green .. "[Success]:" .. white .. " "..txt)
    else
        msg2(id, "" .. green .. "[Success]:" .. white .. " "..txt)
    end
end

function ranwcheck(id, txt)
    local cmd = txt:match("^([!][%w]+)[%s]?")
    if not cmd then return end

    cmd = string.lower(cmd)
    
    local sc = shortcuts[cmd]
    if sc ~= nil then cmd = sc end
    
    local aftercmd = txt:match("[%s](.*)")

    ranwprocess(id, cmd, aftercmd)

    return 1
end

function ranwprocess(id, cmd, txt)

    local arguments = {}
    if txt ~= nil then
        txt = escapeString(txt)
        for word in txt:gmatch("[^%s]+") do
            table.insert(arguments, word)
        end
    end
    
    local ret
    if #arguments > 0 then
        ret = commands[cmd].func(id, arguments)
    else
        ret = commands[cmd].func(id)
    end

    if ret ~= nil then
        if ret == false then
            errranw(id, "Something went wrong")
        else
            errranw(id, ret)
        end
        return
    end
end

function ranwsay(id, txt)
	local ret = ranwcheck(id, txt)
	if ret == 1 then
	return 1
   end
end

shortcuts = {
    ["!rs"] = "!resetscore",
}

commands["!resetscore"] = {
    arguments = 0,
    func = function(id, arguments)
    
    if player(id,'deaths') > 0 or player(id,'score') > 0 or player(id,'assists') > 0 or player(id,'mvp') > 0 then
    
        parse("setscore " .. id .. " 0")
        parse("setdeaths " .. id .. " 0")
        parse("setassists " .. id .. " 0")
        parse("setmvp " .. id .. " 0")
        sucranw(id,'Scores reset.')
        else
        errranw(id,'No need to reset your score.')
        end
        return    
    end
}
edited 2×, last 30.12.18 10:47:56 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview