----client side
addEventHandler("onClientColShapeHit", resourceRoot, function()
local id = getElementData(source,"item_ID")
--
end)
--server side
function createItemInMap(item, name, x, y, z)
createObject(item, x, y, z)
local colSphere = createColSphere(x, y, z, 1.5)
local item_ID = 1
setElementData(colSphere, "item_ID", item_ID, true)
end
When creating colshape, set its elementData.
Use resourceRoot to trigger event only with colShapes created within the same resource.
Not right. Use 10 instead of 0.0.3
Tip: use /debugscript to see detailed error code. Not hard to figure out yourself!
You will have to format returned x,y to be on the edge of resolution.
You can use optional argument 'edgeTolerance' of getScreenFromWorldPosition.
If 'location point' is out of screen, function will return screen x,y position outside of screen resolution. You only have to format returned x,y to be on edge of screen resolution.
https://i.imgur.com/tkVGLBX.png
It will return false if 'location point' is behind the screen.
That works, because instead of client doing action, the server does. Client can't, because the clientside files aren't downloaded yet.(I'm not sure if onPlayerJoin is the right one, maybe onPlayerConnect)
function update()
setCameraMatrix(source, -1360, 1618, 100, -1450, 1200, 100)
showChat(source, false)
end
--updated as gSub told to.
addEventHandler("onPlayerJoin", getRootElement(), update)
Because the clientside isn't ready, you cant use client functions like setSkyGradient, setTime and setWeather, only server functions. Well you can, but that would set effect for every player.
There isn't function as clientTriggerEvent. Use triggerClientEvent. Also, you have to add first argument.
Use this, remember to change player to your defined argument.
triggerClientEvent(player, "LoginType", player, "register")
Yes, the problem is in line 6.
replace "player_Spawn" with "onVehicleLocked".
addEventHandler ( "onVehicleLocked", getLocalPlayer(), onVehicleLocked )
WARNING:sound\sonidoS.luat:6: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil]
The problem is told there. Expected function at argument 3, got nil.
Argument 3 is player_Spawn, argument 2 is getLocalPlayer() and so on. You got on argument 3 nil = nothing. That may be, because "player_Spawn" isn't added as a function.
function getPos()
local x, y ,z = getElementPosition(localPlayer)
local pos = tostring(x..", "..y..", "..z)
outputChatBox(pos, 255, 100, 100, false)
setClipboard(pos)
end
addCommandHandler("pos", getPos)
--gui.lua:232
local imgX, imgY = getControlScreenPos(wnd)
wnd.onclick((x - imgX)/wnd.width, (y - imgY)/wnd.height, btn)
I figured out that this is where it calculates clicked position. getControlScreenPos returns the window offset to x,y locations.
x,y position is 400,80 and gui offset is 200,50. You subtract from clicked position offset position and get exactly map position, which is divided by window size.
addEventHandler("onClientGUIClick", guiRoot, function(button, state, absoluteX, absoluteY)
if source == mapImage then
local relX, relY = guiGetSize(mapImage, true)
local x = relX*6000 - 3000
local y = 3000 - relY*6000
local hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000)
guiSetText(mapXedit, x)
guiSetText(mapYedit, y)
guiSetText(mapZedit, hitZ or 0)
end
end)
Maybe this