- Anders4000
Forum




Attack2(id,mode)
17 replies



- Anders4000
Quote
Alternative attack. Is not available for most weapons. Switches the weapon mode (zoom, silencer, burst, color etc.) for several weapons.
More info: http://www.cs2d.com/help.php?cat=all&cmd=attack2#cmd
for silenced weapons:
0 - unsilenced
1 - silenced
for sniper weapons:
0 - unzoomed
1 - zoom level 1
(2 - zoom level 2 - if available)
laser:
0 - green
1 - next color
2 - next color
...
and so on. no guarantee. better test it with a print or something

Well.. I tried this:
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
rightclick = {0,0,0.....}
function attack2(id)
rightclick[id] = 1
end
function attack(id)
rightclick[id] = 0
end
function OnKill(Killer)
--code
end
Don't worry, the making of the rightclick table was made with an arrayinit... And the functions was added as hooks. Just made you a quick example.
J.
Edit:
here's the code (I dont know exact damage of left click and right click from knife):
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
addhook("hit","check")
function check(id,source,weapon,hpdmg)
if (weapon == 50) --was the hit made by knife?
if (hpdmg<50) and (player(id,"health")-hpdmg)<1 then
--'source' hit 'id' with LEFT click and 'id' dies
else if (hpdmg>50) and (player(id,"health")-hpdmg)<1 then
--'source' hit 'id' with RIGHT click and 'id' dies
end
end
end
edited 2×, last 14.01.11 10:26:02 pm

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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
local left={}
for i=1,32 do
left[i]=true
end
addhook("attack","change1")
function change1(id)
left[i]=true
end
addhook("attack2","change2")
function change2(id)
left[i]=false
end
addhook("kill","check")
function check(killer,victim,weapon,)
if (weapon==50) then
if (left[killer] == true) then
--'VICTIM' WAS KILLED WITH LEFT CLICK
else
--'VICTIM' WAS KILLED WITH RIGHT CLICK
end
end
end
EDIT:
lol, I did it the same way you wanted

My attackhooks are written before my Killhook. But that doesn't help.
Anyway i can change this? Or solve this problem?
1
2
2
addhook("attack","change1",-2)
addhook("attack2","change2",-1)

edited 1×, last 17.01.11 03:07:15 pm

1
2
3
2
3
addhook("attack","change1",-2)
addhook("attack2","change2",-1)
addhook("kill","OnKill")
info.txt has written
Priority is only important if there is more than one function attachted to the same hook!
Default is 0, higher numbers = higher priority, lower numbers (also negative) = lower priority.
The attached function with the HIGHEST priority is the LAST function which will be executed.
Moreover CS2D will take the return value of this function (if there is any)!
In most cases you will just omit the priority parameter (yes, it is [optional])!
Default is 0, higher numbers = higher priority, lower numbers (also negative) = lower priority.
The attached function with the HIGHEST priority is the LAST function which will be executed.
Moreover CS2D will take the return value of this function (if there is any)!
In most cases you will just omit the priority parameter (yes, it is [optional])!
I think you should do this (although priority is only when there are 2 functions to the same hook):
1
2
3
2
3
addhook("attack","change1",1)
addhook("attack2","change2",1)
addhook("kill","OnKill",0)

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
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
addhook("join","setforall")
function setforall(id)
parse("bind mouse2 \"attack2;say !shoot_grenade\"")
end
addhook("say","bob")
function bob(id,m)
if (m=="!shoot_grenade") then
parse("equip "..id.." 49")
parse("setweapon "..id.." 49")
parse("attack")
timer(10,"stripthismadafaka",tostring(id),1)
end
return 1
end
addhook("attack","sda")
function sda(id)
bob(id,"!shoot_grenade")
end
function stripthismadafaka(lol)
local id = tonumber(lol)
parse("strip "..id.." 49")
end
addhook("leave","unbind")
function unbind(id)
parse("bind mouse2 \"attack2\"")
end

Anything else i could try?
I bet shall just tell people that they have to use rightclick and that mouse1 will not give extra ammo, and then just release this...
Or maybe you can use leftclick for faster knifing, if you just want a kill but not ammo

Anyways, you probably don't understand me

Anyone else knows what i could do to fix this bug?
- Anders4000



