Price. Posted September 18, 2013 Share Posted September 18, 2013 guys this is a carjacker job, the problem is when you go into the marker it says accept/decline if i pressed accept nothing happens could you a help me please? Client sided: sx,sy = guiGetScreenSize() lp = getLocalPlayer() mr = math.random(1,2) window = guiCreateWindow(211,175,356,276,"Car Jacker",false) takebutton = guiCreateButton(76,248,71,14,"Accept",false,window) cancbutton = guiCreateButton(209,248,71,14,"Decline",false,window) label1 = guiCreateLabel(13,23,334,147,"Delivery Man.\nAs a deliver man\nYou need to deliver packages\nOnce you got the job, get in a Burrito.\n\n\nFor every package you deliver, you get:\n\n- Cash\n",false,window) guiLabelSetColor(label1,255,255,255) guiLabelSetVerticalAlign(label1,"top") guiLabelSetHorizontalAlign(label1,"left",false) guiSetFont(label1,"default-bold-small") label2 = guiCreateLabel(38,211,274,16,"If you click accept you will lose your current job!",false,window) guiLabelSetColor(label2,255,0,0) guiLabelSetVerticalAlign(label2,"top") guiLabelSetHorizontalAlign(label2,"left",false) guiSetFont(label2,"default-bold-small") guiWindowSetSizable(window, false) guiSetVisible(window,false) marker = createMarker(2394,-1242,23.5,"cylinder",2,170,30,0) theMarker = createMarker(0,0,-50,"cylinder",5,170,30,0) blip = createBlipAttachedTo(marker,56) addEventHandler("onClientMarkerHit",marker,function(p) if p == lp and not isPedInVehicle(lp) then guiSetVisible(window,true) showCursor(true) end end) addEventHandler("onClientGUIClick",window, function(b) if b == "left" then if source == takebutton then if getElementData(lp,"job") ~= "Carjacker" then triggerServerEvent("haveCarJob",lp) end elseif source == cancbutton then guiSetVisible(window,false) showCursor(false) end end end) addEvent("haveCarJob",true) function havejob(x,y) setElementPosition(theMarker,0,0,-50) outputChatBox("There is a vehicle available in "..getZoneName(x,y,0).."! Go and Find it!",255,0,0) end addEventHandler("haveCarJob",root,havejob) addEvent("carJack",true) function jackIt(x,y) outputChatBox("There is a vehicle available in "..getZoneName(x,y,0).."! Go and find it!",255,0,0) end addEventHandler("carJack",root,jackIt) addEventHandler("onClientVehicleStartEnter",root, function(p) if p == lp then if getElementData(source,"jack") and getElementData(lp,"job") ~= "Carjacker" then outputChatBox(""..getPlayerName(source).." has entered the vehicle!",255,0,0) end end end) addEvent("carJackSomeoneEntered",true) function someoneEntered() outputChatBox("Deliver the car to the buyer marked on your map!",255,0,0) end addEventHandler("carJackSomeoneEntered",root,someoneEntered) addEvent("carJackYouEntered",true) function IEntered(x,y,z) setElementPosition(theMarker,x,y,z) if not theBlip then theBlip = createBlipAttachedTo(theMarker,41) end outputChatBox("Deliver the car to the buyer marked on your map!",255,0,0) end addEventHandler("carJackYouEntered",root,IEntered) addEventHandler("onClientMarkerHit",theMarker, function(p) if p == lp and getElementData(lp,"job") == "Carjacker" and getElementData(getPedOccupiedVehicle(lp),"jack") then triggerServerEvent("carJackDeliver",lp) end end) addEvent("carJackDeliver",true) function deliver() if theBlip then destroyElement(theBlip) end outputChatBox(""..getPlayerName(source).." has delivered the vehicle!",255,0,0) end addEventHandler("carJackDeliver",root,deliver) bindKey("num_add","down",function() x,y,z = getElementPosition(lp) rz = getPedRotation(lp) outputChatBox(tostring(math.ceil(x))..","..tostring(math.ceil(y))..","..tostring(math.ceil(z))..","..tostring(math.ceil(rz))) veh = createVehicle(602,x,y,z,0,0,rz) setElementInterior(veh,15) end) Server Sided: routes = {{1137,-1033.6,32,270},{2860,-1908,11,180}} garages = {{1644,-1521,13}} vehicle = createVehicle(602,0,0,-50) theMarker = createMarker(0,0,-50,"arrow",2,255,0,0,255,getTeamFromName("Criminals")) attachElements(theMarker,vehicle,0,0,4) setElementData(vehicle,"jack",true) attached = 1 function reAttach() if attached == 1 then attachElements(theMarker,vehicle,0,0,3.9) elseif attached == 2 then attachElements(theMarker,vehicle,0,0,3.) elseif attached == 3 then attachElements(theMarker,vehicle,0,0,3.7) elseif attached == 4 then attachElements(theMarker,vehicle,0,0,3.6) elseif attached == 5 then attachElements(theMarker,vehicle,0,0,3.5) elseif attached == 6 then attachElements(theMarker,vehicle,0,0,3.4) elseif attached == 7 then attachElements(theMarker,vehicle,0,0,3.5) elseif attached == 8 then attachElements(theMarker,vehicle,0,0,3.6) elseif attached == 9 then attachElements(theMarker,vehicle,0,0,3.7) elseif attached == 10 then attachElements(theMarker,vehicle,0,0,3.) elseif attached == 11 then attachElements(theMarker,vehicle,0,0,3.9) elseif attached == 12 then attachElements(theMarker,vehicle,0,0,4) end if attached < 12 then attached = attached+1 else attached = 1 end end setTimer(reAttach,50,0) addEvent("haveCarJob",true) function haveBusJob() setElementData(source,"job","Carjacker") triggerClientEvent(source,"haveCarJob",root,TheX,TheY) end addEventHandler("haveCarJob",root,haveBusJob) function setCar() timer = 600 pos = math.random(1,table.maxn(routes)) disx = math.random(-150,150) disy = math.random(-150,150) for i,posi in ipairs(routes) do if i == pos then for a,z in ipairs(posi) do if a == 1 then x = z elseif a == 2 then y = z elseif a == 3 then setElementPosition(vehicle,x,y,z) triggerClients(x,y,z,disx,disy) elseif a == 4 then setElementRotation(vehicle,0,0,z) end end end end fixVehicle(vehicle) setElementHealth(vehicle,2000) end setTimer( function() timer = timer-1 if timer == 0 then setCar() end end,1000,0) function triggerClients(x,y,z,a,b) x = x+a y = y+b theX = x theY = y for i,p in ipairs(getElementsByType("player")) do if getElementData(p,"job") == "Carjacker" then triggerClientEvent(p,"carJack",p,x,y) end end end setTimer(setCar,900,1) addEventHandler("onVehicleStartEnter",root, function(p) if source == vehicle then if getElementData(p,"job") ~= "Carjacker" then setVehicleLocked(vehicle,true) else setVehicleLocked(vehicle,false) timer = 600 end end end) addEventHandler("onVehicleEnter",root, function(p) if source == vehicle then if getElementData(p,"job") ~= "Carjacker" then removePedFromVehicle(p) else theGarage = math.random(1,table.maxn(garages)) for i,garage in ipairs(garages) do if i == theGarage then for a,e in ipairs(garage) do if a == 1 then x = e elseif a == 2 then y = e elseif a == 3 then z = e end end end end for i,player in ipairs(getElementsByType("player")) do if player ~= p then triggerClientEvent(player,"carJackSomeoneEntered",p) else triggerClientEvent(player,"carJackYouEntered",p,x,y,z) end end end end end) addEvent("carJackDeliver",true) function deliver() money = math.random(0,3000) for i,player in ipairs(getElementsByType("player")) do if getElementData(player,"job") == "Carjacker" then money = money+1000 triggerClientEvent(player,"carJackDeliver",source) end end givePlayerMoney(source,money) removePedFromVehicle(source) setTimer(setElementPosition,300,1,vehicle,0,0,-50) setElementVelocity(vehicle,0,0,0) setTimer(setCar,3000,1) end addEventHandler("carJackDeliver",root,deliver) Link to comment
Price. Posted September 20, 2013 Author Share Posted September 20, 2013 dunno maybe, can you tell me the solution please? Link to comment
Dealman Posted September 20, 2013 Share Posted September 20, 2013 addEventHandler("onClientGUIClick",window, function(b) if b == "left" then if source == takebutton then if getElementData(lp,"job") ~= "Carjacker" then triggerServerEvent("haveCarJob",lp) end elseif source == cancbutton then guiSetVisible(window,false) showCursor(false) end end end) You're adding an event handler for onClientGUIClick, when "window" is clicked. Then you're checking to see if the source is "takebutton". I'd recommend you construct your code like this instead to make it less confusing and much easier to understand; function handleGUIEvents() if(source == takebutton) then if(getElementData(lp, "job") ~= "Carjacker") then triggerServerEvent("haveCarJob", lp) elseif(source == cancelbutton) then guiSetVisible(window, false) showCursor(false) end end end addEventHandler("onClientGUIClick", getRootElement(), handleGUIEvents) That way, source can be any GUI Element and you can just keep adding to it. Use comments to prevent it from becoming a labyrinth of code Link to comment
Price. Posted September 20, 2013 Author Share Posted September 20, 2013 now i cant even press decline Link to comment
Dealman Posted September 20, 2013 Share Posted September 20, 2013 'Cause you need to add it, like this; function handleGUIEvents() if(source == takebutton) then if(getElementData(lp, "job") ~= "Carjacker") then triggerServerEvent("haveCarJob", lp) elseif(source == cancelbutton) then guiSetVisible(window, false) showCursor(false) end end if(source == cancelbutton) then -- Do the shizzle here end end addEventHandler("onClientGUIClick", getRootElement(), handleGUIEvents) Link to comment
Price. Posted September 20, 2013 Author Share Posted September 20, 2013 (edited) uhm iam sorry what do you mean by "shizzle" also same. Edited September 20, 2013 by Guest Link to comment
Dealman Posted September 20, 2013 Share Posted September 20, 2013 Put whatever relevant code needs to be there. Link to comment
Price. Posted September 20, 2013 Author Share Posted September 20, 2013 will you just say it? i cant really put anything there D: Link to comment
Price. Posted September 20, 2013 Author Share Posted September 20, 2013 the whole scripts before i enter the marker and before i press accept/decline also when i press accept/decline nothing happens help!! Link to comment
Dealman Posted September 20, 2013 Share Posted September 20, 2013 Sorry, I just noticed a mistake I made Try this code instead; function handleGUIEvents() if(source == takebutton) then if(getElementData(lp, "job") ~= "Carjacker") then triggerServerEvent("haveCarJob", lp) end elseif(source == cancbutton) then guiSetVisible(window, false) showCursor(false) end end addEventHandler("onClientGUIClick", getRootElement(), handleGUIEvents) Link to comment
Price. Posted September 20, 2013 Author Share Posted September 20, 2013 now when i press accept nothing happens Link to comment
Dealman Posted September 20, 2013 Share Posted September 20, 2013 I'm not entirely sure as to what you want to accomplish, but post your current code and I'll fix it for you. Also if you could explained what you want, it would help Edit: Don't lose hope if I don't answer for a while, I blame GTA V Link to comment
Price. Posted September 20, 2013 Author Share Posted September 20, 2013 fk it i have hooker job problem now, i need a marker and opens me a gui when i press on the marker and there must be a Hooker team in tab , the problem is when i start blowjob or something like that it doesn't stop i guess i need setTimer i can do that but i need what i have stated above please Link to comment
EstrategiaGTA Posted September 21, 2013 Share Posted September 21, 2013 fk it i have hooker job problem now, i need a marker and opens me a gui when i press on the marker and there must be a Hooker team in tab , the problem is when i start blowjob or something like that it doesn't stop i guess i need setTimer i can do that but i need what i have stated above please A blowjob? lol. Use: setTimer ( function, time(ms), howmanytimes, function arguments) Link to comment
Price. Posted September 21, 2013 Author Share Posted September 21, 2013 well i need a spawner+ gui so when i press accept i get the job auto + there must be a hooker job team in the tab... 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