Advertisement
Guest User

Bounty System

a guest
Jun 17th, 2014
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.94 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <streamer>
  4. #include <YSI\y_commands>
  5. #include <sscanf2>
  6.  
  7. new personalbountys = 0;
  8. new defaultbounty = 50000;
  9.  
  10.  
  11. stock GetPlayersName(playerid)
  12. {
  13.     new name[MAX_PLAYER_NAME];
  14.     GetPlayerName(playerid,name,sizeof(name));
  15.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  16.     {
  17.         if(name[i] == '_') name[i] = ' ';
  18.     }
  19.     return name;
  20. }
  21.  
  22. stock ConvertPrice(price)
  23. {
  24.     new pricestring[32];
  25.     new j = valstr(pricestring,price);
  26.     while(j >= 4) { j -= 3; strins(pricestring,",",j); }
  27.     strins(pricestring,"$",0);
  28.     return pricestring;
  29. }
  30.  
  31.  
  32.  
  33. public OnFilterScriptInit()
  34. {
  35.     print("#################################################################");
  36.     print("||         Simple Bounty system by Jack Leslie - 2014          ||");
  37.     print("#################################################################");
  38.     return 1;
  39. }
  40.  
  41. public OnFilterScriptExit()
  42. {
  43.     print("Simple Bounty system by Jack Leslie closed - thanks for using me!");
  44.     return 1;
  45. }
  46.  
  47.  
  48. public OnPlayerConnect(playerid)
  49. {
  50.     SetPVarInt(playerid, "BountyOnHead", 0);
  51.     SetPVarInt(playerid, "BountyAmount", 0);
  52.     SetPVarString(playerid, "BountySetBy", "No one");
  53.     return 1;
  54. }
  55.  
  56. public OnPlayerDisconnect(playerid, reason)
  57. {
  58.     return 1;
  59. }
  60.  
  61. public OnPlayerDeath(playerid, killerid, reason)
  62. {
  63.     new string[126];
  64.     if(killerid != INVALID_PLAYER_ID)
  65.     {
  66.         if(GetPVarInt(playerid, "BountyOnHead") == 1)
  67.         {
  68.             new bountyamount = GetPVarInt(playerid, "BountyAmount");
  69.             SetPVarInt(playerid, "BountyOnHead", 0);
  70.             SetPVarInt(playerid, "BountyAmount", 0);
  71.             SetPVarString(playerid, "BountySetBy", "No one");
  72.             format(string, sizeof(string), "Bounty Information:{FFFFFF} %s just killed %s for a bounty total of: %s", GetPlayersName(killerid), GetPlayersName(playerid), ConvertPrice(bountyamount));
  73.             SendClientMessageToAll(0xFF0000C8, string);
  74.             GivePlayerMoney(killerid, bountyamount);
  75.             SetPlayerColor(playerid, 0xFFFFFF00);
  76.         }
  77.     }
  78.     return 1;
  79. }
  80.  
  81. public OnPlayerUpdate(playerid)
  82. {
  83.     new string[126];
  84.     if(GetPVarInt(playerid, "BountyOnHead") == 0) {
  85.         if(GetPlayerWantedLevel(playerid) > 5)
  86.         {
  87.             SetPVarInt(playerid, "BountyOnHead", 1);
  88.             SetPVarInt(playerid, "BountyAmount", defaultbounty);
  89.             SetPVarString(playerid, "BountySetBy", "Law Enforcement");
  90.             SetPlayerColor(playerid, 0xFF0000C8);
  91.             SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} Your wanted level has reached Six (6), there fore you have now got a bounty on your head. Watch out!");
  92.             format(string, sizeof(string), "Bounty Information:{FFFFFF} %s has been given an automatic bounty of %s, go collect your reward!", GetPlayersName(playerid), ConvertPrice(GetPVarInt(playerid, "BountyAmount")));
  93.             SendClientMessageToAll(0xFF0000C8, string);
  94.             return 1;
  95.         }
  96.     }
  97.     return 1;
  98. }
  99.  
  100. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  101. {
  102.     new string[126];
  103.     if(GetPVarInt(clickedplayerid, "BountyOnHead") == 1)
  104.     {
  105.         new clickedname[MAX_PLAYER_NAME+1];
  106.         format(string, sizeof(string), "Bounty Amount: %s\nSet By: %s", ConvertPrice(GetPVarInt(clickedplayerid, "BountyAmount")), GetPVarString(clickedplayerid, "BountySetBy", clickedname, MAX_PLAYER_NAME+1));
  107.         ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Bounty Information", string, "Okay", "");
  108.     }
  109.     return 1;
  110. }
  111.  
  112. CMD:setdefaultbounty(playerid, params[])
  113. {
  114.     new string[126];
  115.     if(IsPlayerAdmin(playerid))
  116.     {
  117.         new amount;
  118.         if(sscanf(params, "d", amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information: /setdefaultbounty [amount]");
  119.        
  120.         if(amount < 0) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information: A default bounty can not go below $0.");
  121.         defaultbounty = amount;
  122.         format(string, sizeof(string), "Bounty Information:{FFFFFF} The default bounty amount is now %s.", ConvertPrice(amount));
  123.         SendClientMessageToAll(0xFF0000C8, string);
  124.     }
  125.     return 1;
  126. }
  127.  
  128. CMD:personalbountys(playerid, params[])
  129. {
  130.     if(IsPlayerAdmin(playerid))
  131.     {
  132.         if(personalbountys == 0)
  133.         {
  134.             personalbountys = 1;
  135.             SendClientMessageToAll(0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are now enabled.");
  136.         }
  137.         else if(personalbountys == 1)
  138.         {
  139.             personalbountys = 0;
  140.             SendClientMessageToAll(0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are now disbaled.");
  141.         }
  142.     }
  143.     return 1;
  144. }
  145.  
  146. CMD:givebounty(playerid, params[])
  147. {
  148.     if(personalbountys == 0) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are currently disabled.");
  149.  
  150.     new target, amount, string[126];
  151.     if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");
  152.    
  153.     if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} You do not have that much money to place that bounty.");
  154.    
  155.     if(target == playerid) return SendClientMessage(playerid, 0xFFFFFF00, "Bounty Information:{FFFFFF} You can't set a bounty on your self.");
  156.    
  157.     if(GetPVarInt(target, "BountyOnHead") == 1) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} That player already has a bounty on them.");
  158.    
  159.     if(IsPlayerConnected(target))
  160.     {
  161.         format(string, sizeof(string), "Bounty Information:{FFFFFF} %s has just set a bounty on %s for the sum of %s!", GetPlayersName(playerid), GetPlayersName(target), ConvertPrice(amount));
  162.         SendClientMessageToAll(0xFF0000C8, string);
  163.        
  164.         SetPVarInt(target, "BountyOnHead", 1);
  165.         SetPVarInt(target, "BountyAmount", amount);
  166.         SetPVarString(target, "BountySetBy", GetPlayersName(playerid));
  167.         GivePlayerMoney(playerid, -amount);
  168.         SetPlayerColor(target, 0xFF0000C80);
  169.         return 1;
  170.     }
  171.     else if(!IsPlayerConnected(target))
  172.     {
  173.         SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} That player isn't connected.");
  174.     }
  175.     return 1;
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement