Forum

> > CS2D > Scripts > 2 hours = Vip
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch 2 hours = Vip

10 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: 2 hours = Vip

Rainoth
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
p = {}
addhook("team","_t")
function _t(id,t)
	if not p[id] then p[id]=0 end
end

addhook("minute","_m")
function _m()
	for k, v in pairs (player(0,"table")) do
		p[v] = p[v] + 1
		if p[v] == 120 then
			-- give vip here
		end
	end
end

addhook("leave","_l")
function _l(id)
	if p[id] then p[id] = nil end
end

Works even if the player goes into spectator.

// P.S. for someone who claimed to have found security issues. You're pretty bad if you ask for these kind of things...
1× editiert, zuletzt 03.01.16 19:59:41

alt Re: 2 hours = Vip

Dousea
User Off Offline

Zitieren
@user Rainoth: There will be an error at line 4 because after the condition you don't assign any value to p[id].

alt Re: 2 hours = Vip

Dousea
User Off Offline

Zitieren
Will do the same as user Rainoth's.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
p = {}
addhook("team","_t")
function _t(id,t)
	p[id] = p[id] or 0
end

addhook("minute","_m")
function _m()
	for k, v in ipairs (player(0,"table")) do
		p[v] = p[v] + 1
		if p[v] == 120 then
			-- give vip here
		end
	end
end

addhook("leave","_l")
function _l(id)
	p[id] = nil
end

alt Re: 2 hours = Vip

Avo
User Off Offline

Zitieren
I believe
1
p[id] = (p[id] or 0)
would work as well

Edit: sorry for being Slowpoke.

alt Re: 2 hours = Vip

GeoB99
Moderator Off Offline

Zitieren
It isn't actually hard to do that if you know at least some basics in Lua. The stuff that you asked is basically very simple to do so.
1
2
3
4
5
6
7
8
9
10
11
12
VIP = {}

function VIPsay(id, text)
     for _,i in ipairs(VIP) do
          if i == player(id, "usgn") then
               msg("\169255255255"..player(id, "name").." [VIP]: "..text)
               return 1
          end
     end
end

addhook("say","VIPsay")
Your only task is by adding your USGN ID in the {} brackets and that's it.

• Edit: Oopsie, I left return 1 forgotten which means it will lead to a bug - whenever you type something, the message will appear two times. I guess you wouldn't mind it, I fixed that issue nevertheless. Was bit in a hurry while typing the code.
2× editiert, zuletzt 04.01.16 09:34:04
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht