Advertisement
Guest User

Untitled

a guest
Jun 4th, 2010
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.54 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  4. new Float:JailCellSpawns[][3] =
  5. {
  6.     {197.3941,162.4637,1003.0300},
  7.     {194.3641,175.6378,1003.0234},
  8.     {197.8117,174.2043,1003.0234}
  9. };
  10.  
  11. forward UnJail(playerid);
  12.  
  13. new InJail[MAX_PLAYERS];
  14.  
  15. public OnFilterScriptInit()
  16. {
  17.     print("\n--------------------------------------");
  18.     print(" Jail System by: KAR!");
  19.     print("--------------------------------------\n");
  20.     return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25.     return 1;
  26. }
  27. public OnPlayerSpawn(playerid)
  28. {
  29.     SetPlayerVirtualWorld(playerid, 0);
  30.     SetPlayerInterior(playerid, 0);
  31.     if(InJail[playerid] == 1)
  32.     {
  33.         new rand = random(sizeof(JailCellSpawns));
  34.         SetPlayerPos(playerid, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
  35.         SendClientMessage(playerid, 0xFF0000AA, "Dying Wont Evade You From Escaping Out Of Jail!");
  36.         return 1;
  37.     }
  38.     return 1;
  39. }
  40. public OnPlayerConnect(playerid)
  41. {
  42.     InJail[playerid] = 0;
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerDeath(playerid, killerid, reason)
  47. {
  48.     return 1;
  49. }
  50.  
  51. public OnPlayerCommandText(playerid, cmdtext[])
  52. {
  53.     dcmd(tk,2,cmdtext);
  54.     dcmd(ticket,6,cmdtext);
  55.     dcmd(ar,2,cmdtext);
  56.     dcmd(jail,4,cmdtext);
  57.     dcmd(arrest,6,cmdtext);
  58.     dcmd(copcmds,7,cmdtext);
  59.     if (InJail[playerid] == 1)
  60.     {
  61.         SendClientMessage(playerid, 0xFF0000AA, "Your Commands Have been Disabled While In Jail!");
  62.         return 0;
  63.     }
  64.     return 0;
  65. }
  66.  
  67.  
  68. public UnJail(playerid)
  69. {
  70.     SpawnPlayer(playerid);
  71.     SendClientMessage(playerid, 0xFF0000AA, "You Have Been Released From Jail!");
  72.     InJail[playerid] = 0;
  73.     return 1;
  74. }
  75.  
  76. dcmd_tk(playerid,params[])
  77. {
  78.     new pskin = GetPlayerSkin(playerid);
  79.     if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)
  80.     {
  81.         if(sscanf(params, "d", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /tk [ID]");
  82.         else if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
  83.         else
  84.         {
  85.                     new Float:x, Float:y, Float:z;
  86.                     GetPlayerPos(playerid, x, y, z);
  87.                     if(IsPlayerInRangeOfPoint(playerid, 12.0, x, y, z))
  88.                     {
  89.                         new pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250];
  90.                         GetPlayerName(playerid, pname, sizeof(pname));
  91.                         GetPlayerName(playerid, aname, sizeof(aname));
  92.                         if (GetPlayerWantedLevel(playerid) == 0)
  93.                         {
  94.                             SendClientMessage(playerid, 0xFF0000AA, "This Player Is Not Wanted!");
  95.                             return 1;
  96.                         }
  97.  
  98.                         else if (GetPlayerWantedLevel(playerid) == 1)
  99.                         {
  100.                             SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
  101.                             new rmoney = random(1000);
  102.                             rmoney = rmoney + 500;
  103.                             format(string1, sizeof(string1), "%s Have Been Fined %d Because You Were Just Ticketed!", aname, playerid, pname, playerid);
  104.                             SendClientMessage(playerid,0xFF0000AA, string1);
  105.                             SetPlayerWantedLevel(playerid, 0);
  106.                             format(string1, sizeof(string1), "%s Have Been Fined %d Because You Were Just Ticketed!", aname, playerid, rmoney);//<--- prob want rmoney here too
  107.                             SendClientMessage(playerid,0xFF0000AA, string1);
  108.                             return 1;
  109.                         }
  110.                         else if (GetPlayerWantedLevel(playerid) > 1)
  111.                         {
  112.                             SendClientMessage(playerid, 0xFF0000AA, "Error: this player has to be arrested use /ar");
  113.                             return 1;
  114.                         }
  115.                     }
  116.                 }
  117.             }
  118.             else
  119.             {
  120.                 return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not a police officer!");
  121.             }
  122.     return 1;
  123. }
  124.  
  125. dcmd_ticket(playerid,params[])
  126. {
  127.     return dcmd_tk(playerid, params);
  128. }
  129.  
  130. dcmd_ar(playerid,params[])
  131. {
  132.     new pskin = GetPlayerSkin(playerid);
  133.     if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)
  134.     {
  135.         if(sscanf(params, "d", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /ar [ID]");
  136.             else if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
  137.                 else
  138.                 {
  139.                     new Float:x, Float:y, Float:z;
  140.                     GetPlayerPos(playerid, x, y, z);
  141.                     if(IsPlayerInRangeOfPoint(playerid, 12.0, x, y, z))
  142.                     {
  143.                         new pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250], string2[256], string3[100], string4[100];
  144.                         GetPlayerName(playerid, pname, sizeof(pname));
  145.                         GetPlayerName(playerid, aname, sizeof(aname));
  146.                         if (GetPlayerWantedLevel(playerid) == 0)
  147.                         {
  148.                             SendClientMessage(playerid, 0xFF0000AA, "This Player Is Not Wanted!");
  149.                             return 1;
  150.                         }
  151.                         else if (GetPlayerWantedLevel(playerid) == 1)
  152.                         {
  153.                             SendClientMessage(playerid, 0xFF0000AA, "Error: this player has to high of a wanted level use /tk");
  154.                             return 1;
  155.                         }
  156.                         else if (GetPlayerWantedLevel(playerid) > 1)
  157.                         {
  158.                             SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
  159.                             new WantedLevel = GetPlayerWantedLevel(playerid);
  160.                             SetPlayerInterior(playerid, 3);
  161.                             new rand = random(sizeof(JailCellSpawns));
  162.                             SetPlayerPos(playerid, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
  163.                             SetTimerEx("UnJail",WantedLevel*1000*60,0,"i",playerid);
  164.                             InJail[playerid] = 1;
  165.                             GivePlayerMoney(playerid, -WantedLevel*1000);
  166.                             GivePlayerMoney(playerid, WantedLevel*1000);
  167.                             SetPlayerWantedLevel(playerid, 0);
  168.                             format(string1, sizeof(string1), "%s(%d) Has Been Arrested By Officer %s(%d)", aname, playerid, pname, playerid);
  169.                             SendClientMessageToAll(0xFF0000AA, string1);
  170.                             format(string2, sizeof(string2), "You Have Been Sent To Jail For %s Minuets For Having A Level %s Wanted Level!", WantedLevel, WantedLevel);
  171.                             SendClientMessage(playerid, 0xFF0000AA, string2);
  172.                             format(string3, sizeof(string3), "You Have Recieved A %s000 Bonus For Arresting A Level %s Suspect!", WantedLevel, WantedLevel);
  173.                             SendClientMessage(playerid, 0xFF0000AA, string3);
  174.                             format(string4, sizeof(string4), "You Have Payed A %s000 Penalty On Your Arrest For Having A %s Wanted Level!", WantedLevel, WantedLevel);
  175.                             SendClientMessage(playerid, 0xFF0000AA, string4);
  176.                             return 1;
  177.                         }
  178.                     }
  179.                 }
  180.    }
  181.             else
  182.             {
  183.                 return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not a police officer!");
  184.             }
  185.     return 1;
  186. }
  187.  
  188. dcmd_jail(playerid,params[])
  189. {
  190.     if(IsPlayerAdmin(playerid))
  191.     {
  192.         new time;
  193.         if(sscanf(params, "dds", playerid, time, params[3])) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /jail [ID] [time in minuets][reason]");
  194.             else if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
  195.                 else
  196.                 {
  197.                     SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
  198.                     new pname[MAX_PLAYER_NAME], jname[MAX_PLAYER_NAME], string1[250];
  199.                     GetPlayerName(playerid, pname, sizeof(pname));
  200.                     GetPlayerName(playerid, jname, sizeof(jname));
  201.                     SetPlayerInterior(playerid, 3);
  202.                     new rand = random(sizeof(JailCellSpawns));
  203.                     SetPlayerPos(playerid, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
  204.                     SetTimerEx("UnJail",time*1000*60,0,"i",playerid);
  205.                     InJail[playerid] = 1;
  206.                     SetPlayerWantedLevel(playerid, 0);
  207.                     format(string1, sizeof(string1), "%s(%d) Has Been Jailed By Admin %s(%d) For Reason: %s", jname, playerid, pname, playerid, params[3]);
  208.                     SendClientMessageToAll(0xFF0000AA, string1);
  209.                     return 1;
  210.                 }
  211.       }
  212.       else
  213.             {
  214.           return 0;
  215.             }
  216. }
  217.  
  218. dcmd_arrest(playerid,params[])
  219. {
  220.     return dcmd_tk(playerid, params);
  221. }
  222.  
  223. dcmd_copcmds(playerid,params[])
  224. {
  225.     #pragma unused params
  226.     new pskin = GetPlayerSkin(playerid);
  227.     if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)
  228.     {
  229.         SendClientMessage(playerid, 0xFF0000AA, "Current Cop Commands!");
  230.         SendClientMessage(playerid, 0xFF0000AA, "/arrest - /ar - /ticket - /tk");
  231.         SendClientMessage(playerid, 0xFF0000AA, "Admin Cop Commands!");
  232.         SendClientMessage(playerid, 0xFF0000AA, "/jail");
  233.         return 1;
  234.     }
  235.     else
  236.     {
  237.         return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not a police officer!");
  238.     }
  239. }
  240.  
  241. //!!!!!!!!!!!!!!!!!!!!!!!!!THIS MUST BE AT THE BOTTOM OF THE SCRIPT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  242.  
  243. //------------------[SSCANF]-------------------------------------
  244. stock sscanf(string[], format[], {Float,_}:...)
  245. {
  246.     #if defined isnull
  247.         if (isnull(string))
  248.     #else
  249.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  250.     #endif
  251.         {
  252.             return format[0];
  253.         }
  254.     #pragma tabsize 4
  255.     new
  256.         formatPos = 0,
  257.         stringPos = 0,
  258.         paramPos = 2,
  259.         paramCount = numargs(),
  260.         delim = ' ';
  261.     while (string[stringPos] && string[stringPos] <= ' ')
  262.     {
  263.         stringPos++;
  264.     }
  265.     while (paramPos < paramCount && string[stringPos])
  266.     {
  267.         switch (format[formatPos++])
  268.         {
  269.             case '\0':
  270.             {
  271.                 return 0;
  272.             }
  273.             case 'i', 'd':
  274.             {
  275.                 new
  276.                     neg = 1,
  277.                     num = 0,
  278.                     ch = string[stringPos];
  279.                 if (ch == '-')
  280.                 {
  281.                     neg = -1;
  282.                     ch = string[++stringPos];
  283.                 }
  284.                 do
  285.                 {
  286.                     stringPos++;
  287.                     if ('0' <= ch <= '9')
  288.                     {
  289.                         num = (num * 10) + (ch - '0');
  290.                     }
  291.                     else
  292.                     {
  293.                         return -1;
  294.                     }
  295.                 }
  296.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  297.                 setarg(paramPos, 0, num * neg);
  298.             }
  299.             case 'h', 'x':
  300.             {
  301.                 new
  302.                     num = 0,
  303.                     ch = string[stringPos];
  304.                 do
  305.                 {
  306.                     stringPos++;
  307.                     switch (ch)
  308.                     {
  309.                         case 'x', 'X':
  310.                         {
  311.                             num = 0;
  312.                             continue;
  313.                         }
  314.                         case '0' .. '9':
  315.                         {
  316.                             num = (num << 4) | (ch - '0');
  317.                         }
  318.                         case 'a' .. 'f':
  319.                         {
  320.                             num = (num << 4) | (ch - ('a' - 10));
  321.                         }
  322.                         case 'A' .. 'F':
  323.                         {
  324.                             num = (num << 4) | (ch - ('A' - 10));
  325.                         }
  326.                         default:
  327.                         {
  328.                             return -1;
  329.                         }
  330.                     }
  331.                 }
  332.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  333.                 setarg(paramPos, 0, num);
  334.             }
  335.             case 'c':
  336.             {
  337.                 setarg(paramPos, 0, string[stringPos++]);
  338.             }
  339.             case 'f':
  340.             {
  341.  
  342.                 new changestr[16], changepos = 0, strpos = stringPos;
  343.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  344.                 {
  345.                     changestr[changepos++] = string[strpos++];
  346.                     }
  347.                 changestr[changepos] = '\0';
  348.                 setarg(paramPos,0,_:floatstr(changestr));
  349.             }
  350.             case 'p':
  351.             {
  352.                 delim = format[formatPos++];
  353.                 continue;
  354.             }
  355.             case '\'':
  356.             {
  357.                 new
  358.                     end = formatPos - 1,
  359.                     ch;
  360.                 while ((ch = format[++end]) && ch != '\'') {}
  361.                 if (!ch)
  362.                 {
  363.                     return -1;
  364.                 }
  365.                 format[end] = '\0';
  366.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  367.                 {
  368.                     if (format[end + 1])
  369.                     {
  370.                         return -1;
  371.                     }
  372.                     return 0;
  373.                 }
  374.                 format[end] = '\'';
  375.                 stringPos = ch + (end - formatPos);
  376.                 formatPos = end + 1;
  377.             }
  378.             case 'u':
  379.             {
  380.                 new
  381.                     end = stringPos - 1,
  382.                     id = 0,
  383.                     bool:num = true,
  384.                     ch;
  385.                 while ((ch = string[++end]) && ch != delim)
  386.                 {
  387.                     if (num)
  388.                     {
  389.                         if ('0' <= ch <= '9')
  390.                         {
  391.                             id = (id * 10) + (ch - '0');
  392.                         }
  393.                         else
  394.                         {
  395.                             num = false;
  396.                         }
  397.                     }
  398.                 }
  399.                 if (num && IsPlayerConnected(id))
  400.                 {
  401.                     setarg(paramPos, 0, id);
  402.                 }
  403.                 else
  404.                 {
  405.                     #if !defined foreach
  406.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  407.                         #define __SSCANF_FOREACH__
  408.                     #endif
  409.                     string[end] = '\0';
  410.                     num = false;
  411.                     new
  412.                         name[MAX_PLAYER_NAME];
  413.                     id = end - stringPos;
  414.                     foreach (Player, playerid)
  415.                     {
  416.                         GetPlayerName(playerid, name, sizeof (name));
  417.                         if (!strcmp(name, string[stringPos], true, id))
  418.                         {
  419.                             setarg(paramPos, 0, playerid);
  420.                             num = true;
  421.                             break;
  422.                         }
  423.                     }
  424.                     if (!num)
  425.                     {
  426.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  427.                     }
  428.                     string[end] = ch;
  429.                     #if defined __SSCANF_FOREACH__
  430.                         #undef foreach
  431.                         #undef __SSCANF_FOREACH__
  432.                     #endif
  433.                 }
  434.                 stringPos = end;
  435.             }
  436.             case 's', 'z':
  437.             {
  438.                 new
  439.                     i = 0,
  440.                     ch;
  441.                 if (format[formatPos])
  442.                 {
  443.                     while ((ch = string[stringPos++]) && ch != delim)
  444.                     {
  445.                         setarg(paramPos, i++, ch);
  446.                     }
  447.                     if (!i)
  448.                     {
  449.                         return -1;
  450.                     }
  451.                 }
  452.                 else
  453.                 {
  454.                     while ((ch = string[stringPos++]))
  455.                     {
  456.                         setarg(paramPos, i++, ch);
  457.                     }
  458.                 }
  459.                 stringPos--;
  460.                 setarg(paramPos, i, '\0');
  461.             }
  462.             default:
  463.             {
  464.                 continue;
  465.             }
  466.         }
  467.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  468.         {
  469.             stringPos++;
  470.         }
  471.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  472.         {
  473.             stringPos++;
  474.         }
  475.         paramPos++;
  476.     }
  477.     do
  478.     {
  479.         if ((delim = format[formatPos++]) > ' ')
  480.         {
  481.             if (delim == '\'')
  482.             {
  483.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  484.             }
  485.             else if (delim != 'z')
  486.             {
  487.                 return delim;
  488.             }
  489.         }
  490.     }
  491.     while (delim > ' ');
  492.     return 0;
  493. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement