Client Side --
function warpMapInit()
addEventHandler('onClientRender', g_Root, updatePlayerBlips)
end
function spawnMapDoubleClick(relX, relY)
setPlayerPosition(relX*6000 - 3000, 3000 - relY*6000, 0)
closeWindow(wndSpawnMap)
end
function closeSpawnMap()
showCursor(false)
removeEventHandler('onClientRender', g_Root, updatePlayerBlips)
for elem,data in pairs(g_PlayerData) do
for i,name in ipairs({'mapBlip', 'mapLabelShadow', 'mapLabel'}) do
if data.gui[name] then
destroyElement(data.gui[name])
data.gui[name] = nil
end
end
end
end
wndSpawnMap = {
'wnd',
text = 'Select spawn position',
width = g_MapSide + 20,
controls = {
{'img', id='map', src='map.png', width=g_MapSide, height=g_MapSide, ondoubleclick=spawnMapDoubleClick},
{'lbl', text='Welcome to freeroam. Double click a location on the map to spawn.', width=g_MapSide-60, align='center'},
{'btn', id='close', closeswindow=true}
},
oncreate = warpMapInit,
onclose = closeSpawnMap
}
Server Side--
function spawnMe(x, y, z)
if not x then
x, y, z = getElementPosition(source)
end
if isPedTerminated(source) then
repeat until spawnPlayer(source, x, y, z, 0, math.random(9, 288))
else
spawnPlayer(source, x, y, z, 0, getPedSkin(source))
end
setCameraTarget(source, source)
setCameraInterior(source, getElementInterior(source))
end
Freeroam Code