28.01.2015, 03:49
Hi guys. Here's my first tutorial that will show you simple way to reset variable that creates with enum.
First, the way we usually do is:
looks like this.
But, there is a simple way to do this. In pawno, when you create a variable, it resets themselves as a 0(integer) or false(boolean). So the 'simple way' is:
This. What we just did was simply copy value of tmp(which is 0 or false) to ply_Data[playerid]. Simple, isn't it?
But you might want to set the default value of single content of this variable. Then what you have to is just set the value of tmp.
Like this:
That's it
Thanks for watching my tutorial. See you
First, the way we usually do is:
Код:
enum E_PLAYER_DATA
{
ply_Password[129],
ply_Gender,
ply_Age
// ...
}
new ply_Data[MAX_PLAYERS][E_PLAYER_DATA];
// ...
public OnPlayerConnect(playerid)
{
ply_Data[playerid][Password][0] = EOS;
ply_Data[playerid][Gender] = 0;
ply_Data[playerid][Age] = 0;
// ...
return 1;
}
But, there is a simple way to do this. In pawno, when you create a variable, it resets themselves as a 0(integer) or false(boolean). So the 'simple way' is:
Код:
enum E_PLAYER_DATA
{
ply_Password[129],
ply_Gender,
ply_Age
// ...
}
new ply_Data[MAX_PLAYERS][E_PLAYER_DATA];
// ...
public OnPlayerConnect(playerid)
{
new tmp[E_PLAYER_DATA];
ply_Data[playerid] = tmp;
return 1;
}
But you might want to set the default value of single content of this variable. Then what you have to is just set the value of tmp.
Like this:
Код:
enum E_PLAYER_DATA
{
ply_Password[129],
ply_Gender,
ply_Age,
ply_Admin // default is -1
// ...
}
new ply_Data[MAX_PLAYERS][E_PLAYER_DATA];
// ...
public OnPlayerConnect(playerid)
{
new tmp[E_PLAYER_DATA];
tmp[ply_Data] = -1; // got it!
ply_Data[playerid] = tmp;
return 1;
}
Thanks for watching my tutorial. See you

