Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / checking for equality between user defined types

Author
Message
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 17th Mar 2010 01:46
hey, i cannot understand why this isnt working. im trying to get you to be able to press S to switch from ur primary weapon to ur side arm or vice versa. as of now you can switch from ur side arm to the primary weapon but not back.

Apparently in the IF statement on line 98 (where it check to see if the currentweapon of the player is equal to the primaryweapon he has, it is NEVER equal.

im confused on this, attached is the project folder

arrow keys to move/strafe
mouse to look
r to reload
s to switch weapons (NOT WORKING)

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 17th Mar 2010 02:14
You switch to your sidearm

your sidearm = pistol

pistol has no value... ever.

Windows 7 32-Bit Home Premium Intel Pentium Dual-Core @ 1.46Ghz 2038mb RAM
Krilik
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Arizona, USA
Posted: 17th Mar 2010 02:24
They're never equal because the udt variable isn't assigned a value. The variables inside the udt are assigned values.

Instead of checking if the currentweapon is equal to the primaryweapon, you should check for player(1).currentweapon.name = player(1).primaryweapon.name, as the variable name in the udt actually has an assigned value to check.
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 17th Mar 2010 04:03 Edited at: 17th Mar 2010 04:04
mad nightmare:

ya, the pistol was defined right after the sniper was. in the define_variables subroutine i think

Krillik:

thanks, ill go try that!


[EDIT]

IT WORKS! THANKS KRILLIK!

Login to post a reply

Server time is: 2026-07-26 21:12:24
Your offset time is: 2026-07-26 21:12:24