Jump to content

getElementPosition Errorr


Recommended Posts

Posted

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

Posted
  
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 ) 
  

Posted
  
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

Posted

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 ) 

Posted
no i want to check if the player in the same position # then open window

In the same position of what?? We can't understand you because you didn't say everything.

Just create a marker and then use the event on client marker hit so then you can show your window.

Posted

i want to get the player position #

if the player position is the same before 1h = after 1 hour |> open window

example : if the postion of player is

( 858.14453, -587.89142, 18.01809 )

if it after 1 hour

( 858.14453, -587.89142, 18.01809 )

then open window

Posted

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.

Posted
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

Posted
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:

Posted
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! :)

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