Forum

> > CS2D > Scripts > Attack projectile by reqcld
Forums overviewCS2D overview Scripts overviewLog in to reply

English Attack projectile by reqcld

6 replies
To the start Previous 1 Next To the start

old Attack projectile by reqcld

Mora
User Off Offline

Quote
Hello us
i was confused when i tryed to do something with it:
But why it spawned at pointer?
i guess it will spawned from player to pointer.

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
function earray(m,v)
     local a = {}
     for i = 1, m do
          a[i] = v
     end
     return a
end

smoke_atat = earray(32,0)

addhook("always","forever")
function forever()
     for _, id in pairs(player(0,"table")) do
          if smoke_atat[id] > 0 then
               reqcld(id,2)
          end
     end
end

addhook('clientdata','dataplz')
function dataplz(id,m,x,y)
     if m == 2 then
          if smoke_atat[id] == 1 then
			   if x > 0 and y > 0 and x < map([[xsize]]) * 32 and y < map([[ysize]]) * 32 then
		parse("spawnprojectile "..id.." 53 "..x.." "..y)
				smoke_atat[id] = 0
			   end
          end
     end
end
So, anyone know what it needs?
Thank you a lot !

old Re: Attack projectile by reqcld

Rainoth
Moderator Off Offline

Quote
You might want to read cs2d.com/help
for such things. Requesting client data of type two will return you with data1 as pointer X position and data2 as pointer Y position.

If you want them to spawn from player towards cursor, you don't need to request client data. Unless you need exact distance. Just use player(id,"x") (and y) and current player angle (player(id,"rot")

1
2
3
4
5
6
7
8
addhook("always","forever")
function forever()
     for _, id in pairs(player(0,"table")) do
          if smoke_atat[id] == 1 then
               parse("spawnprojectile "..id.." 53 "..x.." "..y.." "..math.random(1,15)*20 .." "..player(id,"rot"))
          end
     end
end

If you want exact distance use client data hook.

old Re: Attack projectile by reqcld

Mora
User Off Offline

Quote
1
LUA ERROR: sys/lua/Main.lua:1205: attempt to concatenate global 'y' (a nil value).

but it throw from player? (x)(y) isn't player, is pointer coordination?

dat my english.uf

old Re: Attack projectile by reqcld

Mora
User Off Offline

Quote
@user Rainoth: amm is okay, but dat:
1
"..math.random(1,15)*20 .."
As i guess this is projectile dir, and isn't at pointer...
Maybe so?:
Do you know @user Starkkz:'s admin script? here is by SVact projectiles fly at pointer when key is press. But i need just replace it to attack hook.
Starkkz use his functions, i will didnt copy/paste it, 1)is his, 2) i will fail.

old Re: Attack projectile by reqcld

Rainoth
Moderator Off Offline

Quote
Dude it works exactly like user Starkkzs
I even tested it to make sure.

Here's the script I ran
1
2
3
4
5
6
addhook("always","forever")
function forever()
     for _, id in pairs(player(0,"table")) do
        parse("spawnprojectile "..id.." 53 "..player(id,"x").." "..player(id,"y").." "..math.random(1,15)*20 .." "..player(id,"rot"))
     end
end

the
1
math.random(1,15)*20
is distance calculation so the smoke grenades fly at random distances of 15 to 300

That's why I said that you need to use reqcld IF you want exact distance calculation. You never asked for that so I made it with math.random.

old Re: Attack projectile by reqcld

Mora
User Off Offline

Quote
@user Rainoth:
Topic has written
i was confused when i tryed to do something with it:
But why it spawned at pointer?
i guess it will spawned from player to pointer.

Dat english, you know that mine is bad, you can ask what is that, it's a bit understandable, but you do everything that asked here,... sorry my bad, i will told it like:
Quote
i was confused when i tryed to do something with it:
But why it spawned at pointer?
I think it will fly from a player at pointer, like in starkkz's admin script(but it's in serveraction)

Also title says that:
Title has written
Attack projectile by reqcld
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview