I have a struct for weapons in my project. I'm initializing the first weapon:
Code:
WEAPONSTRUCT* glock = malloc(sizeof(WEAPONSTRUCT));
...
	weaponsList[0] = &glock;


and I'm trying to save the pointer to a skill of the player entity.
Code:
if( weaponsList[0] ) {
			player.weapon = weaponsList[0];
		}


Later, I'm trying to get the handle of that weapon in another function for shooting:
Code:
WEAPONSTRUCT* currentWeapon;
	while(me) {
		if( my.weapon ) {
			currentWeapon = my.weapon;
			if( currentWeapon ) {
				STRING* tmpstr1 = str_create("");
				str_for_num( tmpstr1 , currentWeapon.bullet_speed );
				draw_text( tmpstr1 , 10 , 10 , vector(255,255,255) );

...


weaponsList[10] is a var.
I tried with weaponsList being a WEAPONSTRUCT* but it didn't work also (assigning it to player.weapon as "&weaponsList[0]"

Can anyone tell me why its not working? I know I'm missing something in pointer knowledge, but I cant figure this out laugh

***EDIT***
Got it working by going back to weaponsList being a WEAPONSTRUCT* array and assigning the weaponsList[0] directly, without the reference operator & , it is automatically referenced/dereferenced by the engine, I guess?

Last edited by EpsiloN; 12/15/15 10:24.

Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201