Jump to content

jamesRL

Members
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

jamesRL's Achievements

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody.

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody. (2/54)

0

Reputation

  1. I got now another error in console. attempt to concatenate a nil value (local 'id'). Local ID seems to not being used, and the amount value passed from client side is now the same value as the ID? What is wrong here?
  2. Hi, I can't seem to trigger server event. Chat(), SetDisplay(), print works but not the trigger. What can I do? New to FiveM dev btw. JS: $("#submit").click(function () { let IDinputValue = $("#IDinput").val() let AmountinputValue = $("#Amountinput").val() if (IDinputValue.length >= 100) { $.post("http://nui2/error", JSON.stringify({ error: "Input was greater than 100" })) return } else if (!IDinputValue) { $.post("http://nui2/error", JSON.stringify({ error: "There was no value in the input field" })) return } // if there are no errors from above, we can send the data back to the original callback and hanndle it from there $.post('http://nui2/main', JSON.stringify({ PlayerID: IDinputValue, Amount: AmountinputValue, })); return; }) Client side: (here I call the TriggerServerEvent) RegisterNUICallback("main", function(data) chat(data.PlayerID, {0,255,0}) SetDisplay(false) print("test") TriggerServerEvent('qb-faktura:server:payfaktura', source, data.PlayerID, data.Amount) end) Server side: (Here I register the ServerEvent) local QBCore = exports['qb-core']:GetCoreObject() RegisterNetEvent('qb-faktura:server:payfaktura', function(source, id, amount) local src = source local Player = QBCore.Functions.GetPlayer(src) if Player.PlayerData.money.bank >= amount then Player.Functions.RemoveMoney('bank', amount , "fakturabetaling") --id.Functions.AddMoney('bank',amount, "fakturabetaling") TriggerClientEvent('QBCore:Notify', src, "Du betalte " ..amount.. " kr til " .. id , "success") else TriggerClientEvent('QBCore:Notify', src, "Du har ikke nok penger", "error") end end) Anyone who knows? local QBCore = exports['qb-core']:GetCoreObject() RegisterNetEvent('qb-faktura:server:payfaktura') AddEventHandler('qb-faktura:server:payfaktura', function(id, amount) local src = source local Player = QBCore.Functions.GetPlayer(src) id = tonumber(id) amount = tonumber(amount) if Player.PlayerData.money.bank >= amount then Player.Functions.RemoveMoney('bank', amount , "fakturabetaling") --id.Functions.AddMoney('bank',amount, "fakturabetaling") TriggerClientEvent('QBCore:Notify', src, "Du betalte " ..amount.. " kr til " .. ID , "success") else TriggerClientEvent('QBCore:Notify', src, "Du har ikke nok penger", "error") end end) Fixed it. Easy fix. just handle as number and not string.
×
×
  • Create New...