Jump to content

pickup on key


fairyoggy

Recommended Posts

Quote

-- server

function addMarkers ( res )
        marker = createPickup (x,y,z, 3, 2663, 1, 1 )
    end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), addMarkers )

function showAmmoGUI( hitPlayer, matchingDimension )
        triggerClientEvent( hitPlayer, "showAmmoGUI_Ed", getRootElement(), hitPlayer, marker )
end

-- client

function showAmmoGUI( hitPlayer, type )
    guiSetVisible ( GUIEditor_Window[1], true )
    showCursor( true )
end
addEvent("showAmmoGUI_Ed",true)
addEventHandler("showAmmoGUI_Ed",getRootElement(),showAmmoGUI)

I’m ready to do that when a player gets on a marker. The gui window opens but i need when the player is on the marker, you must click the button (for example, N) and after clicking the button, the gui window will open. It is necessary that this button (N) works only in the marker area

Link to comment
function showAmmoGUI(hitPlayer)
    triggerClientEvent(hitPlayer, "showAmmoGUI_Ed", getRootElement(), hitPlayer, marker)
end

addEventHandler("onPlayerPickupHit", marker,
function()
	bindKey(source, "N", "down", showAmmoGUI)
end)

addEventHandler("onPlayerPickupLeave", marker,
function()
	unbindKey(source, "N", "down", showAmmoGUI)
end)

 

Link to comment
7 hours ago, SaNoR said:

function showAmmoGUI(hitPlayer)
    triggerClientEvent(hitPlayer, "showAmmoGUI_Ed", getRootElement(), hitPlayer, marker)
end

addEventHandler("onPlayerPickupHit", marker,
function()
	bindKey(source, "N", "down", showAmmoGUI)
end)

addEventHandler("onPlayerPickupLeave", marker,
function()
	unbindKey(source, "N", "down", showAmmoGUI)
end)

 

and how to write a condition that something like "if button == N then 

triggerClientEvent( hitPlayer, "showAmmoGUI_Ed", getRootElement(), hitPlayer, marker )

else

CancelEvent()

___

how to make it right?

Link to comment

Try

 

 -- server

function addMarkers()
	marker = createPickup(x,y,z, 3, 2663, 1, 1)
end
addEventHandler("onResourceStart", resourceRoot, addMarkers)

function pickupEvent()
	triggerClientEvent(source, "trAmmoGUI_Ed", source, eventName == "onPlayerPickupHit" and true or false)
end
addEventHandler("onPlayerPickupHit", marker, pickupEvent)
addEventHandler("onPlayerPickupLeave", marker, pickupEvent)

-- client

addEvent("trAmmoGUI_Ed",true)
addEventHandler("trAmmoGUI_Ed", root,
function (type)
	if type then
		bindKey("n", "down", bindTheKey)
	else
		unbindKey("n", "down", bindTheKey)
		guiSetVisible(GUIEditor_Window[1], false)
		showCursor(false)
	end
end)

function bindTheKey()
	if not guiGetVisible(GUIEditor_Window[1]) then
		guiSetVisible(GUIEditor_Window[1], true)
		showCursor(true)
	else
		guiSetVisible(GUIEditor_Window[1], false)
		showCursor(false)
	end
end)

 

Edited by TAPL
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...