Kamycz3q Posted February 29, 2020 Share Posted February 29, 2020 Anything Working but only giving weapon dont work function kup(item, kwota) outputChatBox("udalo sie XD") if tonumber(getPlayerMoney(getRootElement())) >= tonumber(kwota) then if item == "glock-18" then giveWeapon(localPlayer, 22, 50, false) outputChatBox("Zakupiono") end else outputChatBox("Nie masz wystarczająco pieniędzy!") end end addEvent( "kup", true ) addEventHandler( "kup", getRootElement(), kup) HTML: <button id="zakup_glock18" class="zakup_glock18" onclick='mta.triggerEvent("kup", "glock-18", 2000)'>Zakup</button> <div id="Cena__2000_"> <span>Cena: 2000$</span> </div> Link to comment
Investor Posted February 29, 2020 Share Posted February 29, 2020 giveWeapon is server-only. CEF can only trigger to client. You need to bridge the client to the server using a server-event. Taking money from the player should also happen on the server, but you probably shouldn't trust the client to tell the server the price, instead the server should look up the price for a given item independently, in a table stored on the server side. Additionally getPlayerMoney(getRootElement()) should be getPlayerMoney() with no parameters. 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