Forum

> > CS2D > Scripts > Throw weapon at player
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Throw weapon at player

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Throw weapon at player

Mami Tomoe
User Off Offline

Zitieren
I'd like to be able to throw a weapon at a player, given source x, y and player x, y.

With range calculation and rotation calculation.

Help pls

alt Re: Throw weapon at player

cs2d_is_a_Gem
User Off Offline

Zitieren
> If you can't make a script as basic as this, you shouldn't speak expertly in my posts, it even says you would do better.

Anyway, I know it is difficult for you to understand the scripts. I will write the script for you if you give me more details.

alt Re: Throw weapon at player

cs2d_is_a_Gem
User Off Offline

Zitieren
In my nick my username comes out if you want to know who I am, I know you don't know how to read scripts, but I didn't know that you don't know how to read English.

well if you explain better I help you with your little basic problem.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cant_drop = {50,74}
normal_drop = {47,48,49,51,52,53,54,72,73,75,76,89}

addhook("drop","drop")
function drop(id,idd,type)
     for _, value in pairs(cant_drop) do
          if value == player(id,"weapon") then
return 1
end
end

     for _, v in pairs(normal_drop) do
          if v == player(id,"weapon") then
return 0
end
end

local x=player(id,"x") 
local y=player(id,"y") 
local rot=player(id,"rot") 
parse("strip "..id.." "..type.."")
parse("spawnprojectile 0 "..type.." "..x.." "..y.." 100 "..rot.."")
return 1
end
1× editiert, zuletzt 19.05.20 21:46:16

alt Re: Throw weapon at player

The Dark Shadow
User Off Offline

Zitieren
@user cs2d_is_a_Gem: You and your scripting skills are sucks anyway. Most likely you don't know anything about performance optimization...and this code without tabs make my eyes hurt. No need to be pretentious anyway, sir. With my respect!

alt Re: Throw weapon at player

Mami Tomoe
User Off Offline

Zitieren
I want the weapon to be thrown in the player's direction regardless of where the location or player are.

locationX, locationY
playerX, playerY

It's simple math, for whoever knows math.

I don't know what else you're talking about though.

alt Re: Throw weapon at player

Baloon
GAME BANNED Off Offline

Zitieren
Try this
1
2
3
4
5
6
7
8
-- in pixels
local locationX = 16
local locationY = 16

function throwTo(id, weapon)
   local deltaX, deltaY = locationX-player(id,"x"), locationY-player(id,"y")
   parse("spawnprojectile "..id.." "..weapon.." "..locationX.." "..locationY.." "..math.sqrt(deltaX^2+deltaY^2).." "..math.deg(math.atan2(-deltaX, deltaY)))
end
Sorry, little mistake, edited and bumped.
2× editiert, zuletzt 20.05.20 14:12:56

alt Re: Throw weapon at player

Mami Tomoe
User Off Offline

Zitieren
Thanks that should work, will test it in a few hours once I'm home.

Edit:
OK so it works but only for some degrees, like if I stand above it the weapon spawns at the locationX, locationY but if I stand like at the left, the weapon is thrown to me.

Is that me using it wrong or is there an actual issue with the sample code?


Edit: I got it to work thanks
2× editiert, zuletzt 21.05.20 17:28:45
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht