SA-MP Forums Archive
save help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: save help (/showthread.php?tid=534460)



save help - jimis - 29.08.2014

Hi guys , i want to save something on a player name file. I mean that : when someone is in jail then i will set injail == 1
but when he recconnect he will still have injail == 1, how i can save that to file with name of player??

its really important for me that command , please someone could help?? thanks


Re: save help - Pottus - 29.08.2014

Really depends on your user system your going to have ini, sqlite or mysql you will need to update your script accordingly.


Re: save help - Clad - 29.08.2014

Lack of informations, We can't help, You must provide some detailed informations so we can get really your issues.


Re: save help - jimis - 29.08.2014

if i use ini, how i can make it??


Re: save help - Clad - 29.08.2014

https://sampforum.blast.hk/showthread.php?tid=244223


Re: save help - jimis - 30.08.2014

i read the tutorial, but its the first i try to make a simply save system, so may someone make an example for me, , when get in police team then inpolice == 1 , and save that on a file with player name, and when player connect again to server then load inpolice == 1, pls i will give rep


Re: save help - jimis - 30.08.2014

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;
} 



Re: save help - [SU]Spartan - 31.08.2014

Just make a timer that will save players stats every second.


Re: save help - Barnwell - 31.08.2014

create a new folder logs will save player stats


Re: save help - jimis - 02.09.2014

Quote:
Originally Posted by Barnwell
Посмотреть сообщение
create a new folder logs will save player stats
I did that . now its create a text with player name and when I type /skata1 its make mitsos = 1 and when I disconnect its saved on on text. BUT when I connect again to the server it make again mitsos = 0 whitout typing nothing. please some help. something wrong on player connect