Jump to content

setElementPosition problem


KariiiM

Recommended Posts

Posted

I am scripting an warper system everything scripted fine,but i face a small problem in same time bigger, when selecte the location from gridlist it warps me underground at the place near farm.

Currently it just take cash without warping plus warning.

WARNING: Bad argument @'setElementPosition' [Expected bool at argument 5, got number '0']

--It's part of the script ,server side:

  
--name  ,  city,   price,   x,  y,  z 
local theTable = { 
{"LVPD", "LV", 1200, 2221.2431640625, 2468.7631835938, 10.8203125},  
{"Hospital", "Las Venturas Airport", 1100, 1625.0001220703, 1850.4322509766, 0.8203125}, 
{"AP", "Las Venturas Airport", 2300, 1730.140625, 1480.3857421875, 10.81282043457}, 
{"AMM", "Come-A-Lot", 2000, 2099.7961425781, 967.29669189453, 10.81282043457} 
} 
  
addEvent ("bus:warpplayer",true) 
addEventHandler ("bus:warpplayer",root, 
function (cityname,price,x,y,z) 
if ( getPlayerMoney ( source ) < tonumber(price) ) then 
outputChatBox("You need ".. tonumber(price).."$ to use this service.", source, 255,0,0) 
else 
takePlayerMoney (source, tonumber(price)) 
          setElementPosition(source, x,y,z,0,0,0) 
    end 
end) 
  

Posted

Why did you put 0, 0, 0 in setElementPosition?

setElementPosition(source, tonumber(x), tonumber(y), tonumber(z)) 

Posted (edited)

I already tried this way but i out with the same error,

Bad argument @'setElementPosition' [Expected vector3 at argument

it do the same as

setElementPosition(source,x, y, z) 

Edited by Guest
Posted

You didn't finish the error. That is most likely because you didn't convert it to number or you got it wrong from wherever you get that coordinates.

Posted

You got 3 or 4 columns, and you want to get coordinates from a non-existing column.

triggerServerEvent("bus:warpplayer",localPlayer, cityname,price,guiGridListGetSelectedItem(busGrid)) 

addEvent ("bus:warpplayer",true) 
addEventHandler ("bus:warpplayer",root, 
function (cityname,price,id) 
local x, y, z = theTable[id][4], theTable[id][5], theTable[id][6] 
if ( getPlayerMoney ( source ) < tonumber(price) ) then 
outputChatBox("You need ".. tonumber(price).."$ to use this service.", source, 255,0,0) 
else 
takePlayerMoney (source, tonumber(price)) 
          setElementPosition(source, x,y,z) 
    end 
end) 

Posted

My bad..

Thanks it worked but the first row isn't selectable and give this error

ERROR: attempt to index field '?' (a nil value)

also the first row cordinations went to the 2nd row..

Posted
triggerServerEvent("bus:warpplayer",localPlayer, cityname,price,guiGridListGetSelectedItem(busGrid)+1) 

Posted

Checking if the x,y,z egal to the cordinations, it doesn't works as it must be like, disable all warps no errors/warns ..

addEvent ("bus:warpplayer",true) 
addEventHandler ("bus:warpplayer",root, 
function (cityname,price,id) 
local loc = getZoneName(theTable[id][4], theTable[id][5], theTable[id][6]) 
local x, y, z = theTable[id][4], theTable[id][5], theTable[id][6] 
local location = getZoneName(x, y, z) 
if ( getPlayerMoney ( source ) < tonumber(price) ) then 
if loc == location then 
outputChatBox("You need ".. tonumber(price).."$ to use this service.", source, 255,0,0) 
else 
outputChatBox("You're already in "..location..".",source,225,0,0) 
          takePlayerMoney (source, tonumber(price)) 
          setTimer(setElementPosition, 5000, 1,source, x,y,z) 
       end 
    end 
end) 

Posted
addEvent ("bus:warpplayer",true) 
addEventHandler ("bus:warpplayer",root, 
function (cityname,price,id) 
local loc = getZoneName(theTable[id][4], theTable[id][5], theTable[id][6]) 
local x, y, z = theTable[id][4], theTable[id][5], theTable[id][6] 
local location = getZoneName(x, y, z) 
if loc == location then 
    if ( getPlayerMoney ( source ) < tonumber(price) ) then 
        outputChatBox("You need ".. tonumber(price).."$ to use this service.", source, 255,0,0) 
    else 
        outputChatBox("You're already in "..location..".",source,225,0,0) 
        takePlayerMoney (source, tonumber(price)) 
        setTimer(setElementPosition, 5000, 1,source, x,y,z) 
     end 
end 
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...