LaCosTa Posted December 22, 2014 Share Posted December 22, 2014 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
Castillo Posted December 22, 2014 Share Posted December 22, 2014 And where is the part where it gives the money when you hit the pickup? Link to comment
LaCosTa Posted December 22, 2014 Author Share Posted December 22, 2014 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
WASSIm. Posted December 22, 2014 Share Posted December 22, 2014 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
LaCosTa Posted December 22, 2014 Author Share Posted December 22, 2014 it says on debugscript , attempt to compare number with nil -- line 8 Link to comment
Castillo Posted December 22, 2014 Share Posted December 22, 2014 if (tonumber(money > 0)) and (tonumber(money < 7000)) then Change to: if ( tonumber ( money ) and tonumber ( money ) > 0 and ( tonumber ( money ) < 7000 ) ) then Link to comment
LaCosTa Posted December 22, 2014 Author Share Posted December 22, 2014 Thanks it's working now , my main purpose is just to know how to add money on command , to use it , if i faced another script like it , anyways thanks WASSim and solidsnake for your help Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now