Forum

> > CS2D > Scripts > This script is not working
Forums overviewCS2D overview Scripts overviewLog in to reply

English This script is not working

2 replies
To the start Previous 1 Next To the start

old This script is not working

Ufjkd
User Off Offline

Quote
Hello everyone, I need a quick help I think. I found this script below, and I need to add 2 weapons to it. But it is not working with 2 weapons.

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
weapcooldown = 2

weaplocked = {}
weaplockround = {}

weaponsallow = {34,35}

addhook("join","e_join")
function e_join(id)
     weaplocked[id] = false
     weaplockround[id] = 0
end

addhook("leave","e_leave")
function e_leave(id)
     weaplocked[id] = nil
     weaplockround[id] = nil
end

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

addhook("buy","e_buy")
function e_buy(id,wp)
     if wp == weaponsallow then
          if weaplocked[id] then
               msg2(id,"\169255000000You can't buy another weap until "..(weapcooldown-weaplockround[id]).." round(s) later!")
               return 1
          else
               weaplocked[id] = true
          end
     end
end

I tried to place = {IDs of the weapons I want to block the purchase temporarily}. But he just does not let buy the scout gun more than the awp he lets buy, I need help on that subject. Thank you

old Re: This script is not working

Bowlinghead
User Off Offline

Quote
Quick Tip:
- line 25: just use ">=" for optimization.
- why not count down with weaplockround? In theorie you dont need the boolean var.

You need to change the buy function to:
1
2
3
4
5
6
7
8
9
10
11
12
function e_buy(id,wp)
     for _,wpn in ipairs(weaponsallow) do
     if wp == wpn then
          if weaplocked[id] then
               msg2(id,"\169255000000You can't buy another weap until "..(weapcooldown-weaplockround[id]).." round(s) later!")
               return 1
          else
               weaplocked[id] = true
          end
     end
     end
end

old Re: This script is not working

Ufjkd
User Off Offline

Quote
Thank you @user Bowlinghead:

Now it's working fine, as I put it in the script that it should do weapon by weapon. Assuming I bought scout and tried to buy it awp it gave me a msg2 error, it could not give that message and it would get to buy another weapon.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview