xXMADEXx Posted January 28, 2013 Posted January 28, 2013 For some reason, when a player goes into the marker, the GUI is visible for everyone --[[ 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) The Ultimate Lua Tutorial! | MTA PHP SDK
TAPL Posted January 28, 2013 Posted January 28, 2013 --[[ 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)
xXMADEXx Posted January 28, 2013 Author Posted January 28, 2013 thanks, but where is the bug? The Ultimate Lua Tutorial! | MTA PHP SDK
Anderl Posted January 28, 2013 Posted January 28, 2013 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. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
xXMADEXx Posted January 28, 2013 Author Posted January 28, 2013 so, what is added is: if (source == markername) then ? The Ultimate Lua Tutorial! | MTA PHP SDK
Castillo Posted January 29, 2013 Posted January 29, 2013 No, if ( hitElement == localPlayer ) then San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
xXMADEXx Posted January 29, 2013 Author Posted January 29, 2013 No, if ( hitElement == localPlayer ) oh, thanks. The Ultimate Lua Tutorial! | MTA PHP SDK
Anderl Posted January 29, 2013 Posted January 29, 2013 No, if ( hitElement == localPlayer ) You forgot 'then' after the condition. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Castillo Posted January 29, 2013 Posted January 29, 2013 My bad, I guess he understood anyway. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now