Advertisement
Guest User

JailCommand

a guest
Aug 29th, 2010
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.06 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <Dini>
  5. #include <sscanf2>
  6. #include <zcmd>
  7.  
  8. new JailFile[64];
  9. new JailTimer[MAX_PLAYERS] = -1;
  10.  
  11. public OnFilterScriptInit()
  12. {
  13.     return 1;
  14. }
  15.  
  16. public OnFilterScriptExit()
  17. {
  18.     return 1;
  19. }
  20.  
  21. public OnPlayerConnect(playerid)
  22. {
  23.     return 1;
  24. }
  25.  
  26. public OnPlayerDisconnect(playerid, reason)
  27. {
  28.     if(JailTimer[playerid] != -1)
  29.     {
  30.         format(JailFile, sizeof(JailFile), "Jailed_ppl/%s.ini", GetName(playerid));
  31.         KillTimer(JailTimer[playerid]);
  32.         dini_Create(JailFile);
  33.     }
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerSpawn(playerid)
  38. {
  39.     format(JailFile, sizeof(JailFile), "Jailed_ppl/%s.ini", GetName(playerid));
  40.     if(dini_Exists(JailFile))
  41.     {
  42.         SendClientMessage(playerid, 0xffffffff, "You get +5 mins jail for disconnecting while in jail!");
  43.         //SetPlayerPos(playerid, x, y, z);          Jail Pos
  44.         JailTimer[playerid] = SetTimerEx("Unjail", 5*60*1000, 0, "d", playerid);//5 mins in the jail for DC
  45.         dini_Remove(JailFile);
  46.     }
  47.     return 1;
  48. }
  49.  
  50. CMD:jail(playerid, params[])
  51. {
  52.     new id, mins, str[128];
  53.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xffffffff, "You're not Admin!");
  54.     if(sscanf(params, "ud", id, mins)) return SendClientMessage(playerid, 0xffffffff, "[Usage]: /jail <id> <minutes>");
  55.     if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xffffffff, "Invalid player id.");
  56.     //SetPlayerPos(id, x, y, z);        Jail Pos
  57.     JailTimer[id] = SetTimerEx("Unjail", mins*60*1000, 0, "d", id);
  58.     format(str, sizeof(str), "You jailed %s for %d mins.", GetName(id), mins);
  59.     SendClientMessage(playerid, 0xffffffff, str);
  60.     format(str, sizeof(str), "%s jailed you for %d mins.", GetName(playerid), mins);
  61.     SendClientMessage(id, 0xffffffff, str);
  62.     return 1;
  63. }
  64.  
  65. forward Unjail(playerid);
  66. public Unjail(playerid)
  67. {
  68.     SendClientMessage(playerid, 0xffffffff, "You're free!");
  69.     //SetPlayerPos(playerid, x, y, z);      Out of Jail Pos
  70.     JailTimer[playerid] = -1;
  71. }
  72.  
  73. stock GetName(playerid)
  74. {
  75.     new name[24];
  76.     GetPlayerName(playerid, name, 24);
  77.     return name;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement