
Skript Command: /convertloot Description
This Skript command /convertloot allows players to convert specific in-game items into virtual cash.
1. Command and Permissions:
- The command is /convertloot.
- Players must have the convertloot.usepermission to use it.
- If a player doesn't have permission, they receive the message "&cYou do not have permission to use this command."
2. Initialization:
Several variables are initialized:
- {_hasLoot}A boolean flag to track if the player has any convertible items.
- {_totalDollars}Stores the total amount of cash the player will receive.
- {_amountOfLoot}Tracks the total number of convertible items.
- {_moneyOne},- _moneyFive,- _moneyTen- _moneyTwenty- _moneyHundredvariables are counters to keep track of how many of each denomination of money the player will receive.
3. Loot counting:
The script checks the player's inventory for the following items:
- Emeralds named "&aMoney"
- Emeralds named "&6Money"
- Gold ingots named "&6Gold"
- Gold nuggets named "&6Golden Watch"
- Iron nuggets named "&7Silver Watch"
- Paper named "&8Dirty Money"
For each type of item found, the script adds the quantity of that item to the _amountOfLoot variable.
4. Loot conversion:
 
 
The script then processes each type of convertible item:
- For each item type, it checks if the player has any of that item.
- If they do, it sets _hasLootto.true
- It removes all of those items from the player's inventory.
- It then loops through the number of items removed.
- Inside the loop:
- A random number between 1 and 100 is generated.
- Based on the random number, the script increments the appropriate money counter (_moneyOne,_moneyFive, etc.) and adds the corresponding value to._totalDollars
- The Golden Watch has its own unique payout percentages.
 
- The script repeats this process for each type of convertible item.
5. Cash delivery and notification:
- If _hasLootistrue(the player had convertible items):
- It plays a sound.
- It sends the message "&aConverting loot to cash..."
- It waits for 10 seconds.
- It then executes console commands to give the player the calculated amounts of each money denomination using a console command.
- It plays another sound.
- It sends the message, "Your loot has been converted to cash!" and "&aYou received &6$%{_totalDollars}%."
 
- If _hasLootisfalse(the player had no convertible items):
- It plays a sound.
- It sends the message "You don't have any loot to convert!"
 

In essence, the script takes specified items from a player's inventory, randomly converts them into virtual cash of different denominations, and gives the cash to the player after a delay.