Forum

> > CS2D > Scripts > 2 hours = Vip
Forums overviewCS2D overview Scripts overviewLog in to reply

English 2 hours = Vip

10 replies
To the start Previous 1 Next To the start

old Re: 2 hours = Vip

Rainoth
Moderator Off Offline

Quote
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...
edited 1×, last 03.01.16 07:59:41 pm

old Re: 2 hours = Vip

Dousea
User Off Offline

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

old Re: 2 hours = Vip

Dousea
User Off Offline

Quote
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

old Re: 2 hours = Vip

Avo
User Off Offline

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

Edit: sorry for being Slowpoke.

old Re: 2 hours = Vip

GeoB99
Moderator Off Offline

Quote
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.
edited 2×, last 04.01.16 09:34:04 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview