Forum

> > CS2D > Scripts > Delay script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Delay script

12 replies
To the start Previous 1 Next To the start

old Delay script

ead
User Off Offline

Quote
Hello everyone! I need a script that works like this, the player can buy the AWP gun a few times in 5 to 20 round for example and the rest of 15 rounds he can not buy weapon. I need a script like this because I use the de_cs2d map and it gets a little hard to detect someone using hack

Thank you in advance

Edit ;
For who did not understand I want a script like this, prohibit buy 1 round and another not the AWP gun.
edited 1×, last 17.02.17 05:06:59 pm

old Re: Delay script

Zeik
User Off Offline

Quote
Requirements are not clear:

• "the player can buy the AWP gun a few times in 5 to 20 round ... and the rest of 15 rounds he can not buy weapon"
How much is "few" times?
From round 5 to 20 you can only buy AWP a "few" times? but from round 20 to 35 you can't buy it even though you had not bought it a "few" times yet?

• "prohibit buy 1 round and another not the AWP gun."
Here you're saying that you can buy AWP in odd rounds and not in even rounds?

The second requirement contradicts the first and none of them is clear.

old Re: Delay script

ead
User Off Offline

Quote
@user Zeik: Hello, so I want a script like this. Not allow always the player buy only AWP every round

old Re: Delay script

Bowlinghead
User Off Offline

Quote
If someone writes that your requirements are not clear then it is not optimal to write 1 sentence that doesnt give additional information.

Please give more detail (Use more words, be specific!)!

old Re: Delay script

Cure Pikachu
User Off Offline

Quote
Suppose the player buys an AWP on round 5, now you don't want that player to buy another AWP until round 7. Is that correct?

old Re: Delay script

ead
User Off Offline

Quote
It would be like:
Round 1: Buy AWP.
Round 2: Can't buy AWP.
Round 3: Buy AWP.

In this chronology on

old Re: Delay script

Zeik
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
round = 1

addhook("endround", "e_endround")
function e_endround()
  round = round + 1
end

addhook("buy", "e_buy")
function e_buy(id, wp)
  if (wp == 35 and round%2 == 0) then
    return 1
  end
end
edited 1×, last 19.02.17 04:42:24 am

old Re: Delay script

Cure Pikachu
User Off Offline

Quote
@user Zeik: Your line 10 has a missing
then
. Besides, I can shorten your code to this:
1
2
3
4
5
6
addhook("buy","e_buy")
function e_buy(id,wp)
	if wp == 35 and (tonumber(game("round"))%2 == 0) then
		return 1
	end
end

This is IMO a better version - it prevents players from buying more than 1 AWP in a single round and don't have to wait for even rounds to buy one.
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
awpcooldown = 2 -- How many rounds to wait before you can buy another AWP

awplocked = {}
awplockround = {}

addhook("join","e_join")
function e_join(id)
	awplocked[id] = false
	awplockround[id] = 0
end

addhook("leave","e_leave")
function e_leave(id)
	awplocked[id] = nil
	awplockround[id] = nil
end

addhook("endround","e_endround")
function e_endround()
	for _, id in ipairs(player(0,"table")) do
		if awplocked[id] then
			awplockround[id] = awplockround[id] + 1
			if awplockround[id] == awpcooldown then
				awplocked[id] = false
				awplockround[id] = 0
			end
		end
	end
end

addhook("buy","e_buy")
function e_buy(id,wp)
	if wp == 35 then
		if awplocked[id] then
			msg2(id,"\169255000000You can't buy another AWP until "..(awpcooldown-awplockround[id]).." round(s) later!")
			return 1
		else
			awplocked[id] = true
		end
	end
end
edited 2×, last 19.02.17 05:10:47 am

old Re: Delay script

Cure Pikachu
User Off Offline

Quote
@user Yates: I prefer to set them to
nil
just to get that tiny bit of performance improvement, if it is even noticeable.

old Re: Delay script

Yates
Reviewer Off Offline

Quote
That would never be noticeable. If you said it were for better practice, sure, but not for "better performance".
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview