save help
#1

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
Reply
#2

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

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

if i use ini, how i can make it??
Reply
#5

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

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
Reply
#7

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 ScoreDeathsMoneyMitsos }
new
    
userDataMAX_PLAYERS ][ USER_ENUM ];
forward @load_user_statistics(playeridname[], value[]);
@
load_user_statistics(playeridname[], value[])
{
    
INI_Int("Money"userDataplayerid ][ Money ]);
    
INI_Int("Mitsos"userDataplayerid ][ Mitsos ]);
    
INI_Int("Deaths"userDataplayerid ][ Deaths ]);
    
INI_Int("Score"userDataplayerid ][ Score ]);
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
        if( 
fexist user_account_path playerid ) ) )
        {
            
SendClientMessage(playeridCOLOR_BLUE"prwto einai");
            
INI_ParseFile(user_account_path playerid ), "load_user_%s", .bExtra true, .extra playerid);
        }
        else
        
SendClientMessage(playeridCOLOR_BLUE"else mpike");
        
userDataplayerid ][ Mitsos ] = 0;
        
userDataplayerid ][ Money ] = 0;
        
userDataplayerid ][ Deaths ] = 0;
        
userDataplayerid ][ Score ] = 0;
        new 
INI:File INI_Openuser_account_pathplayerid ) );
        
INI_SetTag(File"statistics" );
        
INI_WriteInt(File"Money");
        
INI_WriteInt(File"Mitsos");
        
INI_WriteInt(File"Deaths");
        
INI_WriteInt(File"Score");
        
INI_Close(File);
        return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
     new 
INI:File INI_Openuser_account_path playerid ) );
    
INI_SetTag(File"statistics" );
    
INI_WriteInt(File"Money"GetPlayerMoneyplayerid ) );
    
INI_WriteInt(File"Mitsos"userDataplayerid ][ Mitsos ] );
    
INI_WriteInt(File"Deaths"userDataplayerid ][ Deaths ] );
    
INI_WriteInt(File"Score"GetPlayerScoreplayerid ) );
    
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(playeridcmdtext[])
{
    if (
strcmp("/sta"cmdtexttrue10) == 0)
    {
         new
           
sString128 ],
           
mitsos userDataplayerid ][ Mitsos ];
         
format (  sStringsizeof sString ), "Your stats are: MIT: %d"mitsos );
         
SendClientMessageplayerid, -1sString );
         return 
1;
}
    if (
strcmp("/skata1"cmdtexttrue) == 0)
     {
                 
                  
userData[playerid][ Mitsos ] = 1;
                return 
1;
}
    if (
strcmp("/naf"cmdtexttrue) == 0)
     {
                 
                  
userData[playerid][ Mitsos ] = 0;
                return 
1;
}
    return 
0;
}
stock user_account_path(playerid)
{
    new
        
string_path128 ],
        
player_nameMAX_PLAYER_NAME ];
    
GetPlayerNameplayeridplayer_nameMAX_PLAYER_NAME );
    
formatstring_pathsizeof string_path ), "%s.ini"player_name);
    return
        
string_path;

Reply
#8

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

create a new folder logs will save player stats
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)