After some hours i created this, but there are a problem, when i connect to the server and type /skata1 then as you can see Mitsos = 1 , but when i restart server its again 0, and i cant find the user file on scriptfiles (so file not exist) , how i can create the file, please guys some help...
PHP код:
native WP_Hash(_buffer[], len, const str[]);
enum USER_ENUM { Score, Deaths, Money, Mitsos }
new
userData[ MAX_PLAYERS ][ USER_ENUM ];
forward @load_user_statistics(playerid, name[], value[]);
@load_user_statistics(playerid, name[], value[])
{
INI_Int("Money", userData[ playerid ][ Money ]);
INI_Int("Mitsos", userData[ playerid ][ Mitsos ]);
INI_Int("Deaths", userData[ playerid ][ Deaths ]);
INI_Int("Score", userData[ playerid ][ Score ]);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
if( fexist ( user_account_path ( playerid ) ) )
{
SendClientMessage(playerid, COLOR_BLUE, "prwto einai");
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
}
else
SendClientMessage(playerid, COLOR_BLUE, "else mpike");
userData[ playerid ][ Mitsos ] = 0;
userData[ playerid ][ Money ] = 0;
userData[ playerid ][ Deaths ] = 0;
userData[ playerid ][ Score ] = 0;
new INI:File = INI_Open( user_account_path( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteInt(File, "Money", 0 );
INI_WriteInt(File, "Mitsos", 0 );
INI_WriteInt(File, "Deaths", 0 );
INI_WriteInt(File, "Score", 0 );
INI_Close(File);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open( user_account_path ( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteInt(File, "Money", GetPlayerMoney( playerid ) );
INI_WriteInt(File, "Mitsos", userData[ playerid ][ Mitsos ] );
INI_WriteInt(File, "Deaths", userData[ playerid ][ Deaths ] );
INI_WriteInt(File, "Score", GetPlayerScore( playerid ) );
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
//GivePlayerMoney( playerid, userData[ playerid ][ Money ] );
//SetPlayerScore( playerid, userData[ playerid ][ Score ] );
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/sta", cmdtext, true, 10) == 0)
{
new
sString[ 128 ],
mitsos = userData[ playerid ][ Mitsos ];
format ( sString, sizeof ( sString ), "Your stats are: MIT: %d", mitsos );
SendClientMessage( playerid, -1, sString );
return 1;
}
if (strcmp("/skata1", cmdtext, true) == 0)
{
userData[playerid][ Mitsos ] = 1;
return 1;
}
if (strcmp("/naf", cmdtext, true) == 0)
{
userData[playerid][ Mitsos ] = 0;
return 1;
}
return 0;
}
stock user_account_path(playerid)
{
new
string_path[ 128 ],
player_name[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, player_name, MAX_PLAYER_NAME );
format( string_path, sizeof ( string_path ), "%s.ini", player_name);
return
string_path;
}