Lua DealGoldCost

From ArcEmu-Wiki
Jump to: navigation, search
+/-
Main Page        LuaArcEmu Website     ArcEmu Forum     Bug Tracker



Syntax

pPlayer:DealGoldCost( int Money )

Description

With :DealGoldCost(value) you can remove the amount of copper from a player.
It is advised to combine this with :GetCoinage() to check if the user has the amount of copper.

Example Values

100 Copper →→ 1 Silver
1000 Copper (1k) →→ 10 Silver
10000 Copper (10k) →→ 1 Gold
100000 Copper (100k) →→ 10 Gold
1000000 Copper (1M) →→ 100 Gold

Example

function OnGossip(pUnit, event, pPlayer)
         pUnit:GossipCreateMenu(100, pPlayer, 0)
         pUnit:GossipMenuAddItem(7, "Remove 5 Gold.", 1, 0)
         pUnit:GossipMenuAddItem(7, "Remove 50 Gold.", 2, 0)
         pUnit:GossipMenuAddItem(7, "Remove 500 Gold.", 3, 0)
         pUnit:GossipSendMenu(pPlayer)
end
 
funtion OnSelect(pUnit, event, pPlayer, id, intid, code)
         if(intid == 1)
            if(pPlayer:GetCoinage() >= 50000) then -- If the player has 5 Gold or more..
               pPlayer:DealGoldCost(50000) -- also in copper value
            else
               pUnit:SendChatMessageToPlayer(12, 0, "You don't have enough gold!", pPlayer)
            end
         elseif(intid == 2) then
            if(pPlayer:GetCoinage() >= 500000) then -- If the player has 50 Gold or more..
               pPlayer:DealGoldCost(500000) -- also in copper value
            else
               pUnit:SendChatMessageToPlayer(12, 0, "You don't have enough gold!", pPlayer)
            end
         elseif(intid == 3) then
            if(pPlayer:GetCoinage() >= 5000000) then -- If the player has 500 Gold or more..
               pPlayer:DealGoldCost(5000000) -- also in copper value
            else
               pUnit:SendChatMessageToPlayer(12, 0, "You don't have enough gold!", pPlayer)
            end
         end
end
Personal tools