damien111 Posted August 4, 2012 Share Posted August 4, 2012 (edited) im new to this lua stuff, but i can code java script so i have a pretty good idea how stuff works. My Mechanic script creates a marker and a team. and when you are in the marker a GUI pops up. when you click the button it gives you a skin and switches your team. My medic script works the same way but gets a spray can that can heal with some other code. i am not sure how to make it when mechanic enters it fixes the car. heres my code atm. Mechanic-server.lua: function createMechanicTeam () MechanicTeam = createTeam ("Mechanic", 6, 183, 248) end addEventHandler ("onResourceStart", resourceRoot, createMechanicTeam) function joinMechanic() setPlayerTeam(source,MechanicTeam) setElementModel(source,268) setElementData( source, "Occupation", "Mechanic", true ) outputChatBox("You are now Mechanic.",source,0,255,0) end addEvent("setMechanic", true) addEventHandler("setMechanic",root,joinMechanic) addEvent("Mechanic:fixing", true) addEventHandler("Mechanic:fixing", root, function (Mechanic) if (getElementHealth(vechile) < 100) then fixVehicle(getPedOccupiedVehicle(getPlayerFromName(who))) --fixvechile if gets occupied if (VehHeal > 100) then setElementHealth(vechile, 100) end givePlayerMoney(Mechanic, 100) -- Gives 100$ to the Mechanic each time the function is executed takePlayerMoney(source, 100) -- Takes 100$ from the source when he get healed end end) mechanicj.lua: local marker = createMarker(1940.97, 2166.40, 10.82, "Cylinder", 2, 6, 183, 248, 153) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end windowjob = guiMyCwindow(301,250,"Mechanic job") guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,200,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,100,"To take Mechanic job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) guiEditSetReadOnly(GUIEditor_Memo[1],true) function Mechanicjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, Mechanicjob) function Mechanicjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, Mechanicjobleave) function joinTeam() triggerServerEvent("setMechanic",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeMechanicWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeMechanicWindow, false) addEventHandler("onClientPlayerDamage", localVechile, function(attacker, weapon, bodypart, loss) team = getPlayerTeam(attacker) if (attacker and getElementType(attacker) == "player" and weapon == 41 and team and getTeamName(team) == "Mechanic") then -- Checks if the player is using spray and is into Mechanic team cancelEvent() -- Cancels the damage cause by the spray if (not isTimer(pause)) then local health = getElementHealth(localVechile) if (health < 99) then triggerServerEvent("Mechanic:fixing", localVechile, attacker) -- Calls the Server Event pause = setTimer(function() end, 1000, 1) -- Makes a timer for the function so it won't fully heal in the first time end end end end) meta: "Damien" name="mechanic" version="0.1" type="script"/> Edited August 4, 2012 by Guest Link to comment
Castillo Posted August 4, 2012 Share Posted August 4, 2012 You want to fix the vehicle when player sprays the car? Edit: That script is not yours, is the same one from this topic: viewtopic.php?f=91&t=43535 Link to comment
damien111 Posted August 4, 2012 Author Share Posted August 4, 2012 i was using it to learn, but now, i am trying to make it when a member from the mechanic am gets in a car with someone it fixs the car and deducts money and adds money to the mechanic 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