Jump to content

setElementPosition problem


Overkillz

Recommended Posts

Posted

Hey guys, I cant stand "for" at scripting due to I cant controll it.

Well, my point is trying to change the position of the player where he spawned increasing the spawn point +1

function nombreas() 
    local aSpawnPoints = getElementsByType( "spawnpoint" ) 
      
    for i, pSpawnPoint in ipairs( aSpawnPoints ) do 
        local fX, fY, fZ, RX, RY,RZ = tonumber( getElementData( pSpawnPoint, "posX" ) ), tonumber( getElementData( pSpawnPoint, "posY" ) ), tonumber( getElementData( pSpawnPoint, "posZ" ) ) 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        if vehicle then 
            setElementPosition( vehicle, fX,fY,fZ ) 
            outputChatBox("You changed spawn point",255,255,255,true) 
        else 
            outputChatBox("You are not alive",255,255,255,true) 
        end 
         
    end 
     
end 
bindKey ( "2", "down", nombreas ) 

I tried adding to fX,fY,fZ +1 but it didnt work too.

I hope u can help me, thanks for your time

Posted
+1 to all (fX,fY,fZ)

I know that fX or fY or fZ +1 just will change a bit from the position actual.

I don't really understood, are you trying this?

setElementPosition( vehicle, tonumber(fX)+1,tonumber(fY)+1,tonumber(fZ)+1 ) 

Posted

More less, Im trying to change the vehicle position to another spawn point pressing a key "2" however, when I try it, it just change only to a position and after changing it moves to the same position

  • Moderators
Posted

There is always one spawnpoint?

local pSpawnPoint = getElementsByType( "spawnpoint" ) 
if pSpawnPoint[1] then 
    pSpawnPoint = pSpawnPoint[1] 
    -- 
    -- code 
    -- 
    -- code 
    -- 
end 

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