I have this code in client-side
addEvent("getGroundPosition", true)
function getGround(x, y, z)
local z2 = getGroundPosition(x,y,z)
local o = createObject(356, x, y, z2)
end
addEventHandler("getGroundPosition", getRootElement(), getGround)
And this code for server-side
addCommandHandler("bot", botTest)
addEvent("getGroundPosition", true)
function botDead(attacker, weapon, bodypart)
local x, y, z = getElementPosition(source)
triggerClientEvent("getGroundPosition", attacker, x, y, z)
end
I bind on key F remove all objects with ID 356 (in server-side)
function getItems(player)
local x, y, z = getElementPosition(player)
outputChatBox("try_one", player)
for _,p in ipairs(getElementsByType('object')) do
outputChatBox("try_two_one", player)
if isElementInRange(p, x, y, z, 50) then
outputChatBox("try_two", player)
if(getElementModel(p) == 356) then
outputChatBox("try_three", player)
destroyElement(p)
end
end
end
end
This only works if you create an object on the server side, but then I can not use getGroundPosition. However, if the object creation will be on the client side, this code does not work