Overkillz Posted February 14, 2016 Share Posted February 14, 2016 Hey dear community, I have a little question about setElementPosition. When I want to set a position for the vehicle using this function changePos() local vehicle = getPedOccupiedVehicle(localPlayer) setElementPosition(vehicle, spPosX[3],spPosY[3],spPosZ[3]) end bindKey ( "1", "down", changePos ) it work's perfectly but when I try to use a variable as number, it doesnt works function changePos() local currentSpawn = 3 local vehicle = getPedOccupiedVehicle(localPlayer) setElementPosition(vehicle, spPosX[currentSpawn],spPosY[currentSpawn],spPosZ[currentSpawn]) end bindKey ( "1", "down", changePos ) Someone could tell me the reason. Thanks for all, regards. Link to comment
Bonsai Posted February 14, 2016 Share Posted February 14, 2016 Debuuuuuuuuuuuug output Link to comment
Overkillz Posted February 15, 2016 Author Share Posted February 15, 2016 (edited) EDIT: READ DOWN THIS POST Problem fixed, its weard to explain, outputDebugScritp 3 dropped me that there was a nil value. However, I quit out the variable from the function and it worked. Regards. Edited February 15, 2016 by Guest Link to comment
Overkillz Posted February 15, 2016 Author Share Posted February 15, 2016 Well, now I got a new problem now If both guys are using the command to the same time, the variable " currentNumber " increase when it is used by anybody local currentNumber = 1 function setPositionasd(source) local vehicle = getPedOccupiedVehicle(source) if vehicle then setElementPosition(vehicle, 300,500,2) end currentNumber = currentNumber+1 end addCommandHandler("spD",setPositionasd) Its serverside, how can I set it using an easy way just for the local player without triggering our whatever ? Thanks Link to comment
Bonsai Posted February 15, 2016 Share Posted February 15, 2016 Hm, you could use an array, so each player gets its own number. Link to comment
Overkillz Posted February 15, 2016 Author Share Posted February 15, 2016 I decided to use a triggerServerEvent from a client due to I cant stand tables. I couldnt test it due to Im alone at my server, but this should only move myself and increase the variable only for me? --## Client function triggerToSrv() triggerServerEvent("oncgSP", getLocalPlayer(),localPlayer) end addCommandHandler("chsp",triggerToSrv) --## Server currentNumber = 1 function chSP(source) local vehicle = getPedOccupiedVehicle(source) if vehicle then setElementPosition(vehicle, 300,500,2) end currentNumber = currentNumber+1 end addEvent("oncgSP",true) addEvent("oncgSP",getRootElement(),chSP) Link to comment
MTA Team 0xCiBeR Posted February 15, 2016 MTA Team Share Posted February 15, 2016 NO. You should store the variables on the client-side for that or just use a table with the player as index.- Link to comment
Overkillz Posted February 15, 2016 Author Share Posted February 15, 2016 Might someone can show me an example, I tried to do it triggering, but without results. Link to comment
TAPL Posted February 15, 2016 Share Posted February 15, 2016 What the use of the variable currentNumber? Link to comment
Overkillz Posted February 15, 2016 Author Share Posted February 15, 2016 What the use of the variable currentNumber? Im using a table where I have a posX, posY, and posZ, there are some values insertered and I want to move the player when he press the key 1. It is done, but the unique problem is that Im having issues increasing the value. If more than 1 players use it, the variable increase for all, and I want to increase it for one each player. Example: Player 1 press 2 times the key: currentNumber: 2 player 2 press 2 times the key: currentNumber: 4 player 1 press again 2 times the key: currentNumber: 6 The player 1 jumped from a number: 2 to 6. I would like to fix it. Link to comment
TAPL Posted February 15, 2016 Share Posted February 15, 2016 currentNumber = {} -- This on the top of the file currentNumber[source] = currentNumber[source] and currentNumber[source] + 1 or 1 or if not currentNumber[source] then currentNumber[source] = 1 else currentNumber[source] = currentNumber[source] + 1 end Link to comment
Overkillz Posted February 15, 2016 Author Share Posted February 15, 2016 currentNumber = {} -- This on the top of the file currentNumber[source] = currentNumber[source] and currentNumber[source] + 1 or 1 or if not currentNumber[source] then currentNumber[source] = 1 else currentNumber[source] = currentNumber[source] + 1 end and to select just a player, should be the same right ? I mean: currentPlayer = {} if not currentNumber[source] then currentPlayer[source] = source end to select an unique player to move later local vehicle = getPedOccupiedVehicle(currentPlayer[source]) and to set the position to an unique player setElementPosition(currentPlayer[source], posAnyX,posAnyy,posAnyz) 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