#include <a_samp>
#include <YSI\y_ini>
enum ENUM_DATA { Score }
new
_pVars[ MAX_PLAYERS ][ ENUM_DATA ];
forward load_user_score( playerid, name[], value[] );
public load_user_score( playerid, name[], value[] )
{
INI_Int( "Score", _pVars[ playerid ][ Score ] );
return 1;
}
stock USER_PATH(playerid)
{
new
_str[ 128 ],P_NAME[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, P_NAME, MAX_PLAYER_NAME );
format( _str, sizeof ( _str ), "%s.ini", P_NAME );
return _str;
}
public OnPlayerConnect( playerid )
{
_pVars[ playerid ][ Score ] = 0;
INI_ParseFile( USER_PATH ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid );
// I dont see the part where It says SetPlayerScore(playerid . I know its suppose to set the PLAYERS score // when he connects.
return ( true );
}
public OnPlayerDeath( playerid, killerid, reason )
{
if ( killerid != INVALID_PLAYER_ID )
{
SetPlayerScore( killerid, GetPlayerScore( killerid ) + 0 );
}
return ( true );
}
public OnPlayerDisconnect( playerid, reason )
{
new
INI:File = INI_Open( USER_PATH ( playerid ) );
INI_SetTag( File,"score" );
INI_WriteInt( File,"Score", GetPlayerScore( playerid ) );
INI_Close( File );
return ( true );
}
INI_ParseFile( USER_PATH ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid );
INI_ParseFile( USER_PATH ( playerid ), "load_user_%s", false, true, playerid );
stock USER_PATH(playerid)
{
new
_str[ 128 ],P_NAME[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, P_NAME, MAX_PLAYER_NAME );
format( _str, sizeof ( _str ), "%s.ini", P_NAME );
return _str;
}
public OnPlayerDisconnect( playerid, reason )
{
new INI:file = INI_Open( USER_PATH( playerid ) );
INI_WriteInt( file,"Score", GetPlayerScore( playerid ) );
INI_Close( file );
return ( true );
}
stock USER_PATH( playerid )
{
new _str[ 128 ], P_NAME[ MAX_PLAYER_NAME + 1 ];
GetPlayerName( playerid, P_NAME, sizeof P_NAME );
format( _str, sizeof _str, "%s.ini", P_NAME );
return _str;
}
DUDE IM LOOKING FOR IT TO SAVE SCORE , THAT DOESNT EVEN SAVE SCORE MAN!!! I REALLY NEED HELP ON THIS
|
INI_ParseFile(playerfile, "load_user", .bExtra = true, .extra = playerid, .bPassTag = true);
forward load_user(playerid, name[ ], value[ ]);
public load_user(playerid, name[], value[])
{
INI_Int("Score", _pVars[ playerid ][ Score ]);
SetPlayerScore( playerid, _pVars[ playerid ][ Score ] );
return 1;
}