SHARE
TWEET

uScript - Bounty

a guest Jul 21st, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. minBounty = 1000; // Minimum Bounty That Can Be Placed
  2. bountyTextColor = "yellow";
  3. currencyName = "Gold";
  4.  
  5. // Creates The Necessary Table If It Does Not Already Exist
  6. event onLoad(){
  7.     database.execute("CREATE TABLE IF NOT EXISTS bountylist(victimid VARCHAR(17) PRIMARY KEY,placerid VARCHAR(17) NOT NULL,bountyAmount INT DEFAULT 0,timePlaced DATETIME NOT NULL);");
  8. }
  9.  
  10. // Pays Player Who Killed Other Player With Bounty And Removes The Bounty
  11. event onPlayerDeath(player, cause, murdererId){
  12.     if(murdererId == player.id){
  13.         return;
  14.     }
  15.     murderer = toPlayer(murdererId);
  16.     if(isPlayer(murderer) == false){
  17.         return;
  18.     }
  19.     bounty = getBounty(player.id);
  20.     if(bounty == false){
  21.         return;
  22.     }
  23.     bountyAmount = toInt(bounty[2]);
  24.     murderer.increaseBalance(bountyAmount);
  25.     broadcast(str.format("[Bounty] {0} Has Killed {1} And Received Their {2} {3} Bounty!", murderer.name, player.name, bountyAmount, currencyName), bountyTextColor);
  26.     database.execute(str.format("DELETE FROM bountylist WHERE victimid = '{0}';", player.id));
  27. }
  28.  
  29. // Command To Add A Bounty To A Player
  30. command bountyadd(arg1, arg2){
  31.     permission = array("bounty", "bountyadd");
  32.     execute(){
  33.         if(isSet(arg1) == false or isSet(arg2) == false){
  34.             player.message("[Bounty] Proper Usage: /bountyadd (player) (amount)", bountyTextColor);
  35.             return;
  36.         }
  37.         target = toPlayer(arg1);
  38.         if(isPlayer(target) == false){
  39.             player.message("[Bounty] Could Not Find That Player!", bountyTextColor);
  40.             return;
  41.         }
  42.         if(arg2 < minBounty or arg2 < 1){
  43.             player.message(str.format("[Bounty] Your Bounty Must Be Between 1 and {0} {1}!", minBounty, currencyName), bountyTextColor);
  44.             return;
  45.         }
  46.         if(player.balance < arg2){
  47.             player.message("[Bounty] You Can Not Afford A Bounty Of This Amount!", bountyTextColor);
  48.             return;
  49.         }
  50.         bounty = getBounty(target.id);
  51.         if(bounty != false){
  52.             database.execute(str.format("UPDATE bountylist SET bountyAmount = bountyAmount + {0} WHERE victimid = '{1}';", arg2, target.id));
  53.             bounty = getBounty(target.id);
  54.             broadcast(str.format("[Bounty] {0} Has Increased The Bounty On {1} To {2} {3}!", player.name, target.name, bounty[2], currencyName), bountyTextColor);
  55.             return;
  56.         }
  57.         player.decreaseBalance(arg2);
  58.         broadcast(str.format("[Bounty] {0} Has Placed A Bounty Of {1} {2} On {3}!", player.name, arg2, currencyName, target.name), bountyTextColor);
  59.         database.execute(str.format("INSERT INTO bountylist (victimid, placerid, bountyAmount, timePlaced) VALUES ('{0}', '{1}', {2}, CURRENT_TIMESTAMP);", target.id, player.id, arg2));
  60.     }
  61. }
  62.  
  63. // Command To Remove A Bounty From A Player (Preferably For Staff Members)
  64. command bountyremove(arg){
  65.     permission = array("bountyremove", "bountyadmin");
  66.     execute(){
  67.         if(isSet(arg) == false){
  68.             player.message("[Bounty] Proper Usage: /bountyremove (player)", bountyTextColor);
  69.             return;
  70.         }
  71.         target = toPlayer(arg);
  72.         if(isPlayer(target) == false){
  73.             player.message("[Bounty] Could Not Find That Player!", bountyTextColor);
  74.             return;
  75.         }
  76.         bounty = getBounty(target.id);
  77.         if(bounty == false){
  78.             player.message(str.format("[Bounty] {0} Does Not Have A Bounty On Them!", target.name), bountyTextColor);
  79.             return;
  80.         }
  81.         database.execute(str.format("DELETE FROM bountylist WHERE victimid = '{0}';", target.id));
  82.         broadcast(str.format("[Bounty] {0} Has Forcefully Removed The Bounty On {1}", player.name, target.name), bountyTextColor);
  83.         player.message("[Bounty] You Have Successfully Removed The Bounty On " + target.name + "!", bountyTextColor);
  84.     }
  85. }
  86.  
  87. // Command To Pay Off Your Bounty
  88. command bountypay(){
  89.     permission = array("bountypay", "bounty");
  90.     execute(){
  91.         bounty = getBounty(player.id);
  92.         if(bounty == false){
  93.             player.messge("[Bounty] You Do Not Have A Bounty On You!", bountyTextColor);
  94.             return;
  95.         }
  96.         bountyAmount = toInt(bounty[2]);
  97.         if(player.balance < bountyAmount){
  98.             player.message(str.format("[Bounty] You Can Not Afford To Pay Off Your Bounty Of {0} {1}!", bountyAmount, currencyName));
  99.             return;
  100.         }
  101.         player.decreaseBalance(bountyAmount);
  102.         database.execute(str.format("DELETE FROM bountylist WHERE victimid = '{0}';", player.id));
  103.         broadcast(str.format("[Bounty] {0} Has Payed Off The Bounty On Them!", player.name), bountyTextColor);
  104.     }
  105. }
  106.  
  107. // Displays All People Online With Bounties
  108. command bountylist(){
  109.     permission = array("bountylist", "bounty");
  110.     execute(){
  111.         output = "[Bounty] Bounties: ";
  112.         bounties = database.execute("SELECT * FROM bountylist");
  113.         foreach(bounty in bounties){
  114.             if(isPlayer(toPlayer(bounty[0]))){
  115.                 output = str.format(output + toPlayer(bounty[0]).name + "(${0}) ", bounty[2]);
  116.             }
  117.         }
  118.         player.message(output, bountyTextColor);
  119.     }
  120. }
  121.  
  122. // Retrieves Bounty From Database
  123. function getBounty(victimID){
  124.     bounty = database.execute(str.format("SELECT * FROM bountylist WHERE victimid = '{0}';", victimID));
  125.     if(bounty.count == 0){
  126.         return false;
  127.     }
  128.     return bounty[0];
  129. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top