Помогите. Когда покупаешь машину, в элемент "vehspawn" записывается ид машины и он означает то, что машина куплена и заспавнилась. Но почему-то скрипт не работает. Скрипт не видит элемент "vehspawn". Вот код:
function spawncar()
local x,y,z = getElementPosition(source)
if isElement( "vehspawn" ) then
local vehicle = getElementData (source, "vehspawn")
local createv = createVehicle(vehicle, x+5, y, z)
outputChatBox("Vehicle has been successfully created",source)
else
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then -- if the player is logged in
local vehicle = getAccountData ( playeraccount, "veh")
local createv = createVehicle(vehicle, x+5, y, z)
outputChatBox("Vehicle has been successfully created",source)
end
end
end
addEvent ("Comprar carro", true)
addEventHandler ("Comprar carro", getRootElement(),
function(id2, cost2, name2,x, y, z, sRz)
if (getPlayerMoney (source) >= tonumber(cost2)) then
outputChatBox ("You bought " .. name2, source, 255, 0, 0, false)
outputChatBox ("ID: " .. id2, source, 255, 0, 0, false)
outputChatBox ("Price: " .. cost2, source, 255, 0, 0, false)
takePlayerMoney (source, tonumber (cost2))
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then -- if the player is logged in
setAccountData ( playeraccount, "veh", id2 ) -- Сохраняем тачку в акк
end
local x,y,z = getElementPosition (source)
local vehicle = createVehicle (id2, x+5, y, z, 0, 0, sRz )
setElementData (source, "vehspawn", id2)
else
outputChatBox ("Error", source, 255, 0, 0, false)
end
end)