Reset structured array with integer/float/string fields
#1

Hi,

is there a way to reset an array which has an enum with integer, float *AND* string fields?

Example code:
Код:
enum myStructure
{
	myVar1,
	myVar2,
	Float:myVar3,
	Float:myVar4,
	myVar5[10],
	myVar6[100],
	myVar7[100]
}

myArray[MAX_PLAYERS][myStructure];
For example I set myVar1 to some player specific value (i.e. UserID read from database).
Then if the player disconnects I want to reset *ALL* variables in this array of the player so the next player starts with an "empty" array.

Another example: I set another player specific string to myVar5 and want to reset this variable in OnPlayerDisconnect.


I know I could do it using something like that:
Код:
myArray[playerID][myVar1] = 0;
myArray[playerID][myVar2] = 0;
myArray[playerID][myVar3] = 0.0;
myArray[playerID][myVar4] = 0.0;
strdel(myArray[playerID][myVar5], 0, 10);
strdel(myArray[playerID][myVar6], 0, 100);
strdel(myArray[playerID][myVar7], 0, 100);
But that's not the way I want to write my code.

Is there a way to reset the array using a loop?

Next problem: myVar2 my contains the playerID of another player which can be 0. How to check whether the variable is set (i.e. is 0 or any other number) or not?
Reply


Messages In This Thread
Reset structured array with integer/float/string fields - by Programie - 04.03.2012, 15:21
Re: Reset structured array with integer/float/string fields - by T0pAz - 04.03.2012, 15:33
Re: Reset structured array with integer/float/string fields - by Zeex_ - 04.03.2012, 15:48
Re: Reset structured array with integer/float/string fields - by T0pAz - 04.03.2012, 15:52
Re: Reset structured array with integer/float/string fields - by Programie - 04.03.2012, 16:01
Re: Reset structured array with integer/float/string fields - by Jefff - 04.03.2012, 22:50
Re: Reset structured array with integer/float/string fields - by Programie - 05.03.2012, 00:02

Forum Jump:


Users browsing this thread: 1 Guest(s)