Jump to content

GetPosition help.


Azu

Recommended Posts

Posted
function GetPosition ( player ) 
    local x, y, z =  getElementPosition( player ) 
 outputChatBox("Your Position: "..x..", "..y..", "..z..") 
end 
addCommandHandler ( "Postion", GetPosition ) 
 

This isn't working. It keeps saying something about an unexpected symbol.

What I want to do is get the players position and then have it blow up once is goes past a value in the Y position, like past - 4000 in Y only.

Posted
function GetPosition ( player ) 
    local x, y, z =  getElementPosition( player ) 
 outputChatBox("Your Position: "..x..", "..y..", "..z) 
end 
addCommandHandler ( "Postion", GetPosition ) 
  

You added an extra ". You should work in a text editor that supports syntax highlighting, which makes errors like this easier to spot.

  • Moderators
Posted

Hi Azu,

If you use notepad++, you would have of to see the extra " ( I can see it in the syntax highlighting of MTA's forum :lol )

You can change the language in notepad++: Language => L => Lua

But sometimes I have an error when I start notepad++( Failed to load langs.xml ) and there are no syntax highlighting.

To fix it:

Go to the installation folder for Notepad++ and delete langs.xml. Then, in that same folder, find langs.model.xml, make a copy of it, and rename the copy to langs.xml.

Posted

I didn't test if it works but try it. Put it in server-side script.

function resStarts(startedRes) 
    setTimer(check, 1000, 0) 
end 
  
function check() 
    for i, v in ipairs(getElementsByType("player")) do 
    local x, y, z = getElementPosition(v) 
    if(y > 4000) then 
    killPed(v) 
    end 
    end 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resStarts) 

  • Moderators
Posted
I didn't test if it works but try it. Put it in server-side script.
function resStarts(startedRes) 
    setTimer(check, 1000, 0) 
end 
  
function check() 
    for i, v in ipairs(getElementsByType("player")) do 
    local x, y, z = getElementPosition(v) 
    if(y > 4000) then 
    killPed(v) 
    end 
    end 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resStarts) 

This script work but he said -4000 ( I know, is not stupid but ... :mrgreen: )

And no answer from Azu so we can say that he founds the solution to make that

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