I want to create a weapon that uses two firing modes: automatic and burst fire.
Looking through, I think I would need to add this hook to the weapon code:
[code] function keyPressed (P, key)
if key == IN_WALK then
if weaponFireMode == 1 then
local weaponFireMode = 2
else local weaponFireMode = 1
end
end
hook.Add( "KeyPress", "switchFireMode", keyPressed ) [/code]
I don't know too much LUA and the code above was half copied from the wiki and half created by myself. The lines with ( ? ) next to them are ones I'm pretty sure won't work.
I would've to declare the weaponFireMode to be either 1 or 2, 1 being auto and 2 being burst fire.
QUESTION: If I return else as nil ( nothing, basically ), will the weapon still fire or do I need to do something like:
[code] elseif key == IN_ATTACK then
( not sure what makes the weapon fire, tbh )
else
return nil [/code]
Basically, do I need to account for all the possibilities before returning as nil? ( possibilities meaning reload, and stuff like that. )
Sorry, you need to Log In to post a reply to this thread.