FPS: Problems with python, weapon list.(Done, just used logic bricks)

I already did it with logic bricks

Hi,

I’m just starting with python, and I want animated weapon changing. I already did a script, set up the logic bricks for it, but it didn’t work. They didn’t switch. I’ve posted it but nobody sees anything on it.

Here’s the script:

#################################################################
#################
#################################################################

import GameLogic

###################################################
###########
###################################################

cont = GameLogic.getCurrentController()
own = cont.getOwner()

M4Replace = cont.getActuator(“M4Replace”)
USPReplace = cont.getActuator(“USPReplace”)
animation = cont.getActuator(“animation”)
M4A1 = cont.getSensor (“M4A1”)
Pistol = cont.getSensor (“Pistol”)
SetM41 = cont.getActuator (“SetM41”)
SetUSP1 = cont.getActuator (“SetUSP1”)

######################################################
###################
######################################################

if Pistol.isPositive():
GameLogic.addActiveActuator(animation,1)
if animation.getFrame() > 25:
GameLogic.addActiveActuator(USPReplace,1)
GameLogic.addActiveActuator(SetUSP1,1)
else:
GameLogic.addActiveActuator(USPReplace,0)
GameLogic.addActiveActuator(SetUSP1,0)

if M4A1.isPositive():
GameLogic.addActiveActuator(animation,1)
if animation.getFrame() > 25:
GameLogic.addActiveActuator(M4Replace,1)
GameLogic.addActiveActuator(SetM41,1)
else:
GameLogic.addActiveActuator(M4Replace,0)
GameLogic.addActiveActuator(SetM41,0)

####################################################
########################
####################################################

Thanks


This can super easily be done in logic bricking! No need for python dude.

have a “weaponchange” property (a timer), and of course a “weapon” property :slight_smile:
anyways…

keyboardselectweapon1 ______and ______ property “weapon” = 1
_____________________________________property “changeweapon” = 0.000

property “changeweapon” < 0.200 ____ and ____ action “change to weapon 1”

and make the weapon meshes appear ect…

tell ya what that wasnt too clear ill rig a small demo file super simple for ya!

Thank you alot! But its not clear, its not working for me! ( I tested it with cube and cilynder meshes as guns, with an ipo ) It just plays the ipo, but when it returns the cilynder is still there!

What happens is that the timer is not working for me

Yes, MASSter!!!
I did it!
But not using a timer property. I did it by using a cube with an ipo and a plane, that sends a message!

Lol, do you know how to close a thread? It doesn’t appear on the FAQ.

lolololol wow so much information! :eek:

to close a thread just edit your first post or post again saying that its closed. usually people wont post again if youve stated that uve figured things out, but do it just to be sure…

Yeah, and for different weapons ammo HUD display, just using visibility actuators is enough.