Overkillz Posted February 8, 2016 Posted February 8, 2016 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
Bonus Posted February 8, 2016 Posted February 8, 2016 Increase +1 in what? X? Y? Z? fZ+1 increases the height of the spawn.
Overkillz Posted February 8, 2016 Author Posted February 8, 2016 +1 to all (fX,fY,fZ) I know that fX or fY or fZ +1 just will change a bit from the position actual.
Enargy, Posted February 9, 2016 Posted February 9, 2016 +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 ) - Inactivo.
Overkillz Posted February 9, 2016 Author Posted February 9, 2016 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 IIYAMA Posted February 11, 2016 Moderators Posted February 11, 2016 There is always one spawnpoint? local pSpawnPoint = getElementsByType( "spawnpoint" ) if pSpawnPoint[1] then pSpawnPoint = pSpawnPoint[1] -- -- code -- -- code -- end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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