Jump to content

Problem with source

Recommended Posts

-- 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)
		setElementData(cylinder, "BoxWithPoints", getElementData(cylinder, "BoxWithPoints")+1)
	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)

setTimer(TIMER, 3000, 0)

-- client side

setElementData(getLocalPlayer(), "points", 0)

addCommandHandler("ShowMyPoints", function()
	outputChatBox(tostring(getElementData(getLocalPlayer(), "points")), 255, 255, 0)

addEvent("givePointsToServer", true)

addEventHandler("givePointsToServer", root, function(player)
	local player = client
	setElementData(player, "points", getElementData(player, "points"))

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

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


and about the element in marker, you can do this

function elementinmarker(element) 
      if element then
        if isElementWithinMarker(element,cylinder) then
        -- Your code
     end,3000, 1)

and it would be better if you make the whole code server side

Edited by Sisqo0
  • Like 1
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...