DonnySheffield Posted Friday at 10:41 Share Posted Friday at 10:41 Hello guys! I'm working on one job script which is pizza delivery. Everything is working fine, but i wanted to give random salary after every customer. "fizu" mean the payment so i made random 5$ to 150$, but for some reason after every customer only give 18$ and not random. Any idea why this could happen? This is my code: fizu = math.random(5,150) addEventHandler("onColShapeHit", getRootElement(), function (thePlayer, sameDimension) if isElement(source) then if getElementType(thePlayer) == "player" then if sameDimension then local currentJob = startedJobs[thePlayer] if currentJob then local colData = getElementData(source, "pizzaCol") if colData and colData[1] == thePlayer then local carryingPizza = getElementData(thePlayer, "carryingPizza") or {} if carryingPizza[1] then local orderId = colData[2] if carryingPizza[1] == currentJob.pizzas[orderId] then local remainingPizzas = 0 local pizzaBoyElement = getElementData(thePlayer, "usingPizzaBoy") if isElement(pizzaBoyElement) then local pizzaBoyInventory = getElementData(pizzaBoyElement, "pizzaBoyInventory") or {} for k in pairs(pizzaBoyInventory) do remainingPizzas = remainingPizzas + 1 end end destroyElement(source) if remainingPizzas <= 0 then startedJobs[thePlayer] = nil setElementData(pizzaBoyElement, "pizzaBoyInventory", false) else currentJob.delivered[orderId] = true end exports.cl_core:giveMoney(thePlayer, fizu, "pizzaDelivered") setElementData(thePlayer, "usingPizzaBoy", false) setPedAnimation(thePlayer, false) setElementFrozen(thePlayer, false) triggerClientEvent(thePlayer, "pizzaDeliveredSuccessfully", thePlayer, orderId, remainingPizzas) exports.cl_hud:showInfobox(thePlayer, "s", "Sikeresen leszállítottad a pizzát! ") else exports.cl_hud:showInfobox(thePlayer, "e", "Ez a megrendelő nem ilyen pizzát kért!") end end end end end end end end ) Link to comment
Moderators IIYAMA Posted Friday at 13:46 Moderators Share Posted Friday at 13:46 2 hours ago, DonnySheffield said: Any idea why this could happen? It is on the top of the code, just running once at the beginning. Could you explain why you put it there? Just so that I can understand the context of that variable placement, because normally you wouldn't put it there unless there is a specific reason. 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