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.

Newcomers DBPro Corner / [dbpro]Grog Grueslayer ...

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 6th Nov 2005 04:40
remember when you told me this?
Quote: "I would use select/case. Anything that has to do with the weapons like the max ammo for each weapon could also be included."


Well, I used to have a type array for the weapons containing all the weapon info and a case/select fucntion for offsetting the limb. Now, I want to do away with the weapon type array and just use the case/select function. However, the weapon name is not displayed when a weapon is picked up and the ammo and clips is always 0.



I thought maybe all of those had to be global but then I remember that global variables are defined at the beginning of the code and functions are defined at the bottom of the code so that can't be it.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Nov 2005 05:24
Anything that is only defined inside a function won't exist outside of the function... unless it's defined as global or in an array (which are automatically global).

The only things you want to be inside the select/case are constants that don't change for each weapon like name$, maxclips, and maxammo. The way it is right now the minute the player picks up a weapon you have the current ammo and clips to be at the max... most first person shooters only give you one clip of ammo when picking up a weapon.

The clips and the ammo you want defined outside of the function in an array (just using the dim statement will be fine... you don't need to give the player any ammo). When their in an array you can add to the ammo and clips whenever the player runs over a crate of ammo and when they pick up a weapon.

The function should only be used when the player switches weapons... weither it be when picking up a weapon (that the player doesn't have yet) and when the player specifically decides to switch to a different weapon. Adding ammo to the players ammo array should be done outside of the function.

I hope this helps... just let me know if you need more help.
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 6th Nov 2005 06:04
So your point is that I will need some kind of array, but it doesn't have to be a type array?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Nov 2005 08:15 Edited at: 6th Nov 2005 08:16
Right... but only for the number of bullets and clips being carried by the player for each weapon. The name of the weapon and the max for bullets and clips need to be global but not in an array (which change everytime a different weapon is selected).

Some people might disagree with me but i'll say it anyway. Type arrays require more code in a lot of cases. A regular array is a lot easier to work with 99% of the time. I generally only use UDT's (User Defined Types) when i'm working with file loading/saving data.

If all the data is going to be either a string or an integer it's best to just use a regular array. The weapon clips and ammo for each weapon can be put into a single regular array.



CWeapon is still used as the current weapon.
"Ammo(CWeapon,0)" is the amount of bullets
"Ammo(CWeapon,1)" is the number of clips

Login to post a reply

Server time is: 2024-09-24 07:33:44
Your offset time is: 2024-09-24 07:33:44