Jump to content

[Help] Problem with different markers


AlexWo

Recommended Posts

Hey,

I got in my script 2 different marker. One of them opens a Job-GUI and the other one will open a Vehiclespawn-GUI.

Now if I enter the second marker it opens the Job-GUI. I use as the event handler

addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit ) 

"getRootElement". I think thats the problem but if I chage it and start it no GUI opens.

Help would be great

This is my whole clientside-script:

markers = 
    { 
        createMarker( -1620, 685, 6, "cylinder", 1.5, 0, 0, 255, 100), 
        createMarker( 2242, 2450, 9.75, "cylinder", 1.5 , 0, 0, 255, 100), 
        createMarker( 1555, -1675.5, 15.2, "cylinder", 1.5, 0, 0, 255, 100) 
         
    } 
  
vehiclemarkers = 
    {    
        createMarker( 1556, -1612, 12.5, "cylinder", 1.5, 0, 0, 255, 100), 
        createMarker( 1566, -1612, 12.5, "cylinder", 1.5, 0, 0, 255, 100) 
    } 
  
LSPoliceBlip = createBlip( 1554, -1675, 15, 30, 2) 
SFPoliceBlip = createBlip( -1620, 685, 8, 30, 2) 
LVPoliceBlip = createBlip( 2242, 2450, 11, 30, 2) 
  
  
function PoliceGUI (hitPlayer, matchingDimension ) 
    --Message that you enered the Marker 
    outputChatBox ( getPlayerName(hitPlayer) .. ", you entered the Police-Job Marker", 255, 255, 0 ) 
    --Window/GUI  
    policeWindow = guiCreateWindow ( 0.25, 0.25, 0.4, 0.4, "Policejob", true ) 
    --Tap Panel 
    policePanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, policeWindow ) 
    --Tab's 
    policeMap = guiCreateTab( "Job Information", policePanel )   
    scriptinformation = guiCreateTab( "Script Information", policePanel )   
    --PoliceTab 
    guiCreateLabel(0.02, 0.04, 0.94, 0.2, "Welcome to the Police Department", true, policeMap) 
    guiCreateLabel(0.02, 0.08, 0.94, 0.92, "Press 'Accept' to accept the Job and get your Equipment", true, policeMap) 
    guiCreateLabel(0.02, 0.12, 0.94, 0.92, "Press 'Exit' to close this gui and exit", true, policeMap) 
    guiCreateLabel(0.065, 0.5, 0.94, 0.92, "Please choose a Skin:", true, policeMap) 
    guiCreateStaticImage( 350, 75, 350, 175, "images/police-tape.png", false, policeMap ) 
     
     
    LS = guiCreateRadioButton(50,200,100,16,"LS Skin",false, policeMap) 
        guiRadioButtonSetSelected(LS,true) 
    SF = guiCreateRadioButton(50,220,100,16,"SF Skin",false, policeMap) 
    LV = guiCreateRadioButton(50,240,100,16,"LV Skin", false, policeMap) 
  
  
    exitbutton = guiCreateButton( 0.5, 0.85, 0.2, 0.1, "Exit", true, policeMap ) 
    acceptbutton = guiCreateButton( 0.1, 0.85, 0.2, 0.1, "Accept", true, policeMap ) 
    showCursor ( true ) 
     
    --ScriptInformationTab 
    guiCreateLabel(0.02, 0.04, 0.94, 0.2, "This script is made by Alexander Wolf©", true, scriptinformation) 
    guiCreateLabel(0.02, 0.08, 0.94, 0.2, "Do you like my script? Visit my Website alexwo.com/scripting for more!", true, scriptinformation) 
end 
addEventHandler ( "onClientMarkerHit", getRootElement(), PoliceGUI ) 
  
function wclose (state) 
 if state == "left" then 
  if source == exitbutton then 
    outputChatBox("You left the Job Marker "..getPlayerName(localPlayer).."!", 255, 100, 0) 
    guiSetVisible(policeWindow, false) 
    showCursor(false) 
  end 
 end 
end 
addEventHandler("onClientGUIClick", getRootElement(), wclose) 
  
function acceptjob (state) 
 if state == "left" then 
  if source == acceptbutton then 
    if(guiRadioButtonGetSelected(LS))then 
        triggerServerEvent("giveEquipmentLS", getLocalPlayer(), thePlayer) 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
        local acceptsound = playSound("sounds/accept.mp3") 
    elseif(guiRadioButtonGetSelected(SF))then 
        triggerServerEvent("giveEquipmentSF", getLocalPlayer(), thePlayer) 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
        local acceptsound = playSound("sounds/accept.mp3") 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
    elseif(guiRadioButtonGetSelected(LV))then 
        triggerServerEvent("giveEquipmentLV", getLocalPlayer(), thePlayer) 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
        local acceptsound = playSound("sounds/accept.mp3") 
    end 
  end 
 end 
end 
addEventHandler("onClientGUIClick", getRootElement(), acceptjob) 

Link to comment
markers = 
    { 
        createMarker( -1620, 685, 6, "cylinder", 1.5, 0, 0, 255, 100), 
        createMarker( 2242, 2450, 9.75, "cylinder", 1.5 , 0, 0, 255, 100), 
        createMarker( 1555, -1675.5, 15.2, "cylinder", 1.5, 0, 0, 255, 100) 
        
    } 
  
vehiclemarkers = 
    {    
        createMarker( 1556, -1612, 12.5, "cylinder", 1.5, 0, 0, 255, 100), 
        createMarker( 1566, -1612, 12.5, "cylinder", 1.5, 0, 0, 255, 100) 
    } 
  
LSPoliceBlip = createBlip( 1554, -1675, 15, 30, 2) 
SFPoliceBlip = createBlip( -1620, 685, 8, 30, 2) 
LVPoliceBlip = createBlip( 2242, 2450, 11, 30, 2) 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        for _, marker in ipairs ( markers ) do 
            addEventHandler ( "onClientMarkerHit", marker, PoliceGUI ) 
        end 
    end 
) 
  
function PoliceGUI (hitPlayer, matchingDimension ) 
    --Message that you enered the Marker 
    outputChatBox ( getPlayerName(hitPlayer) .. ", you entered the Police-Job Marker", 255, 255, 0 ) 
    --Window/GUI 
    policeWindow = guiCreateWindow ( 0.25, 0.25, 0.4, 0.4, "Policejob", true ) 
    --Tap Panel 
    policePanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, policeWindow ) 
    --Tab's 
    policeMap = guiCreateTab( "Job Information", policePanel )   
    scriptinformation = guiCreateTab( "Script Information", policePanel )   
    --PoliceTab 
    guiCreateLabel(0.02, 0.04, 0.94, 0.2, "Welcome to the Police Department", true, policeMap) 
    guiCreateLabel(0.02, 0.08, 0.94, 0.92, "Press 'Accept' to accept the Job and get your Equipment", true, policeMap) 
    guiCreateLabel(0.02, 0.12, 0.94, 0.92, "Press 'Exit' to close this gui and exit", true, policeMap) 
    guiCreateLabel(0.065, 0.5, 0.94, 0.92, "Please choose a Skin:", true, policeMap) 
    guiCreateStaticImage( 350, 75, 350, 175, "images/police-tape.png", false, policeMap ) 
    
    
    LS = guiCreateRadioButton(50,200,100,16,"LS Skin",false, policeMap) 
        guiRadioButtonSetSelected(LS,true) 
    SF = guiCreateRadioButton(50,220,100,16,"SF Skin",false, policeMap) 
    LV = guiCreateRadioButton(50,240,100,16,"LV Skin", false, policeMap) 
  
  
    exitbutton = guiCreateButton( 0.5, 0.85, 0.2, 0.1, "Exit", true, policeMap ) 
    acceptbutton = guiCreateButton( 0.1, 0.85, 0.2, 0.1, "Accept", true, policeMap ) 
    showCursor ( true ) 
    
    --ScriptInformationTab 
    guiCreateLabel(0.02, 0.04, 0.94, 0.2, "This script is made by Alexander Wolf©", true, scriptinformation) 
    guiCreateLabel(0.02, 0.08, 0.94, 0.2, "Do you like my script? Visit my Website alexwo.com/scripting for more!", true, scriptinformation) 
end 
  
function wclose (state) 
 if state == "left" then 
  if source == exitbutton then 
    outputChatBox("You left the Job Marker "..getPlayerName(localPlayer).."!", 255, 100, 0) 
    guiSetVisible(policeWindow, false) 
    showCursor(false) 
  end 
 end 
end 
addEventHandler("onClientGUIClick", getRootElement(), wclose) 
  
function acceptjob (state) 
 if state == "left" then 
  if source == acceptbutton then 
    if(guiRadioButtonGetSelected(LS))then 
        triggerServerEvent("giveEquipmentLS", getLocalPlayer(), thePlayer) 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
        local acceptsound = playSound("sounds/accept.mp3") 
    elseif(guiRadioButtonGetSelected(SF))then 
        triggerServerEvent("giveEquipmentSF", getLocalPlayer(), thePlayer) 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
        local acceptsound = playSound("sounds/accept.mp3") 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
    elseif(guiRadioButtonGetSelected(LV))then 
        triggerServerEvent("giveEquipmentLV", getLocalPlayer(), thePlayer) 
        guiSetVisible(policeWindow, false) 
        showCursor(false) 
        local acceptsound = playSound("sounds/accept.mp3") 
    end 
  end 
 end 
end 
addEventHandler("onClientGUIClick", getRootElement(), acceptjob) 

Link to comment

It works! :)

Thank you very much.

What does exactly that

addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        for _, marker in ipairs ( markers ) do 
            addEventHandler ( "onClientMarkerHit", marker, PoliceGUI ) 
        end 
    end 
) 

do?

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