HuskLV Posted March 17, 2017 Share Posted March 17, 2017 Hey, i make carshop system new button "token" with buy car. If you have token you can buy car with him, please help with this. client side: if itemID == 300 then gui["btnCoin"] = guiCreateButton(232, 140, 105, 41, "Redeem token", false, gui["_root"]) addEventHandler("onClientGUIClick", gui["btnCoin"], carshop_buyCar_click, false) guiSetEnabled(gui["btnCoin"], coinEnabled) else gui["btnCash"] = guiCreateButton(10, 140, 105, 41, "Pay by cash", false, gui["_root"]) addEventHandler("onClientGUIClick", gui["btnCash"], carshop_buyCar_click, false) guiSetEnabled(gui["btnCash"], cashEnabled) end function carshop_buyCar_click() if exports.global:hasSpaceForItem(getLocalPlayer(), 3, 1) then local sourcestr = "cash" if (source == gui["btnBank"]) then sourcestr = "bank" elseif (source == gui["btnCoin"]) then sourcestr = "coin" end triggerServerEvent("carshop:buyCar", theVehicle, sourcestr) else outputChatBox("You don't have space in your inventory for a key", 0, 255, 0) end carshop_buyCar_close() end server side: elseif (paymentMethod == "coin") then if itemID == 300 and costCar < 15000 then if isOverlayDisabled then outputChatBox("Token 15'000$ you dont have token with up to 15'000$!", client, 0, 255, 0) else exports.hud:sendBottomNotification(client, "Wrong token - 15'000$", "Token 15'000$ you dont have token with up to 15'000$!") end else takeItemFromSlot(client, 300) end Please help me! 1 Link to comment
NeXuS™ Posted March 17, 2017 Share Posted March 17, 2017 Can you use [lua] tags? This is horrible to look at... And also, copy a bit more, because I can't understand a thing from what you wrote. Link to comment
HuskLV Posted March 17, 2017 Author Share Posted March 17, 2017 --CLIENT SIDE if itemID == 300 then gui["btnCoin"] = guiCreateButton(232, 140, 105, 41, "Redeem token", false, gui["_root"]) addEventHandler("onClientGUIClick", gui["btnCoin"], carshop_buyCar_click, false) guiSetEnabled(gui["btnCoin"], coinEnabled) else gui["btnCash"] = guiCreateButton(10, 140, 105, 41, "Pay by cash", false, gui["_root"]) addEventHandler("onClientGUIClick", gui["btnCash"], carshop_buyCar_click, false) guiSetEnabled(gui["btnCash"], cashEnabled) end function carshop_buyCar_click() if exports.global:hasSpaceForItem(getLocalPlayer(), 3, 1) then local sourcestr = "cash" if (source == gui["btnBank"]) then sourcestr = "bank" elseif (source == gui["btnCoin"]) then sourcestr = "coin" end triggerServerEvent("carshop:buyCar", theVehicle, sourcestr) else outputChatBox("You don't have space in your inventory for a key", 0, 255, 0) end carshop_buyCar_close() end --SERVER SIDE elseif (paymentMethod == "coin") then if itemID == 300 and costCar < 15000 then if isOverlayDisabled then outputChatBox("Token 15'000$ you dont have token with up to 15'000$!", client, 0, 255, 0) else exports.hud:sendBottomNotification(client, "Wrong token - 15'000$", "Token 15'000$ you dont have token with up to 15'000$!") end else takeItemFromSlot(client, 300) end Link to comment
NeXuS™ Posted March 17, 2017 Share Posted March 17, 2017 Whats above this? elseif (paymentMethod == "coin") then if itemID == 300 and costCar < 15000 then if isOverlayDisabled then outputChatBox("Token 15'000$ you dont have token with up to 15'000$!", client, 0, 255, 0) else exports.hud:sendBottomNotification(client, "Wrong token - 15'000$", "Token 15'000$ you dont have token with up to 15'000$!") end else takeItemFromSlot(client, 300) end Link to comment
HuskLV Posted March 17, 2017 Author Share Posted March 17, 2017 local costCar = getElementData(source, "carshop:cost") if (paymentMethod == "cash") then if not exports.global:hasMoney(client, costCar) or costCar == 0 then if isOverlayDisabled then outputChatBox("You don't have enough money on hand for this pal..", client, 0, 255, 0) else exports.hud:sendBottomNotification(client, "Money is always a problem..", "You don't have enough money on hand for this pal..") end return false else exports.global:takeMoney(client, costCar) end elseif (paymentMethod == "bank") then local money = getElementData(client, "bankmoney") - costCar if money < 0 or costCar == 0 then if isOverlayDisabled then outputChatBox("You don't have enough money in your bank account for this pal..", client, 0, 255, 0) else exports.hud:sendBottomNotification(client, "Money is always a problem..", "You don't have enough money in your bank account for this pal..") end else exports.anticheat:changeProtectedElementDataEx(client, "bankmoney", money, false) mysql:query_free("UPDATE characters SET bankmoney=" .. mysql:escape_string((tonumber(money) or 0)) .. " WHERE id=" .. mysql:escape_string(getElementData( client, "dbid" ))) end elseif (paymentMethod == "coin") then if itemID == 300 and costCar < 15000 then if isOverlayDisabled then outputChatBox("Jūs nevarat iegādāties dārgāku par 15'000$ caur šo kuponu!", client, 0, 255, 0) else exports.hud:sendBottomNotification(client, "Nederīgs kupons - 15'000$", "Jūs nevarat iegādāties dārgāku par 15'000$ caur šo kuponu!") end else takeItemFromSlot(client, 300)--HUSKLV end else if isOverlayDisabled then outputChatBox("No.", client, 0, 255, 0) else exports.hud:sendBottomNotification(client, "No!", "Just no...") end return false end Link to comment
NeXuS™ Posted March 17, 2017 Share Posted March 17, 2017 Can you search for this in your code? setElementData(source, "carshop:cost", ...) Link to comment
HuskLV Posted March 17, 2017 Author Share Posted March 17, 2017 7 minutes ago, NeXuS™ said: Can you search for this in your code? setElementData(source, "carshop:cost", ...) carshop:cost work! Because with cash and bank i can buy, but i make token and that's not working. Error not shows. Link to comment
NeXuS™ Posted March 17, 2017 Share Posted March 17, 2017 Do you have a token-system already? Link to comment
itHyperoX Posted March 17, 2017 Share Posted March 17, 2017 exports.global: just not a leaked script? Link to comment
NeXuS™ Posted March 17, 2017 Share Posted March 17, 2017 @TheMOG, I think it's valhalla. Link to comment
marxist Posted March 17, 2017 Share Posted March 17, 2017 This is OwlGaming's script. If you want to create a token based system, use your own script and not a leaked one. It'll be easier to manage in the long run. 1 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