Forum

> > CS2D > Scripts > Grenade Launcher function for M4A1/Ak47
Forums overviewCS2D overview Scripts overviewLog in to reply

English Grenade Launcher function for M4A1/Ak47

27 replies
Page
To the start Previous 1 2 Next To the start

old Grenade Launcher function for M4A1/Ak47

J4x
User Off Offline

Quote
hi guys im triying to make a grenade launcher function for the m4A1 and ak-47, it will be something like if u press f3 it will changer the fire mod into grenade launcher mode, but the problem is that i dont know how to make that the weapon only have 1 bullet when u activate the grenade launcher function...

i try to write a code...

1
2
3
4
5
6
7
8
9
10
11
addhook("hit","boom")
addhook("serveraction","explode")
function explode(id,action)
function boom(id,src,wpn)
if action == 2 then
if wpn == 30 then
parse("explosion "..player(id,"x").." "..player(id,"y").." 1 24 "..src)
end
end
end
end
edited 3×, last 04.01.11 09:13:57 pm

Admin/mod comment

Your title should describe your problem/question. Changed. /TheKilledDeath

old Re: Grenade Launcher function for M4A1/Ak47

DannyDeth
User Off Offline

Quote
Maybe this will work?
Spoiler >

old Re: Grenade Launcher function for M4A1/Ak47

Flacko
User Off Offline

Quote
Wtf.
You attached a function you declared INSIDE a function to a hook?!
Failure overload.
You're aiming totally in the wrong direction.

Edit:
This is a basic example that doesn't check for weapons nor stuff...
Toggle the Grenade Launcher with F3.

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
using_gl = {}

addhook("serveraction","_serveraction")
function _serveraction(id,a)
	if a == 2 then
		using_gl[id] = not (using_gl[id])
		if using_gl[id] then
			msg2(id,"Grenade Launcher is ON")
		else
			msg2(id,"Grenade Launcher is OFF")
		end
	end
end

addhook("attack","_attack")
function _attack(id)
	using_gl[id] = nil
end

addhook("hit","_hit")
function _hit(id,src)
	if(src ~= id) then
		if(using_gl[src]) then
			using_gl[src] = nil
			parse("explosion "..player(id,"x").." "..player(id,"y").." 1 24 "..src)
		end
	end
end
edited 1×, last 31.12.10 09:31:50 pm

old Re: Grenade Launcher function for M4A1/Ak47

Phenixtri
User Off Offline

Quote
Seeing as you guys are working on this n have experience with it I have a Q.

Would it be possible to make the rocket launcher a grenade launcher for say the AK47 (M4A2 M203) & the P90 (MP5 M203)?

Basically I want to make a M203 grenade launcher lua script for NTDs HL2D mod & its 2 weapons the M4 & MP5. I was thinking of making a nade launcher that behaves just like the one in Half Life.

Details on how I want to make the launchers to function as.

1) The launcher is a secondary fire mode for the MP5 (P90) & M4 (AK47).

2) The secondary launcher is activated with the right mouse button or F3 as the default bind key.

3) Both the launcher for the MP5 & M4 are single shot with a 3 sec delay between shots (during this delay you may also not use the primary fire mode)

4) Both launchers use the same ammo reserve with a max ammo count of 10+1

5) During the 3 sec delay there will be a custom reload sound for the launcher.

6) The grenade launcher (rocket launcher) will have its own reloading sound & projectile flight/fire sound. (since the default rocket launcher uses the RPGs firing/rocket flight sound)

So from a lua perspective what would be my main obstacles for making a lua for such a function ?

Sorry if its a little off topic but you guys are so far the only people attempting a grenade launcher function for CS2D so logically Ill ask you for guidance on the matter.

old Re: Grenade Launcher function for M4A1/Ak47

Phenixtri
User Off Offline

Quote
i know n im even getting help from starkz n kimkat on the Half Life mod thread on the topic but im still trying to understand the mind fuck known as lua scripting @_@

code like lua is especially difficult for me since im a visual learner & creator

old Re: Grenade Launcher function for M4A1/Ak47

loldlold123
User Off Offline

Quote
Wohaa ??! i make it wait i making some little things

my script is :

if you press f3 you activited grande luncher
if you press again f3 you deactibited grande luncher
you can use only for m4a1 (i can edit it)

if you join to game you have 1 grande
and if grande luncher acvited and when you shot with m4a1 EXPLOSİVEE

now im making on f2 grande buying menu

(maximum you can wear 1 grande but if you want more i can edit)
edited 1×, last 05.01.11 09:07:44 pm
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview