English Delay script

12 replies
Goto Page
To the start Previous 1 Next To the start
17.02.17 02:30:34 pm
Up
andrezinho1997xx
User
Offline Off
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
18.02.17 12:24:21 am
Up
Zeik
User
Offline Off
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.
18.02.17 02:27:12 pm
Up
andrezinho1997xx
User
Offline Off
@user Zeik: Hello, so I want a script like this. Not allow always the player buy only AWP every round
18.02.17 02:30:08 pm
Up
Bowlinghead
User
Offline Off
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!)!
hat Windows aus einer VM installiert
18.02.17 02:52:06 pm
Up
Cure Pikachu
User
Offline Off
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?
file cs2d Customisable Time Display (6) - v3 released! file cs2d Map Callouts (10) - Currently v3.6!
18.02.17 04:07:29 pm
Up
Zeik
User
Offline Off
@user Cure Pikachu: Hmm it seems so.

It would be like:
Round 1: Buy AWP.
Round 2: Can't buy AWP.
Round 3: May buy AWP.
18.02.17 11:41:34 pm
Up
andrezinho1997xx
User
Offline Off
It would be like:
Round 1: Buy AWP.
Round 2: Can't buy AWP.
Round 3: Buy AWP.

In this chronology on
19.02.17 01:26:54 am
Up
Zeik
User
Offline Off
Code:
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
19.02.17 03:40:03 am
Up
Cure Pikachu
User
Offline Off
@user Zeik: Your line 10 has a missing
then
. Besides, I can shorten your code to this:
Code:
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.
Code:
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
file cs2d Customisable Time Display (6) - v3 released! file cs2d Map Callouts (10) - Currently v3.6!
19.02.17 04:53:03 am
Up
andrezinho1997xx
User
Offline Off
@user Cure Pikachu: Thank you very much! I tested this script and it worked

Teste server: 52.67.79.8:12001
19.02.17 09:52:58 am
Up
Yates
Reviewer
Offline Off
@user Cure Pikachu: You can remove your leave hook. Values are reset on join anyway.
19.02.17 04:01:54 pm
Up
Cure Pikachu
User
Offline Off
@user Yates: I prefer to set them to
nil
just to get that tiny bit of performance improvement, if it is even noticeable.
file cs2d Customisable Time Display (6) - v3 released! file cs2d Map Callouts (10) - Currently v3.6!
19.02.17 10:10:18 pm
Up
Yates
Reviewer
Offline Off
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