Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- minBounty = 1000; // Minimum Bounty That Can Be Placed
- bountyTextColor = "yellow";
- currencyName = "Gold";
- // Creates The Necessary Table If It Does Not Already Exist
- event onLoad(){
- 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);");
- }
- // Pays Player Who Killed Other Player With Bounty And Removes The Bounty
- event onPlayerDeath(player, cause, murdererId){
- if(murdererId == player.id){
- return;
- }
- murderer = toPlayer(murdererId);
- if(isPlayer(murderer) == false){
- return;
- }
- bounty = getBounty(player.id);
- if(bounty == false){
- return;
- }
- bountyAmount = toInt(bounty[2]);
- murderer.increaseBalance(bountyAmount);
- broadcast(str.format("[Bounty] {0} Has Killed {1} And Received Their {2} {3} Bounty!", murderer.name, player.name, bountyAmount, currencyName), bountyTextColor);
- database.execute(str.format("DELETE FROM bountylist WHERE victimid = '{0}';", player.id));
- }
- // Command To Add A Bounty To A Player
- command bountyadd(arg1, arg2){
- permission = array("bounty", "bountyadd");
- execute(){
- if(isSet(arg1) == false or isSet(arg2) == false){
- player.message("[Bounty] Proper Usage: /bountyadd (player) (amount)", bountyTextColor);
- return;
- }
- target = toPlayer(arg1);
- if(isPlayer(target) == false){
- player.message("[Bounty] Could Not Find That Player!", bountyTextColor);
- return;
- }
- if(arg2 < minBounty or arg2 < 1){
- player.message(str.format("[Bounty] Your Bounty Must Be Between 1 and {0} {1}!", minBounty, currencyName), bountyTextColor);
- return;
- }
- if(player.balance < arg2){
- player.message("[Bounty] You Can Not Afford A Bounty Of This Amount!", bountyTextColor);
- return;
- }
- bounty = getBounty(target.id);
- if(bounty != false){
- database.execute(str.format("UPDATE bountylist SET bountyAmount = bountyAmount + {0} WHERE victimid = '{1}';", arg2, target.id));
- bounty = getBounty(target.id);
- broadcast(str.format("[Bounty] {0} Has Increased The Bounty On {1} To {2} {3}!", player.name, target.name, bounty[2], currencyName), bountyTextColor);
- return;
- }
- player.decreaseBalance(arg2);
- broadcast(str.format("[Bounty] {0} Has Placed A Bounty Of {1} {2} On {3}!", player.name, arg2, currencyName, target.name), bountyTextColor);
- database.execute(str.format("INSERT INTO bountylist (victimid, placerid, bountyAmount, timePlaced) VALUES ('{0}', '{1}', {2}, CURRENT_TIMESTAMP);", target.id, player.id, arg2));
- }
- }
- // Command To Remove A Bounty From A Player (Preferably For Staff Members)
- command bountyremove(arg){
- permission = array("bountyremove", "bountyadmin");
- execute(){
- if(isSet(arg) == false){
- player.message("[Bounty] Proper Usage: /bountyremove (player)", bountyTextColor);
- return;
- }
- target = toPlayer(arg);
- if(isPlayer(target) == false){
- player.message("[Bounty] Could Not Find That Player!", bountyTextColor);
- return;
- }
- bounty = getBounty(target.id);
- if(bounty == false){
- player.message(str.format("[Bounty] {0} Does Not Have A Bounty On Them!", target.name), bountyTextColor);
- return;
- }
- database.execute(str.format("DELETE FROM bountylist WHERE victimid = '{0}';", target.id));
- broadcast(str.format("[Bounty] {0} Has Forcefully Removed The Bounty On {1}", player.name, target.name), bountyTextColor);
- player.message("[Bounty] You Have Successfully Removed The Bounty On " + target.name + "!", bountyTextColor);
- }
- }
- // Command To Pay Off Your Bounty
- command bountypay(){
- permission = array("bountypay", "bounty");
- execute(){
- bounty = getBounty(player.id);
- if(bounty == false){
- player.messge("[Bounty] You Do Not Have A Bounty On You!", bountyTextColor);
- return;
- }
- bountyAmount = toInt(bounty[2]);
- if(player.balance < bountyAmount){
- player.message(str.format("[Bounty] You Can Not Afford To Pay Off Your Bounty Of {0} {1}!", bountyAmount, currencyName));
- return;
- }
- player.decreaseBalance(bountyAmount);
- database.execute(str.format("DELETE FROM bountylist WHERE victimid = '{0}';", player.id));
- broadcast(str.format("[Bounty] {0} Has Payed Off The Bounty On Them!", player.name), bountyTextColor);
- }
- }
- // Displays All People Online With Bounties
- command bountylist(){
- permission = array("bountylist", "bounty");
- execute(){
- output = "[Bounty] Bounties: ";
- bounties = database.execute("SELECT * FROM bountylist");
- foreach(bounty in bounties){
- if(isPlayer(toPlayer(bounty[0]))){
- output = str.format(output + toPlayer(bounty[0]).name + "(${0}) ", bounty[2]);
- }
- }
- player.message(output, bountyTextColor);
- }
- }
- // Retrieves Bounty From Database
- function getBounty(victimID){
- bounty = database.execute(str.format("SELECT * FROM bountylist WHERE victimid = '{0}';", victimID));
- if(bounty.count == 0){
- return false;
- }
- return bounty[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement