04.03.2012, 15:21
Hi,
is there a way to reset an array which has an enum with integer, float *AND* string fields?
Example code:
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:
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?
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];
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);

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?