SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/11/2019, 12:11 AM   #1
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Help saving system

Pls someone can help me to make this saving system working https://pastebin.com/w2hSid1r
I dont have any error on gm but it doesent work i think i have to add/change something.
Thx for everyone will try help!
davide1999 is offline   Reply With Quote
Old 14/11/2019, 06:13 AM   #2
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,859
Reputation: 1571
Default Re: Help saving system

How do you stop the server? If you close the server application it might not call OnGameModeExit: https://wiki.sa-mp.com/wiki/OnGameModeExit
In particular the following part: "This callback will NOT be called if the server crashes or the process is killed by other means, such as using the Linux kill command or pressing the close-button on the Windows console."

What you could try is adding the below in your OnGameModeExit callback (just like it does in the wiki example).
Code:
print("Gamemode ended.");
Then verify that that string is in the server logs. If it is, then there is indeed a different problem. If it isn't, then OnGameModeExit simply isn't called and you'd need to shut the server down by issuing the exit command (either in game or through the console).
Jstylezzz is offline   Reply With Quote
Old 14/11/2019, 12:02 PM   #3
WalkZ
Big Clucker
 
WalkZ's Avatar
 
Join Date: Oct 2019
Location: Pakistan
Posts: 103
Reputation: 4
Default Re: Help saving system

You didn't parse INI file, It should work now.

PHP Code:
#define PATHa "Gangpoints/%s.ini"
enum gInfo
{
    
gGP1,
    
gGP2,
    
gGP3
}
new 
GangInfo[gInfo];
forward Loadgp_data(name[],value[]);
public 
Loadgp_data(name[],value[])
{
    
INI_Int("gang1gp",GangInfo[gGP1]);
    
INI_Int("gang2gp",GangInfo[gGP2]);
    
INI_Int("gang3gp",GangInfo[gGP3]);
    return 
1;
}

public 
OnGameModeInit()
{
   
INI_ParseFile(PATHa"Loadgp_data", .bExtra false); // Here we loading the file
   
return 1;
}

 
public 
OnGameModeExit()
{
    new 
INI:myFile INI_Open(PATHa); 
    
INI_SetTag(myFile,"tag1");
    
INI_WriteInt(myFile,"gang1gp",GangInfo[gGP1]);
    
INI_WriteInt(myFile,"gang2gp",GangInfo[gGP2]);
    
INI_WriteInt(myFile,"gang3gp",GangInfo[gGP3]);
    
INI_Close(myFile);
    return 
1//INI_Int("gang1gp",GangInfo[gGP1]);

__________________
[EN] Chinatown Freeroam [BETA]
- Different Advanced Deathmatches with Times and Scores
- Different Races
- Different Events
- Gangs (Groves, Ballas, Aztecas, Mafia, Bikers & Triads)
- Drugs with Drug Dealers at Streets
- Hitman Bounty System
- Ammunations, Pizza Stacks, Burger-Shots, Banks
- Jobs (Pizza-Boy, Plumber, Trasher, Bus)
- Money-Bag every 30 minutes
- Reaction Test every 15 minutes
- Daily improving by adding new features and fixing present bugs.
WalkZ is offline   Reply With Quote
Old 14/11/2019, 10:02 PM   #4
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help saving system

Quote:
Originally Posted by WalkZ View Post
You didn't parse INI file, It should work now.

PHP Code:
#define PATHa "Gangpoints/%s.ini"
enum gInfo
{
    
gGP1,
    
gGP2,
    
gGP3
}
new 
GangInfo[gInfo];
forward Loadgp_data(name[],value[]);
public 
Loadgp_data(name[],value[])
{
    
INI_Int("gang1gp",GangInfo[gGP1]);
    
INI_Int("gang2gp",GangInfo[gGP2]);
    
INI_Int("gang3gp",GangInfo[gGP3]);
    return 
1;
}

public 
OnGameModeInit()
{
   
INI_ParseFile(PATHa"Loadgp_data", .bExtra false); // Here we loading the file
   
return 1;
}

 
public 
OnGameModeExit()
{
    new 
INI:myFile INI_Open(PATHa); 
    
INI_SetTag(myFile,"tag1");
    
INI_WriteInt(myFile,"gang1gp",GangInfo[gGP1]);
    
INI_WriteInt(myFile,"gang2gp",GangInfo[gGP2]);
    
INI_WriteInt(myFile,"gang3gp",GangInfo[gGP3]);
    
INI_Close(myFile);
    return 
1//INI_Int("gang1gp",GangInfo[gGP1]);

I think it doesent save, i added this codes for try to see if it save every time i use this comand it need will be +1 but its always 0 on scriptfiles
CMD:gang1(playerid,params[])
{
GangInfo[gGP1]++;
return 1;
}
CMD:gang2(playerid,params[])
{
GangInfo[gGP2]++;
return 1;
}
CMD:gang3(playerid,params[])
{
GangInfo[gGP3]++;
return 1;
}
davide1999 is offline   Reply With Quote
Old 15/11/2019, 08:55 AM   #5
WalkZ
Big Clucker
 
WalkZ's Avatar
 
Join Date: Oct 2019
Location: Pakistan
Posts: 103
Reputation: 4
Default Re: Help saving system

If you are restarting your server through your host console panel then your data will not save under OnGamemodeExit, try login in RCON and type /rcon gmx and check if your data saves.
__________________
[EN] Chinatown Freeroam [BETA]
- Different Advanced Deathmatches with Times and Scores
- Different Races
- Different Events
- Gangs (Groves, Ballas, Aztecas, Mafia, Bikers & Triads)
- Drugs with Drug Dealers at Streets
- Hitman Bounty System
- Ammunations, Pizza Stacks, Burger-Shots, Banks
- Jobs (Pizza-Boy, Plumber, Trasher, Bus)
- Money-Bag every 30 minutes
- Reaction Test every 15 minutes
- Daily improving by adding new features and fixing present bugs.
WalkZ is offline   Reply With Quote
Old 15/11/2019, 08:24 PM   #6
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help saving system

Quote:
Originally Posted by WalkZ View Post
If you are restarting your server through your host console panel then your data will not save under OnGamemodeExit, try login in RCON and type /rcon gmx and check if your data saves.
i put this codes under onplayerdisconnect so it must be save every times some one disconect from server but it doesent save value on scriptfiles are always 0

new INI:myFile = INI_Open(PATHa);
INI_SetTag(myFile,"tag1");
INI_WriteInt(myFile,"gang1gp",GangInfo[gGP1]);
INI_WriteInt(myFile,"gang2gp",GangInfo[gGP2]);
INI_WriteInt(myFile,"gang3gp",GangInfo[gGP3]);
INI_Close(myFile);

I put this under OnPlayerDisconnect
davide1999 is offline   Reply With Quote
Old 15/11/2019, 08:47 PM   #7
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help saving system

Quote:
Originally Posted by davide1999 View Post
i put this codes under onplayerdisconnect so it must be save every times some one disconect from server but it doesent save value on scriptfiles are always 0

new INI:myFile = INI_Open(PATHa);
INI_SetTag(myFile,"tag1");
INI_WriteInt(myFile,"gang1gp",GangInfo[gGP1]);
INI_WriteInt(myFile,"gang2gp",GangInfo[gGP2]);
INI_WriteInt(myFile,"gang3gp",GangInfo[gGP3]);
INI_Close(myFile);

I put this under OnPlayerDisconnect
When i disconnect on server log i got this error:
*** YSI Error: INI_Open could not find or create file Gangpoints/%s.ini
But on scriptfiles i have file.ini Gangpoints.ini
davide1999 is offline   Reply With Quote
Old 15/11/2019, 08:56 PM   #8
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 755
Reputation: 147
Default Re: Help saving system

Create Gangpoints folder in scriptfiles.
Calisthenics is offline   Reply With Quote
Old 15/11/2019, 08:59 PM   #9
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help saving system

Quote:
Originally Posted by Calisthenics View Post
Create Gangpoints folder in scriptfiles.
I create Gangpoints folder and put inside Gangpoints.ini so?
davide1999 is offline   Reply With Quote
Old 15/11/2019, 09:03 PM   #10
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help saving system

Solved it work thx you very much!
davide1999 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Simple Toy System + Saving with DINI. (saving only 1 slot) PaulDinam Filterscripts 24 20/11/2018 02:36 PM
Converting MYSQL Saving Codes into .INI Saving System codes ???? PURG3D Scripting Help 6 14/04/2015 11:49 PM
MySQL saving system to DJSON saving system TonyNames Scripting Help 4 21/01/2014 07:27 PM
New saving system and still not saving score/money Karl[NDZ] Scripting Help 16 12/09/2013 07:55 AM
[FilterScript] DWS - Dynamic Weapon System (Gun object, Saving system,...More) JusstinRoller Filterscripts 15 31/07/2013 11:02 AM


All times are GMT. The time now is 02:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.