J4x User Offline
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 Maybe this will work?
Spoiler 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("hit","boom")
addhook("serveraction","explode")
function explode(id,action)
	function boom(id,src,wpn,action)
		local AMMO = 1
		if AMMO > 0 then
			if action == 2 then
				if wpn == 30 then
					parse("explosion "..player(id,"x").." "..player(id,"y").." 1 24 "..src)
				end
			end
		end
	end
end
J4x User Offline
thx for the answer ill test it Anytime
So, does it work? J4x User Offline
i cant test it right now, but u will be in the credits of the relism mod Well, that would be nice, but no need if it doesn't work/I can't fix it 1 Question, why do you use a function in anotherone? And that function is called by a hit hook and the other one by a serveractoin hook, why this? J4x User Offline
becuase i want the m4a1 to shoot the "grenade" only if u press the serveraction But why the "hit" hook? Only if he's hurted by someone AND uses serveraction? J4x User Offline
yeah thats what i like...
EDIT: flacko then what i should do? edited 2×, last 31.12.10 09:09:49 pm
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
hey why not try to when buy the M4A1/Ak47 you win a grenade launcher for ak47 and rocket launcher for m4a1
sorry I used the google translator edited 1×, last 03.01.11 06:55:16 pm
translators are forbidden -.- PartyPooPer has written
translators are forbidden -.-
Why acctually? Because it's not able to understand? (That smiley was ment as a laugh, not a "talk"...) 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. J4x User Offline
i was thinking making something exactly as u describe it, but i think its to hard... edited 2×, last 05.01.11 08:09:19 pm
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 J4x User Offline
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
J4x User Offline
can u show us the code headhunter?