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.

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

:d::i::s::g::r::a::c::e:

norby89.png

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

The rEvolution is coming ...

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) 

5acec1ecbc.png
Posted

What is that :roll: this is solved if i'm not wrong.

P.S: It's not even what he was doing...

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Oh well, my bad i didn't read that.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • 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

The rEvolution is coming ...

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