jessiepinkman Posted August 25, 2017 Share Posted August 25, 2017 script_c [..] function strt() payment = 50 if not isElementWithinMarker(localPlayer, work) then return end local random = math.random(2, #places) local target = createMarker(places[random][1], places[random][2], places[random][3]-1.0, "cylinder", 1.0, 255, 0, 0) local blip = createBlipAttachedTo(cel, 12) addEventHandler("onClientMarkerHit", cel, function(el, md) if not md or getElementType(el) ~= "player" then return end if el ~= localPlayer then return end destroyElement(cel) destroyElement(blip) setElementFrozen(el, true) setPedAnimation ( localPlayer, "CARRY", "crry_prtial", 1,true ) setTimer(function() setElementFrozen(el, false) setPedAnimation(localPlayer, false) setElementData(localPlayer, "delivered", true) triggerServerEvent("getPlayerCredits", getRootElement(), payment) -- HERE end, 5000, 1) end) end script_s mysql = exports.mysql addEvent("getPlayerCredits",true) addEventHandler("getPlayerCredits", resourceRoot, payment function (payment) if getElementData(plr, "delivered") == true then exports.global:giveMoney(thePlayer,payment) outputChatBox("OK!",root,0,255,0) return end end) Error: Client triggered server side event getPlayerCredits, but event is not added serverside Link to comment
Mr.Loki Posted August 25, 2017 Share Posted August 25, 2017 (edited) mysql = exports.mysql addEvent("getPlayerCredits",true) addEventHandler("getPlayerCredits", resourceRoot, function (payment) if getElementData(plr, "delivered") == true then exports.global:giveMoney(thePlayer,payment) outputChatBox("OK!",root,0,255,0) return end end) Line 3 script_s addEventHandler("getPlayerCredits", resourceRoot, payment should be addEventHandler("getPlayerCredits", resourceRoot, function(payment) the reason for the error is because you didnt have a comma after payment which is still wrong syntax btw. TIP: You should use an editor that shows simple errors in Lua Edited August 25, 2017 by Mr.Loki 1 Link to comment
jessiepinkman Posted August 25, 2017 Author Share Posted August 25, 2017 1 hour ago, Mr.Loki said: mysql = exports.mysql addEvent("getPlayerCredits",true) addEventHandler("getPlayerCredits", resourceRoot, function (payment) if getElementData(plr, "delivered") == true then exports.global:giveMoney(thePlayer,payment) outputChatBox("OK!",root,0,255,0) return end end) Line 3 script_s addEventHandler("getPlayerCredits", resourceRoot, payment should be addEventHandler("getPlayerCredits", resourceRoot, function(payment) the reason for the error is because you didnt have a comma after payment which is still wrong syntax btw. TIP: You should use an editor that shows simple errors in Lua Okay, now it's saying: (Line 4 script_s) bad argument @'getElementData' [expected element at argument 1, got nil] Link to comment
Mr.Loki Posted August 25, 2017 Share Posted August 25, 2017 You have "plr" and "thePlayer" they are not defined as far as what I can see in the code. Who is plr and who is thePlayer? I'm guessing that plr = player sending money and thePlayer = player receiving money If so then you should set the source of the event to the localPlayer by changing getRootElement() to LocalPlayer in line 23 Then add that "el" variable to 1 of the arguments along with payment at line 23 so it would look like: localPlayer, el, payment) Next in your server event change "plr" to source which will be the localPlayer and add "thePlayer" right before payment in line 3 as a function parameter it would look like: function(thePlayer,payment) 1 Link to comment
jessiepinkman Posted August 25, 2017 Author Share Posted August 25, 2017 (edited) 19 minutes ago, Mr.Loki said: You have "plr" and "thePlayer" they are not defined as far as what I can see in the code. Who is plr and who is thePlayer? I'm guessing that plr = player sending money and thePlayer = player receiving money If so then you should set the source of the event to the localPlayer by changing getRootElement() to LocalPlayer in line 23 Then add that "el" variable to 1 of the arguments along with payment at line 23 so it would look like: localPlayer, el, payment) Next in your server event change "plr" to source which will be the localPlayer and add "thePlayer" right before payment in line 3 as a function parameter it would look like: function(thePlayer,payment) No, i just want to give player money from work Edited August 25, 2017 by jessiepinkman Link to comment
Mr.Loki Posted August 25, 2017 Share Posted August 25, 2017 4 minutes ago, jessiepinkman said: No, i just want to give player money from work Then just change getRootElement() to localPlayer and plr and thePlayer to source 1 Link to comment
jessiepinkman Posted August 25, 2017 Author Share Posted August 25, 2017 21 minutes ago, Mr.Loki said: Then just change getRootElement() to localPlayer and plr and thePlayer to source It's okay now, no errors but it's not giving me money Link to comment
Mr.Loki Posted August 25, 2017 Share Posted August 25, 2017 Line 3 change resourceRoot to root 1 Link to comment
jessiepinkman Posted August 25, 2017 Author Share Posted August 25, 2017 8 minutes ago, Mr.Loki said: Line 3 change resourceRoot to root You're the best 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