☠ RaZeR ☠ Posted April 10, 2016 Share Posted April 10, 2016 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
Anubhav Posted April 10, 2016 Share Posted April 10, 2016 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
OnlineCheater Posted April 10, 2016 Share Posted April 10, 2016 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
OnlineCheater Posted April 10, 2016 Share Posted April 10, 2016 What's the error in debug? Link to comment
☠ RaZeR ☠ Posted April 10, 2016 Author Share Posted April 10, 2016 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
Anubhav Posted April 10, 2016 Share Posted April 10, 2016 Dide, it won't work.You need to change the px and py and pz to your thing! !! Link to comment
☠ RaZeR ☠ Posted April 10, 2016 Author Share Posted April 10, 2016 no i want to check if the player in the same position # then open window Link to comment
OnlineCheater Posted April 10, 2016 Share Posted April 10, 2016 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. Link to comment
☠ RaZeR ☠ Posted April 10, 2016 Author Share Posted April 10, 2016 i want to check the player position every 1 hour # after that if the position after 1 hour is the same # open the window Link to comment
Anubhav Posted April 10, 2016 Share Posted April 10, 2016 Position x, y, z = ? Tell us the X Y Z of that position! Link to comment
☠ RaZeR ☠ Posted April 10, 2016 Author Share Posted April 10, 2016 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 Link to comment
Anubhav Posted April 10, 2016 Share Posted April 10, 2016 https://wiki.multitheftauto.com/wiki/GetPlayerIdleTime You can make it server sided. Then triggerto client side and open window. Link to comment
Dealman Posted April 10, 2016 Share Posted April 10, 2016 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
Anubhav Posted April 11, 2016 Share Posted April 11, 2016 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
Dealman Posted April 11, 2016 Share Posted April 11, 2016 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. Link to comment
Anubhav Posted April 11, 2016 Share Posted April 11, 2016 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. 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now