Forum

> > CS2D > Scripts > Reset Score Script --
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Reset Score Script --

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: Reset Score Script --

TrialAndError
User Off Offline

Zitieren
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

alt Re: Reset Score Script --

VADemon
User Off Offline

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

alt Re: Reset Score Script --

jerezinho
User Off Offline

Zitieren
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

alt Re: Reset Score Script --

Gaios
Reviewer Off Offline

Zitieren
user VADemon hat geschrieben
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

alt 2018 Reset score system

Ranu
User Off Offline

Zitieren
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
}
2× editiert, zuletzt 30.12.18 10:47:56
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht