Jump to content

why wont it work?


Recommended Posts

hi i made my 1st client sided script today and i really struggle with them. This is it:

function roll() 
    x,y,z = getElementPosition(player) 
    ground = getGroundPosition(x,y,z) 
    outputChatBox(ground) 
    setTimer(roll, 1000, 0) 
end 
addCommandHandler( "test", roll) 

its supposed to tell me what height the ground is when i type test and continue to tell me every second after. I have no warnings but it wont work. Why not?

Link to comment

try this:

function roll() 
    local x,y,z = getElementPosition(localPlayer) --instead of player try localPlayer 
    local ground = getGroundPosition(x,y,z) 
    outputChatBox(ground) 
    setTimer(roll, 1000, 0) 
end 
addCommandHandler( "test", roll) 

Link to comment
getGroundPosition 

Client-Side ONLY

function fnRoll() 
    local nX, nY, nZ = tonumber(getElementPosition( getLocalPlayer())); 
    outputChatBox( tonumber(getGroundPosition( nX, nY, nZ )) ); 
    setTimer( fnRoll, 1000, 0 ); 
end 
addCommandHandler( 'test', fnRoll ); 

Link to comment
getGroundPosition 

Client-Side ONLY

function fnRoll() 
    local nX, nY, nZ = tonumber(getElementPosition( getLocalPlayer())); 
    outputChatBox( tonumber(getGroundPosition( nX, nY, nZ )) ); 
    setTimer( fnRoll, 1000, 0 ); 
end 
addCommandHandler( 'test', fnRoll ); 

The code is client-side and.. mine is correct.

Link to comment

As far as I know, that doesn't matter. MTA looks at the attributes anyway, not the (non-existant) contents of the tag.

Anyway, seriously, run debugscript 3. You need to enter it in the in-game F8 console, not in the server window.

Link to comment
As far as I know, that doesn't matter. MTA looks at the attributes anyway, not the (non-existant) contents of the tag.

Anyway, seriously, run debugscript 3. You need to enter it in the in-game F8 console, not in the server window.

plus you have to be signed in to your MTA account.

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...