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.

Dark GDK / Guns & Ammo trouble

Author
Message
SFCBias
15
Years of Service
User Offline
Joined: 8th Aug 2009
Location: Hephzibah, GA, USA
Posted: 25th Nov 2009 21:44 Edited at: 25th Nov 2009 22:38
Ive created a player class in which each player has another type called 'PlayerGun' which of course is the Players Gun. Each Gun has a 'Ammo' member and its not a problem until i drop the gun. I change guns by using a function to pickup items and it changes the guns by

Player[0].PlayerGun = Gun_to_pickup.

At This point every thing is fine. but when i use ammo, drop the gun by picking up another (Player[0].PlayerGun = New_Gun_to_pickup), the ammo on the other gun resets. Im not sure why this is happening so maybe someone can give me some advice
Gun Class


item pickup function


EDIT:

Here The player struct if it helps



if(You.AddCode.toPost)TGC.Users.CanHelp = true;
else return NoCodeMessage;
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 25th Nov 2009 22:25 Edited at: 25th Nov 2009 22:31
do you store the ammo of the dropped gun after it is dropped or is it just stored until it is dropped? also do you give ammo for the gun when it is picked up or use the ammo stored with the gun?

I ask these because I'm not all to familiar with classes yet. However, it seems to me that you only store how much ammo the gun has in the player class, so when a new gun is picked up this value is lost which gives it either a default value or a new value for the ammo ( you said it resets but you didn't specify to empty or full ) anyway I hope this helps.

Also, after re-reading the code something else occured, in your fireing function do you remove ammo from the values in the instance of the gun class or just from the player's information? maybe try to remove the values from both? again, just shooting in the dark ( no pun intended ).
SFCBias
15
Years of Service
User Offline
Joined: 8th Aug 2009
Location: Hephzibah, GA, USA
Posted: 25th Nov 2009 22:39 Edited at: 25th Nov 2009 22:44
EDIT EDIT: Your first post explains the problem, i didnte realize that was happening. I was taking the ammo from the instance in the player , rather than the instance of the gun itself.

So, thank you for your help..sometimes you need other people to catch things like that for you

if(You.AddCode.toPost)TGC.Users.CanHelp = true;
else return NoCodeMessage;
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 26th Nov 2009 00:10
Any time 8-D sorry for being so unspecific

Login to post a reply

Server time is: 2024-11-19 09:52:56
Your offset time is: 2024-11-19 09:52:56