redditing Posted July 3, 2020 Share Posted July 3, 2020 -- server side cylinder = createMarker(-712.09100, 967.01917, 12.33547-1, "cylinder", 1.5, 255, 50, 0, 255) setElementData(cylinder, "BoxWithPoints", 0) function TIMER() if getElementData(cylinder, "BoxWithPoints") >= 8 then setElementData(cylinder, "BoxWithPoints", 8) else setElementData(cylinder, "BoxWithPoints", getElementData(cylinder, "BoxWithPoints")+1) end if isElementWithinMarker(source, cylinder) then triggerServerEvent("givePointsToServer", root) PointsServer = getElementData(source, "points") BoxPoints = getElementData(cylinder, "BoxWithPoints") setElementData(source, "points", PointsServer + BoxPoints) setElementData(cylinder, "BoxWithPoints", 0) end end setTimer(TIMER, 3000, 0) -- client side setElementData(getLocalPlayer(), "points", 0) addCommandHandler("ShowMyPoints", function() outputChatBox(tostring(getElementData(getLocalPlayer(), "points")), 255, 255, 0) end) addEvent("givePointsToServer", true) addEventHandler("givePointsToServer", root, function(player) local player = client setElementData(player, "points", getElementData(player, "points")) end) The problem is with the ruler where isElementWithinMarker (source, cylinder) shows me the error that argument 1 got nil, I don't know what to think about it because I checked meta.xml and server side and client side is the correct type, could someone explain why is this happening? Link to comment
nxFairlywell Posted July 3, 2020 Share Posted July 3, 2020 Because, Source in timers equals nil source = nil Also, You using the triggerServerEvent function in Server-side and that is wrong side for it. Link to comment
Sisqo0 Posted July 3, 2020 Share Posted July 3, 2020 (edited) Quote source -- The player or element the event was attached to That's why you don't get the player since you're using timer. Your code has some mistakes too such as you are trying to trigger client side from server by triggerServerEvent and the right is triggerClientEvent. infinity timer can cause some problems as well especially you made it every 3 sec. You can use this better "onElementDataChange" and about the element in marker, you can do this function elementinmarker(element) setTimer(function() if element then if isElementWithinMarker(element,cylinder) then -- Your code end end end,3000, 1) end addEventHandler("onMarkerHit",cylinder,elementinmarker) and it would be better if you make the whole code server side Edited July 3, 2020 by Sisqo0 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