Jump to content

Hit marker and later warp coordinates


Notorious^

Recommended Posts

Hello all

All is good but my serverside is bad.i cant make it.can you help me ? I entered marker and GUI is working but i cant warp to coordinates.please help.i mean i didnt triggered server event.

 

Clientside :

GUIEditor = {
Button = {},
window = {},
label = {}
}
local screenW, screenH = guiGetScreenSize()
GUIEditor.window[1] = guiCreateWindow((screenW - 313) / 2, (screenH - 109) / 2, 313, 109, "konu basligi", false)
guiWindowSetSizable(GUIEditor.window[1],false)

GUIEditor.label[1] = guiCreateLabel (37, 28, 236, 16, (" soru sorma yeri ? "), false, GUIEditor.window.[1])
guiSetFont (GUIEditor.label[1], "default-bold-small")
guiLabelHorizontalAlign(GUIEditor.label[1],"center", false)
GUIEditor.button[1] = guiCreateButton (25, 66,129,32, "evet", false,GUIEditor.window[1])
guiSetPropert(GUIEditor.button[1], "normalTextColour","FFAAAAAA")
GUIEditor.button[2] = guiCreateButton(154,66,129,32, "Hayir",false, GUIEditor.window[1])
guiSetProperty(GUIEditor.button[2], "normalTextColour", "FFAAAAAA")

guiSetVisible (GUIEditor.window[1],false)

local enabled = true

Mark =
{1507.73,2842.96,10.82},
{-310.012,1583.59,75.56},
{-2125.71,272.62,35.48},

}

for k, v in ipairs (Mark) do
z = v[3] -1
Marker = createMarker (v[1], v[2], z, "cylinder", 2, 255,255,0,0)
setElementData (Marker,"markerPurpose","Arena")
addEventHandler ("onClientMarkerHit",Marker,
function (hit)
if hit == localPlayer then

if not enabled then exports.topBarChatMessage ( "test",2000) return end
if isPedInVehicle (localPlayer) then return end
guiSetVisible ( GUIEditor.window[1],true)
ShowCursor (true)
guiSetText (GUIEditor.label[1],"Arenaya girmek istiyor musun ?"))
playSound ("tus.wav")

end
end)
end

addEventHandler ("onClientGuiClick",root,function()
if source == GUIEditor.button[1] then
guiSetVisible (GUIEditor.window[1],false)
showCursor (false)
triggerServerEvent ("warphal",localPlayer)
playSound ("kabul.mp3")

else if source ==GUIEditor.button[2] then
guiSetVisible (GUIEditor.window[1],false)
showCursor (false)
playSound ("hadi.mp3")
end
end)

addEvent ("montana",true)
addEventHandler ("montana",root,function()
guiSetVisible (GUIEditor.window[1],true)
guiSetText (GUIEditor.label[1],("girmek istermisin ?"))
showCursor (true)
end)

Server side:

addEvent("warphal", true)
addEventHandler("warphal",root,spawn)

local spawns = {
{2014.47,1523.71,10.81},
{2023.47,1437.71,10.81},
{2121.47,1481.71,10.81},
{1928.47,1482.71,10.81}
}

function spawn (localPlayer)
local rnd = math.random 1, #spawns)
setElementPosition ( localPlayer, spawns [rnd][1],spawns [rnd][2],spawns [rnd][3])
end

 

Link to comment

If I understand correctly, try this.

local Mark = {
	[1] = {1507.73,2842.96,10.82},
	[2] = {-310.012,1583.59,75.56},
	[3] = {-2125.71,272.62,35.48},
}

Marker = {}
for k, v in ipairs (Mark) do
	z = v[3] -1
	Marker[k] = createMarker (v[1], v[2], z, "cylinder", 2, 255,255,0,0)
	setElementData(Marker[k],"markerPurpose", "Arena")

	addEventHandler ("onClientMarkerHit", resourceRoot,
	function (hit)
		if hit == localPlayer then

			if not enabled then exports.topBarChatMessage ( "test",2000) return end
			if isPedInVehicle (localPlayer) then return end
			guiSetVisible ( GUIEditor.window[1],true)
			ShowCursor (true)
			guiSetText (GUIEditor.label[1],"Arenaya girmek istiyor musun ?"))
			playSound ("tus.wav")

		end
	end)
end

EDIT: did i not tested

Link to comment
  • Moderators
--[[ OLD
addEvent("warphal", true)
addEventHandler("warphal",root,spawn)
]]

local spawns = {
  {2014.47,1523.71,10.81},
  {2023.47,1437.71,10.81},
  {2121.47,1481.71,10.81},
  {1928.47,1482.71,10.81}
}

function spawn ()
	local rnd = math.random(#spawns)
	-- Using client pre-defined variable
	setElementPosition ( client, spawns[rnd][1],spawns[rnd][2],spawns[rnd][3])
  	iprint("spawn function has been called") -- debug line
end

addEvent("warphal", true) -- moved to here
addEventHandler("warphal",resoourceRoot, spawn, false) -- receive the event only for the resourceRoot element. And not it's children: false = getPropagated 

 

triggerServerEvent ("warphal", resourceRoot) -- using the resourceRoot as source element

 

resourceRoot is the main element created by the resource. Every element created by resource is attached to it.

 

Pre-defined variables:

 

Link to comment

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...