Jump to content

getElementPosition Errorr


Recommended Posts

why this doesn't work @

Debug " client.lua:7 ")" expected near ","

function outputLocalPlayerPosition ( ) 
    local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) 
    end 
  
  
setTimer (function() 
    if ( getElementPosition ( getLocalPlayer ( ) ) == px, py, pz ) then 
        guiSetVisible ( wind, true ) 
        end 
    end, 3600000, 0 ) 
    ) 

Link to comment
  
function outputLocalPlayerPosition ( ) 
    local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) 
    end 
  
  
setTimer (function() 
     local x, y, z = getElementPosition ( getLocalPlayer ( ) ) 
    if ( x == px and y == py and z == pz ) then 
        guiSetVisible ( wind, true ) 
        end 
    end, 3600000, 0 ) 
  

Link to comment
  
function outputLocalPlayerPosition ( ) 
    local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) 
    end 
  
  
setTimer (function() 
     local x, y, z = getElementPosition ( getLocalPlayer ( ) ) 
    if ( x == px and y == py and z == pz ) then 
        guiSetVisible ( wind, true ) 
        end 
    end, 3600000, 0 ) 
  

That should work

Link to comment

no problem in debug but the windows doesnt want to be visible | # i changed the time to 5 sec

function outputLocalPlayerPosition ( ) 
    local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) 
    end 
  
  
function gg2 () 
     local x, y, z = getElementPosition ( getLocalPlayer ( ) ) 
    if ( x == px and y == py and z == pz ) then 
        guiSetVisible ( wind, true ) 
        end 
    end 
setTimer ( gg2, 5000, 0 ) 

Link to comment

You're defining them as local. px, py and pz variables are local to the function outputLocalPlayerPosition. This means the function gg2 can not reach those variables and thus - returns a nil value(so you should have received errors, make sure you've enabled Debugging properly).

So there are a few different solutions for this. Here's two possible ways you could achieve what you want;

1. Call the gg2 function passing px, py, pz as parameters;

function outputLocalPlayerPosition() 
    local px, py, pz = getElementPosition(localPlayer) 
    gg2(px, py, pz) 
end 
setTimer(outputLocalPlayerPosition, 5000, 0) 
  
  
function gg2(px, py, pz) 
local x, y, z = getElementPosition(localPlayer) 
    if(x == px and y == py and z == pz) then 
        guiSetVisible(wind, true) 
    end 
end 

2. Use return and then call outputLocalPlayerPosition to return the px, py and pz values;

function outputLocalPlayerPosition() 
    local px, py, pz = getElementPosition(localPlayer) 
    return px, py, pz 
end 
  
  
function gg2() 
local px, py, pz = outputLocalPlayerPosition() 
local x, y, z = getElementPosition(localPlayer) 
    if(x == px and y == py and z == pz) then 
        guiSetVisible(wind, true) 
    end 
end 
setTimer(gg2, 5000, 0) 

To see if one hour has passed since last, you can use either account data(server-side, permanent data) or element data(both, but data is lost upon disconnection). Then you can use either getTickCount or getRealTime.

Link to comment
You're defining them as local. px, py and pz variables are local to the function outputLocalPlayerPosition. This means the function gg2 can not reach those variables and thus - returns a nil value(so you should have received errors, make sure you've enabled Debugging properly).

So there are a few different solutions for this. Here's two possible ways you could achieve what you want;

1. Call the gg2 function passing px, py, pz as parameters;

function outputLocalPlayerPosition() 
    local px, py, pz = getElementPosition(localPlayer) 
    gg2(px, py, pz) 
end 
setTimer(outputLocalPlayerPosition, 5000, 0) 
  
  
function gg2(px, py, pz) 
local x, y, z = getElementPosition(localPlayer) 
    if(x == px and y == py and z == pz) then 
        guiSetVisible(wind, true) 
    end 
end 

2. Use return and then call outputLocalPlayerPosition to return the px, py and pz values;

function outputLocalPlayerPosition() 
    local px, py, pz = getElementPosition(localPlayer) 
    return px, py, pz 
end 
  
  
function gg2() 
local px, py, pz = outputLocalPlayerPosition() 
local x, y, z = getElementPosition(localPlayer) 
    if(x == px and y == py and z == pz) then 
        guiSetVisible(wind, true) 
    end 
end 
setTimer(gg2, 5000, 0) 

To see if one hour has passed since last, you can use either account data(server-side, permanent data) or element data(both, but data is lost upon disconnection). Then you can use either getTickCount or getRealTime.

Better solution is to trigger a event if the player has idle time I Belive rather than doing such a big check.

getPlayerIdleTime

Link to comment
Better solution is to trigger a event if the player has idle time I Belive rather than doing such a big check.

getPlayerIdleTime

I merely provided but a few examples of how it can be done, I never claimed them to be the best solutions. getPlayerIdleTime only works if the player doesn't move, so that means they'd have to stand still and do nothing for an hour. Doesn't sound particularly fun to me. :lol:

Link to comment
Better solution is to trigger a event if the player has idle time I Belive rather than doing such a big check.

getPlayerIdleTime

I merely provided but a few examples of how it can be done, I never claimed them to be the best solutions. getPlayerIdleTime only works if the player doesn't move, so that means they'd have to stand still and do nothing for an hour. Doesn't sound particularly fun to me. :lol:

That's what I understood. He wants to check if a player is AFK for an hour and then open the gui.

I have no idea what he exactly means! :)

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