Jump to content

[HELP] Nothing happens (script doesn't work)


MarbleXeno

Recommended Posts

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 

 

Edited by MarbleXeno
Link to comment

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) == false) then -- This never triggers because it is never nil (It's either true or false) So changed nil to false
		guiSetVisible(okno1, true)
		showCursor(true)
	end
end)

This should resolve the issue

Link to comment
23 minutes ago, ReZurrecti0n said:

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) == false) then -- This never triggers because it is never nil (It's either true or false) So changed nil to false
		guiSetVisible(okno1, true)
		showCursor(true)
	end
end)

This should resolve the issue

Thanks for your help!

Could you see it too? I would be very grateful.

 

 

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