Hello guys. I'm just learning Lua. I wrote some code, my idea is: When player hit the marker, gui opens. What i'm doing wrong? In debuscript i haven't got any errors.
I would be
extremely grateful if there were comments next to the (corrected) code.
My main language is Polish, so instead of 'script' I write 'skrypt'. Sorry for that: /
meta.xml
<meta>
<info name="praca_gazety" author="Xeno" type="RPG" version="0.0.1" />
<script src="skrypt_c.Lua" type="client" />
<script src="skrypt_s.Lua" type="server" />
</meta>
skrypt_s.Lua
addEventHandler("onResourceStart",resourceRoot,
function ()
local marker = createMarker(-2442, 754, 34, "cylinder", 2)
addEventHandler("onMarkerHit",marker,onMarkerHit)
end)
function onMarkerHit(hitPlayer, matchingDimension)
if not matchingDimension then
ourputChatBox("Error")
end
if ( getElementType (hitPlayer) == 'player' ) then
outputChatBox("PRACA DORYWCZA")
triggerClientEvent(hitPlayer,"showGUI",hitPlayer)
end
end
skrypt_c.Lua
local okno1 = guiCreateWindow(0.32, 0.21, 0.21, 0.27, "PRACA DORYWCZA", false)
guiWindowSetSizable(okno1, false)
guiSetVisible(okno1, false)
local button1 = guiCreateButton(0.03, 0.58, 0.94, 0.38, "Jestem przyciskiem", false, okno1)
addEvent("showGUI", true)
addEventHandler("showGUI", getRootElement(),
function ()
if (guiGetVisible(okno1) == nil) then
guiSetVisible(okno1, true)
showCursor(true)
end
end)
-- okno1 = window1 (it's in Polish, SORRY FOR THAT!
I will add that when I enter the marker, 'PRACA DORYWCZA'
is displayed in the chat, so the check has been carried out.
if ( getElementType (hitPlayer) == 'player' ) then
outputChatBox("PRACA DORYWCZA")
triggerClientEvent(hitPlayer,"showGUI",hitPlayer)
end