Advertisement
MrAlienBG

New Release

May 19th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.57 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #define pSave "Jail/%s.ini"
  4. forward PlayerInJail(playerid);
  5.  
  6. enum Info
  7. {
  8.         Jail,
  9.         JailTime
  10. }
  11. new Pnfo[MAX_PLAYERS][Info];
  12.  
  13. forward LoadStats(playerid,name[],value[]);
  14. public LoadStats(playerid,name[],value[])
  15. {
  16.     INI_Int("Jail", Pnfo[playerid][Jail]);
  17.     INI_Int("JailTime", Pnfo[playerid][JailTime]);
  18.     return 1;
  19. }
  20. public OnFilterScriptInit()
  21. {
  22.     SetTimer("PlayerInJail", 1000, true);
  23.     return 1;
  24. }
  25.  
  26. public PlayerInJail(playerid)
  27. {
  28.     for(new a = 0; a<MAX_PLAYERS; a ++)
  29.     {
  30.         if(Pnfo[a][Jail] == 1)
  31.         {  
  32.             if(Pnfo[a][JailTime] > 0)
  33.             {  
  34.             Pnfo[a][JailTime] -= 1;
  35.             }else{
  36.             Pnfo[a][Jail] = 0;
  37.             SpawnPlayer(playerid);
  38.             }
  39.         }
  40.     }
  41. return 1;
  42. }
  43. public OnPlayerConnect(playerid)
  44. {
  45.     INI_ParseFile(UserPath(playerid),"LoadStats",.bExtra = true, .extra = playerid);
  46.         return 1;
  47. }
  48.        
  49. public OnPlayerDisconnect(playerid, reason)
  50. {
  51.     new INI:File = INI_Open(UserPath(playerid));
  52.     INI_SetTag(File,"Stats");
  53.     INI_WriteInt(File, "Jail", Pnfo[playerid][Jail]);
  54.     INI_WriteInt(File, "JailTime", Pnfo[playerid][JailTime]);
  55.     INI_Close(File);
  56.  
  57.         return 1;
  58. }
  59.  
  60. public OnPlayerSpawn(playerid)
  61. {
  62.         if(Pnfo[playerid][Jail] == 1)
  63.         {
  64.         // send to jail function
  65.         }
  66.         return 1;
  67. }
  68. stock UserPath(playerid)
  69. {
  70.     new string[128],playername[MAX_PLAYER_NAME];
  71.     GetPlayerName(playerid,playername,sizeof(playername));
  72.     format(string,sizeof(string),pSave,playername);
  73.     return string;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement