MoeezKhan Posted January 31, 2014 Share Posted January 31, 2014 I make a medic job but it not working. i hope you fix it -----client side----- GUIEditor = { memo = {}, button = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0.29, 0.24, 0.42, 0.49, "", true) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) bAccept = guiCreateMemo(0.08, 0.20, 0.41, 0.67, "", true, GUIEditor.window[1]) bAccept = guiCreateButton(0.60, 0.20, 0.34, 0.17, "Accept Job", true, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "sa-header") guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick", bAccept, showGUIbf, false) addEventHandler("onClientGUIClick", bAccept, joinTeam, false) bClose = guiCreateButton(0.67, 0.61, 0.20, 0.16, "CLOSE", true, GUIEditor.window[1]) guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick", bClose, showGUIbf, false) GUIEditor.memo[1] = guiCreateMemo(0.08, 0.20, 0.41, 0.67, "Become a Medic and heal people by using the command /heal player !", true, GUIEditor.window[1]) end triggerServerEvent("theMarker") triggerServerEvent("createCar") triggerServerEvent("setTeam") end ----server side---- local theMarker = createMarker ( 1103.3049316406,1079.1077880859,10.8359375, "cylinder", 1, 0, 0, 200, 170 ) -- creates the marker createBlip = ( 1103.3049316406,1079.1077880859,10.8359375, 55, 2) function MarkerHit ( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) setGUIvisable ("Panel") -- sets the triggered GUI visable triggerClientEvent() -- Triggers the GUI see Client end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) function createCar local createVehicle (416, -2591 584 15) -- ID X Y and Z setPedIntoCar(createVehicle) -- Warps the Player into the Created Car end function setTeam onGUIclick(bAccept) then setPlayerTeam("Medic") if getPlayerTeam = Medic then outputChatBox("You are already an Medic") end -- Adds the Command for Medic members to heal players local range = 50 addCommandHandler('heal', -- creates the command /heal function(p,c,who) local who = getPlayerFromName(who) if who then local mx,my,mz = getElementPosition(p) local ux,uy,uz = getElementPosition(who) if getDistanceBetweenPoints3D(mx,my,mz,ux,uy,uz) <= range then if getPlayerTeam(p) == getTeamFromName("Medic") then -- only for medics able setElementHealth(who, 100) -- sets full health setPlayerMoney(who, -100) -- Takes 100$ for healing end else outputChatBox("This player is too far away",p,0,0,225) end else outputChatBox('Player not found.',p,0,0,255) end end ) Link to comment
Castillo Posted January 31, 2014 Share Posted January 31, 2014 Of course not, it makes no sense, that's all a mess. Link to comment
MoeezKhan Posted January 31, 2014 Author Share Posted January 31, 2014 Of course not, it makes no sense, that's all a mess. what you mean Link to comment
TheGamingMann Posted February 1, 2014 Share Posted February 1, 2014 He means your code is a mess e.g. You have local createCar() this is not even how to correctly write a local variable. I am not the most competent coder but this really needs a make over. When I am back on my PC I will do my best to fix it up a bit for you. Link to comment
xXMADEXx Posted February 1, 2014 Share Posted February 1, 2014 Please have a look at this: viewtopic.php?f=148&t=40809 Link to comment
TheGamingMann Posted February 1, 2014 Share Posted February 1, 2014 Okay. I did what I can. I am not one to work with teams as I have yet to try them out. I got the window to show and the car to spawn and have the player warped into it. Server Side: function giveJob() local veh = createVehicle(416, -2591, 584, 15) -- ID X Y and Z warpPedIntoVehicle(source, veh) -- Warps the Player into the Created Car triggerClientEvent("hideMedic", source) end addEvent("setJob", true) addEventHandler("setJob", root, giveJob) -- Adds the Command for Medic members to heal players local range = 50 addCommandHandler('heal', -- creates the command /heal function(p,c,who) local who = getPlayerFromName(who) if who then local mx,my,mz = getElementPosition(p) local ux,uy,uz = getElementPosition(who) if getDistanceBetweenPoints3D(mx,my,mz,ux,uy,uz) <= range then if getPlayerTeam(p) == getTeamFromName("Medic") then -- only for medics able setElementHealth(who, 100) -- sets full health givePlayerMoney(who, -100) -- Takes 100$ for healing end else outputChatBox("This player is too far away",p,0,0,225) end else outputChatBox('Player not found.',p,0,0,255) end end ) Client Side: local theMarker = createMarker(1103.3049316406, 1079.1077880859, 9.8359375, "cylinder", 1, 0, 0, 200, 170) -- creates the marker local blip = createBlip(1103.3049316406, 1079.1077880859, 10.8359375, 22, 2) -- creates the hospital blip function createMedicGUI() wdwJob = guiCreateWindow(0.29, 0.24, 0.42, 0.49, "", true) guiWindowSetSizable(wdwJob, false) btnAccept = guiCreateButton(0.60, 0.20, 0.34, 0.17, "Accept Job", true, wdwJob) guiSetFont(btnAccept, "sa-header") btnClose = guiCreateButton(0.67, 0.61, 0.20, 0.16, "CLOSE", true, wdwJob) guiSetProperty(btnClose, "NormalTextColour", "FFAAAAAA") memInfo = guiCreateMemo(0.08, 0.20, 0.41, 0.67, "Become a Medic and heal people by using the command /heal [player]!", true, wdwJob) guiMemoSetReadOnly(memInfo, true)-- makes memo read only. addEventHandler("onClientGUIClick", btnClose, hideJob, false) addEventHandler("onClientGUIClick", btnAccept, jobHandler, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), -- creates and hides the window function() createMedicGUI() guiSetVisible(wdwJob, false) end ) function showJob() -- shows the window upon request if not guiGetVisible(wdwJob) then guiSetVisible(wdwJob, true) showCursor(true, true) end end addEvent("showMedic", true) addEventHandler("onClientMarkerHit", theMarker, showJob) -- server side "onMarkerHit" was not working so I went to client side for it function hideJob() -- hides the window upon request guiSetVisible(wdwJob, false) showCursor(false, false) end addEvent("hideMedic", true) addEventHandler("hideMedic", localPlayer, hideJob) function jobHandler() -- tells the server when the player accepted the job triggerServerEvent("setJob", localPlayer) end I am not sure about the command part. I just left it in there so you can still code off it. Hopefully someone else can contribute and me and you can learn something. Link to comment
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