Jump to content

[Help] Expecting Money


LaCosTa

Recommended Posts

Well i just want to make a script , that the admin can use the command /createGift "money" , to create a pickup , when a player hit that pickup he"ll recieve the money that the admin putted it through the command

gifts = {}  
     
     
    function addGift ( creator , ... )  
      if (getElementType(creator) == "player" ) then 
        local accountname = getAccountName (getPlayerAccount(creator)) 
      if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Console" ) ) then 
        local x,y,z = getElementPosition(creator)  
         gifts[creator] = createPickup(x+5,y,z,3,1274) 
                moneyGf = {...} 
                if ( tonumber(moneyGf > 0 )) and ( tonumber(moneyGf < 7000 )) then  
                 setElementData(gifts[creator],"gift",moneyGf) 
                else 
                 outputChatBox("SYNTAX USAGE : /createGift money",creator,255,255,255) 
                end 
                end 
           
            end 
        end 
addCommandHandler("createGift",addGift) 

Link to comment
      function getYourGift (reciever )  
            if (getElementType(reciever) == "player" ) and ( not isPedInVehicle(reciever) )  then  
                local money = getPlayerMoney(reciever)  
                local giftM = getElementData(gifts[creator],"gift") 
                setPlayerMoney(reciever,money+giftM) 
                outputChatBox("Congratulations You Got : "..giftM.." , ! " ,reciever,255,255,255) 
                destroyElement(gifts[creator]) 
  
            end 
        end 
addEventHandler("onPickupHit", gifts[creator] , getYourGift) 

Link to comment
local gifts = {} 
    
function addGift(creator, _, money) 
    local account = getPlayerAccount(creator) 
    if (account) and not (isGuestAccount(account)) then 
        local accountname = getAccountName(account) 
        if (isObjectInACLGroup("user."..accountname, aclGetGroup("Console")) then 
            if (tonumber(money > 0)) and (tonumber(money < 7000)) then 
                local x, y, z = getElementPosition(creator) 
                gifts[creator] = createPickup(x+5, y, z, 3, 1274) 
                setElementData(gifts[creator], "gift", money) 
                addEventHandler("onPickupUse", gifts[creator], getYourGift) 
            else 
                outputChatBox("SYNTAX USAGE : /createGift money",creator,255,255,255) 
            end 
        end 
    end 
end 
addCommandHandler("createGift",addGift) 
  
function getYourGift(reciever) 
    local creator = table.find(gifts, source) 
    local giftM = tonumber(getElementData(source, "gift")) or 0 
    givePlayerMoney(reciever, giftM) 
    outputChatBox("Congratulations You Got: $"..giftM.." !", reciever, 255, 255, 255) 
    destroyElement(source) 
    gifts[creator] = nil 
end) 
  
function table.find (tab, vf) 
    if (tab) and (type(tab) == "table") then 
        for k, v in pairs(tab) do 
            if (v == vf) then 
                return k 
            end 
        end 
    end 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...