Advertisement
Guest User

Auto Score By Joker

a guest
Jul 31st, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.89 KB | None | 0 0
  1. //                                  Score Saving by Joker
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <dini>
  6. #include <foreach>
  7. #if defined FILTERSCRIPT
  8.  
  9. #define SAVE_SCORE true
  10.  
  11. #define SERVER_USER_FILE "Users/%s.ini"
  12. #include "../include/gl_common.inc"
  13. #if SAVE_SCORE == true
  14. enum pInfo
  15. {
  16.     pScore
  17. }
  18. #endif
  19. new PlayerInfo[MAX_PLAYERS][pInfo];
  20. public OnFilterScriptInit()
  21. {
  22.     print("\n--------------------------------------");
  23.     print(" Score Saving by Joker loaded");
  24.     print("--------------------------------------\n");
  25.     SetTimer("scoretimer", 60*1000, true);
  26.     return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31.     print("\n--------------------------------------");
  32.     print(" Score Saving by Joker unloaded");
  33.     print("--------------------------------------\n");
  34.     return 1;
  35. }
  36. public OnPlayerConnect(playerid)
  37. {
  38.      #if SAVE_SCORE == true
  39.     new name[MAX_PLAYER_NAME], file[256];
  40.     GetPlayerName(playerid, name, sizeof(name));
  41.     format(file, sizeof(file), SERVER_USER_FILE, name);
  42.     SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
  43.     if (!dini_Exists(file))
  44.     {
  45.         dini_Create(file);
  46.         dini_IntSet(file, "Score",SetPlayerScore(playerid,0));
  47.     }
  48.     if(fexist(file))
  49.     {
  50.         SetPlayerScore(playerid,dini_Int(file, "Score"));
  51.     }
  52.     #endif
  53.     return 1;
  54. }
  55.  
  56. public OnPlayerDisconnect(playerid, reason)
  57. {
  58.       #if SAVE_SCORE == true
  59.     new name[MAX_PLAYER_NAME], file[256];
  60.     GetPlayerName(playerid, name, sizeof(name));
  61.     format(file, sizeof(file), SERVER_USER_FILE, name);
  62.     dini_IntSet(file, "Score", GetPlayerScore(playerid));
  63.     #endif
  64.     return 1;
  65. }
  66. forward scoretimer();
  67. public scoretimer()
  68. {
  69.     foreach(Player,i)
  70.     {
  71.         if(IsPlayerConnected(i) == 1)
  72.             AddScoreForPlayer(i,1);
  73.     }
  74.     return 1;
  75. }
  76. #endif
  77.  
  78. stock AddScoreForPlayer(playerid,score)
  79. {
  80.   return SetPlayerScore(playerid,GetPlayerScore(playerid)+score);
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement