Field Declared As A Function -1 reply

Please wait...

Guest

I didn't make it!

0 XP

 
#1 9 years ago

I'm trying to set up a reload system, based on the example over at Code3Arena, but I've hit upon a problem:

In g_local.h under struct gclient_s I have:

void Cmd_Reload( gentity_t *ent ); int ClipAmmo( int w );

Upon building I get an error stating that these fields are being declared as functions... They're supposed to be functions, what exactly is the problem here? The functions themselves are already in place in g_cmds.c, and everything appears as though it should work. Can anyone explain why I'm getting this error?




Xycaleth

Resident programmer guy

50 XP

3rd May 2016

1 Uploads

86 Posts

0 Threads

#2 9 years ago

I'm gonna guess you're following this tutorial: Code3Arena

In which case, I'm also gonna guess you have something like this in your g_local.h file: // Our Ammo Variable, ps.ammo, now refers to Bag Ammo int clipammo[MAX_WEAPONS];

// timeResidual is used to handle events that happen every second // like health / armor countdowns and regeneration int timeResidual;

void Cmd_Reload( gentity_t *ent ); int ClipAmountForWeapon( int w ); };You'll notice in the example code, the }; comes before the two functions, so it should be: // Our Ammo Variable, ps.ammo, now refers to Bag Ammo int clipammo[MAX_WEAPONS];

// timeResidual is used to handle events that happen every second // like health / armor countdowns and regeneration int timeResidual; };

void Cmd_Reload( gentity_t *ent ); int ClipAmountForWeapon( int w ); Hope that helps :)




Raz0r

Worse than most terrible

50 XP

27th September 2006

0 Uploads

6,737 Posts

0 Threads

#3 9 years ago

I've successfully implemented reloading, so if you get stuck, just give us a shout. Also, I might invite you to join the 'JA Coders' staff before we launch o.o' Interested?




Guest

I didn't make it!

0 XP

 
#4 9 years ago

Through a combination of reading what Xycaleth posted above and talking to BobaFett, I've got a version which compile, at least. Now I just need to work out why my reload command is only semi-funcitional.

Razor, if you wish you invite me to "JA Coders", that would be fine with me, although I'm far from the most knowledgeable on the subject.