Jump to content

How i can give weapon after clicking something on CEF browser


Kamycz3q

Recommended Posts

 

Anything Working but only giving weapon dont work :/

 

function kup(itemkwota)
    outputChatBox("udalo sie XD")
    if tonumber(getPlayerMoney(getRootElement())) >= tonumber(kwotathen
        if item == "glock-18" then
            giveWeapon(localPlayer2250false)
            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

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

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...