Jump to content

[Help] Unable to get this script to work


Forthwind

Recommended Posts

So I'm trying to use my script to transfer a variable from server side to client side, it's going to be placed in a dx. Yet whatever I've tried so far resulted in an error, along with involving an experienced friend who also wasn't able to find the error.

 

Anyway the script is as following:

Server side: 

function Position (thePlayer)
local root = getRootElement()
spawnPlayer (source, -1756.2720947266, 787.56939697266, 167.65625, 0, math.random(0,288), 0, 0)
fadeCamera(source, true)
setCameraTarget(source, source)
end

addEventHandler( "onPlayerJoin", getRootElement(), Position )

function startgame(playerSource)
  actualtimer = setTimer(outputChatBox, 100000, 1, "Life is gut")
                setElementData(playerSource, "countdowntimer", actualtimer)
end

addCommandHandler( "countdown", startgame )]

 


 

-- client

function transferhandler()
outputChatBox ("countdown")
end

addEventHandler("onClientRender", root,
    function(timer)
        dxDrawRectangle(313, 242, 378, 55, tocolor(5, 0, 0, 149), false)
  countdown = (getTimerDetails(getElementData(getLocalPlayer(), "countdowntimer"))/1000)
        dxDrawText("Game starts in:" .. countdown .. "seconds!", 323, 258, 646, 280, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
    end
)

addEvent( "StartEvent", true )
addEventHandler( "StartEvent", getRootElement(), countdown )

 

These are the errors I'm getting:
When I start the resourse:  howv2ym.jpg

When I write the command /countdown (to start the countdown, variable that's going to be transferred.

8XbMZlB.jpg

 

Lastly, those errors are equal to these lines in the script: Client.lua:30 is this line:
countdown = (getTimerDetails(getElementData(getLocalPlayer(), "countdowntimer"))/1000)

So the transfer is working fine, just the clientside part isn't.

 

Edited by Forthwind
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...