Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- config = {
- "MIN_BOUNTY": 100,
- "MAX_BOUNTY": 10000
- };
- translations = {
- "CORRECT_USAGE": "Correct Usage: /AddBounty <target> <amount>",
- "TARGET_NOT_FOUND": "Could not find target player",
- "INVALID_AMOUNT": "Amount must be between {0} and {1}",
- "ALREADY_HAS_BOUNTY": "Target already has a bounty",
- "NOT_ENOUGH_EXP": "You do not have enough experience to place this bounty",
- "PLACED_BOUNTY": "Successfully placed bounty on target",
- "UI_BOUNTY": "{0}: {1} experience",
- "BOUNTY_CLAIMED_KILLER": "You have claimed {0}'s bounty of {1}",
- "BOUNTY_CLAIMED_BY": "{0} has claimed {1}'s bounty of {2}"
- };
- event onLoad(){
- database.nonQuery("CREATE TABLE IF NOT EXISTS uBountyList(
- id VARCHAR(17) PRIMARY KEY,
- name VARCHAR(255) NOT NULL DEFAULT 0,
- worth INT NOT NULL DEFAULT 0
- );");
- }
- function translate(player, ID, params){
- if(params == null) params = [];
- while(params.count != 4) params.add("");
- player.message(translations[ID].format(params[0],params[1],params[2],params[3]));
- }
- command AddBounty(target, amount){
- permission = "uBounty.add";
- allowedCaller = "player";
- execute(){
- if(target == null or amount == null)
- return translate(player, "CORRECT_USAGE");
- amount = amount.toNumber();
- if(amount < config["MIN_BOUNTY"] or amount > config["MAX_BOUNTY"])
- return translate(player, "INVALID_AMOUNT", [config["MIN_BOUNTY"], config["MAX_BOUNTY"]]);
- target = toPlayer(target);
- if(target == null)
- return translate(player, "TARGET_NOT_FOUND");
- DBcheck = DBcheck = database.firstRow("SELECT * FROM uBountyList WHERE id= @p0;", target.id);
- if(DBcheck.count != 0)
- return translate(player, "ALREADY_HAS_BOUNTY");
- if(player.experience < amount)
- return translate(player, "NOT_ENOUGH_EXP");
- player.experience-= amount;
- database.nonQuery("INSERT INTO uBountyList VALUES (@p0,@p1,@p2)", target.id, target.name, amount);
- translate(player, "PLACED_BOUNTY");
- }
- }
- command oBounty(){
- permission = "uBounty";
- allowedCaller = "player";
- execute(){
- uBountyData = database.allRows("SELECT * FROM uBountyList ORDER BY worth ASC LIMIT 8");
- viewData = array();
- foreach(bounty in uBountyData){
- if(toPlayer(bounty[0]) != null)
- viewData.add(translations["UI_BOUNTY"].format(bounty[1],bounty[2]));
- }
- while(viewData.count != 8) viewData.add("Empty");
- player.effects.sendUI(9375, 9375, dataShown[0], dataShow[1],dataShown[2], dataShown[3]);
- player.effects.sendUI(9376, 9376, dataShown[4], dataShow[5],dataShown[6], dataShown[7]);
- }
- }
- command cBounty(){
- permission = "uBounty";
- allowedCaller = "player";
- execute(){
- player.effects.clearUIByID(9375, player.id);
- player.effects.clearUIByID(9376, player.id);
- }
- }
- event onPlayerDeath(player, killer, cause){
- if(killer == null or player.id == killer.id) return;
- DBcheck = database.firstRow("SELECT * FROM uBountyList WHERE id= @p0;", player.id);
- if(DBcheck.count == 0) return;
- worth = DBcheck[2].toNumber();
- translate(killer, "BOUNTY_CLAIMED_KILLER", [player.name, worth ]);
- broadcast(translations["BOUNTY_CLAIMED_BY"].format(killer.name, player.name, worth));
- killer.experience+= worth ;
- database.nonQuery("DELETE FROM uBountyList WHERE id= @p0;", player.id);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement