Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Score Saving by Joker
- #define FILTERSCRIPT
- #include <a_samp>
- #include <dini>
- #include <foreach>
- #if defined FILTERSCRIPT
- #define SAVE_SCORE true
- #define SERVER_USER_FILE "Users/%s.ini"
- #include "../include/gl_common.inc"
- #if SAVE_SCORE == true
- enum pInfo
- {
- pScore
- }
- #endif
- new PlayerInfo[MAX_PLAYERS][pInfo];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Score Saving by Joker loaded");
- print("--------------------------------------\n");
- SetTimer("scoretimer", 60*1000, true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" Score Saving by Joker unloaded");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- #if SAVE_SCORE == true
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
- if (!dini_Exists(file))
- {
- dini_Create(file);
- dini_IntSet(file, "Score",SetPlayerScore(playerid,0));
- }
- if(fexist(file))
- {
- SetPlayerScore(playerid,dini_Int(file, "Score"));
- }
- #endif
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- #if SAVE_SCORE == true
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- dini_IntSet(file, "Score", GetPlayerScore(playerid));
- #endif
- return 1;
- }
- forward scoretimer();
- public scoretimer()
- {
- foreach(Player,i)
- {
- if(IsPlayerConnected(i) == 1)
- AddScoreForPlayer(i,1);
- }
- return 1;
- }
- #endif
- stock AddScoreForPlayer(playerid,score)
- {
- return SetPlayerScore(playerid,GetPlayerScore(playerid)+score);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement