Jump to content

Weird GUI Bug


xXMADEXx

Recommended Posts

Posted

For some reason, when a player goes into the marker, the GUI is visible for everyone :o

--[[ 
Author: xXMADEXx 
File: jobs/server.lua 
type: Server 
Copyright 2012 (c) xXMADEXx 
--]] 
  
local mechanic_job_marker_ls = createMarker (2200.19507, -1970.24207, 13.7841, "cylinder", 1.5, 0, 100, 255, 0 ) 
local mechanic_job_marker_sf = createMarker (-2037.205078125, 174.556640625, 27.8359375, "cylinder", 1.5, 0, 100, 255, 0 ) 
local mechanic_job_marker_LV = createMarker (1658.5751953125, 2199.5830078125, 9.8203125, "cylinder", 1.5, 0, 100, 255, 0 ) 
  
-- GUI -- 
job = "Mechanic" 
local resX,resY = guiGetScreenSize() 
local width,height = 606,372 
local X = (resX/2) - (width/2) 
local Y = (resY/2) - (height/2) 
mechanic_job_window = guiCreateWindow(X,Y,width,height,"RoG Jobs - ".. job,false) 
guiWindowSetMovable(mechanic_job_window,false) 
guiWindowSetSizable(mechanic_job_window,false) 
guiSetVisible(mechanic_job_window,false) 
mechanic_job_description = guiCreateMemo(38,46,524,260,"\nAs a mehcanic, you can go around San Andreas, lookign for people who have damaged cars.\nWhen you find someone who needs their car fixed, just simply get into the vehicle and type '/fix' to repair their vehicle. You have to make sure they pay you, using the commands /pay [who] [amount] or /give [who] [amount]",false,mechanic_job_window) 
guiMemoSetReadOnly(mechanic_job_description,true) 
mechanic_job_take = guiCreateButton(44,313,261,44,"Accept Job",false,mechanic_job_window) 
mechanic_job_exit = guiCreateButton(306,313,261,44,"Cancel",false,mechanic_job_window) 
  
--close function -- 
function closeWindow() 
    if (source == mechanic_job_exit) or (source == mechanic_job_take) then 
        guiSetVisible(mechanic_job_window, false) 
        showCursor(false,false) 
    end 
end 
addEventHandler("onClientGUIClick", mechanic_job_exit, closeWindow) 
addEventHandler("onClientGUIClick", mechanic_job_take, closeWindow) 
  
-- When you get near ped -- 
function markerhit() 
    guiSetVisible(mechanic_job_window, true) 
    showCursor(true) 
end 
addEventHandler("onClientMarkerHit", mechanic_job_marker_ls, markerhit) 
addEventHandler("onClientMarkerHit", mechanic_job_marker_sf, markerhit) 
addEventHandler("onClientMarkerHit", mechanic_job_marker_LV, markerhit) 
  
function mechanicTakeJob() 
    triggerServerEvent("mechanicTakesJob",localPlayer) 
    triggerServerEvent("rog:teams:setteam:community",localPlayer) 
end 
addEventHandler("onClientGUIClick", mechanic_job_take , mechanicTakeJob, false) 

Posted
--[[ 
Author: xXMADEXx 
File: jobs/server.lua 
type: Server 
Copyright 2012 (c) xXMADEXx 
--]] 
  
local mechanic_job_marker_ls = createMarker (2200.19507, -1970.24207, 13.7841, "cylinder", 1.5, 0, 100, 255, 0 ) 
local mechanic_job_marker_sf = createMarker (-2037.205078125, 174.556640625, 27.8359375, "cylinder", 1.5, 0, 100, 255, 0 ) 
local mechanic_job_marker_LV = createMarker (1658.5751953125, 2199.5830078125, 9.8203125, "cylinder", 1.5, 0, 100, 255, 0 ) 
  
-- GUI -- 
job = "Mechanic" 
local resX,resY = guiGetScreenSize() 
local width,height = 606,372 
local X = (resX/2) - (width/2) 
local Y = (resY/2) - (height/2) 
mechanic_job_window = guiCreateWindow(X,Y,width,height,"RoG Jobs - ".. job,false) 
guiWindowSetMovable(mechanic_job_window,false) 
guiWindowSetSizable(mechanic_job_window,false) 
guiSetVisible(mechanic_job_window,false) 
mechanic_job_description = guiCreateMemo(38,46,524,260,"\nAs a mehcanic, you can go around San Andreas, lookign for people who have damaged cars.\nWhen you find someone who needs their car fixed, just simply get into the vehicle and type '/fix' to repair their vehicle. You have to make sure they pay you, using the commands /pay [who] [amount] or /give [who] [amount]",false,mechanic_job_window) 
guiMemoSetReadOnly(mechanic_job_description,true) 
mechanic_job_take = guiCreateButton(44,313,261,44,"Accept Job",false,mechanic_job_window) 
mechanic_job_exit = guiCreateButton(306,313,261,44,"Cancel",false,mechanic_job_window) 
  
--close function -- 
function closeWindow() 
    if (source == mechanic_job_exit) or (source == mechanic_job_take) then 
        guiSetVisible(mechanic_job_window, false) 
        showCursor(false,false) 
    end 
end 
addEventHandler("onClientGUIClick", mechanic_job_exit, closeWindow) 
addEventHandler("onClientGUIClick", mechanic_job_take, closeWindow) 
  
-- When you get near ped -- 
function markerhit(hitElement) 
    if hitElement == localPlayer then 
        guiSetVisible(mechanic_job_window, true) 
        showCursor(true) 
    end 
end 
addEventHandler("onClientMarkerHit", mechanic_job_marker_ls, markerhit) 
addEventHandler("onClientMarkerHit", mechanic_job_marker_sf, markerhit) 
addEventHandler("onClientMarkerHit", mechanic_job_marker_LV, markerhit) 
  
function mechanicTakeJob() 
    triggerServerEvent("mechanicTakesJob",localPlayer) 
    triggerServerEvent("rog:teams:setteam:community",localPlayer) 
end 
addEventHandler("onClientGUIClick", mechanic_job_take , mechanicTakeJob, false) 

Posted

You should check if the player who entered the marker is the local player, otherwise it will show it for everybody since client code is loaded for all players.

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