Jump to content

Create Gui on marker enter


Recommended Posts

Hi,

Im trying to make a gui open on marker enter, but close when you press the ok button.

This is what i got,

local Police = createTeam("Police", 0, 0, 255)   -- this will create the team everytime the  
  
local teamMarker = createMarker(1553.33, -1677.37, 15, 'cylinder', 1.5, 0, 0, 255, 150 ) 
  
function teamMarkerHit( hitElement, matchingDimension ) 
    if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
        if getPlayerTeam (hitElement) == Police then 
            outputChatBox("Steven: You are already employed by this department.", hitElement) 
        else 
    local policeWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Police Application",true) 
            setPlayerTeam ( hitElement, Police) 
            setPlayerSkin( hitElement, 280) 
            giveWeapon ( hitElement, 3, 1, true ) 
            giveWeapon ( hitElement, 22, 148, true ) 
            giveWeapon ( hitElement, 29, 64, true ) 
            giveWeapon ( hitElement, 25, 10, true ) 
        end 
  end 
end 
addEventHandler( "onMarkerHit", teamMarker , teamMarkerHit ) 

But its stopped everyting else from working.

Link to comment

GUI functions are always client-side. this is server script, judging by onMarkerHit.

use onClientMarkerHit in a client script.

also, if you do it like "local policeWindow = guiCreateWindow" in a handler function, you wont be able to access this gui element when your function finishes.

Link to comment

this will work ( i think )

client-side ^^

  
Police = createTeam("Police", 0, 0, 255)   -- this will create the team everytime the 
teamMarker = createMarker(1553.33, -1677.37, 15, 'cylinder', 1.5, 0, 0, 255, 150 ) 
policeWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Police Application",true) 
guiSetVisible ( policeWindow, false ) 
function teamMarkerHit( hitElement, matchingDimension ) 
    if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
        if getPlayerTeam (hitElement) == Police then 
            outputChatBox("Steven: You are already employed by this department.", hitElement) 
        else 
            guiSetVisible ( policeWindow, true ) 
            setPlayerTeam ( hitElement, Police) 
            setPlayerSkin( hitElement, 280) 
            giveWeapon ( hitElement, 3, 1, true ) 
            giveWeapon ( hitElement, 22, 148, true ) 
            giveWeapon ( hitElement, 29, 64, true ) 
            giveWeapon ( hitElement, 25, 10, true ) 
        end 
    end 
end 
addEventHandler( "onClientMarkerHit", teamMarker , teamMarkerHit ) 
  

Link to comment

ok

c-side

use Solidsnake14 c-side >> down

s-side

  
function GiveWeapon2 ( hitElement ) 
            giveWeapon ( hitElement, 3, 1, true ) 
            giveWeapon ( hitElement, 22, 148, true ) 
            giveWeapon ( hitElement, 29, 64, true ) 
            giveWeapon ( hitElement, 25, 10, true ) 
end 
addEvent( "GiveWeapon", true ) 
addEventHandler ( "GiveWeapon", getRootElement(), GiveWeapon2) 
  
  

Edited by Guest
Link to comment

Wrong client side.

Police = createTeam("Police", 0, 0, 255)   -- this will create the team everytime the 
teamMarker = createMarker(1553.33, -1677.37, 15, 'cylinder', 1.5, 0, 0, 255, 150 ) 
policeWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Police Application",true) 
guiSetVisible ( policeWindow, false ) 
function teamMarkerHit( hitElement, matchingDimension ) 
    if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
        if getPlayerTeam (hitElement) == Police then 
            outputChatBox("Steven: You are already employed by this department.", hitElement) 
        else 
            guiSetVisible ( policeWindow, true ) 
            setPlayerTeam ( hitElement, Police) 
            setPlayerSkin( hitElement, 280) 
            triggerServerEvent ("GiveWeapon", hitElement, hitElement) -- If you don't pass twice hitElement it won't work for server side: hitElement. 
        end 
    end 
end 
addEventHandler( "onClientMarkerHit", teamMarker , teamMarkerHit ) 

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