Jump to content

WolfPire

Members
  • Posts

    141
  • Joined

  • Last visited

Everything posted by WolfPire

  1. Thanks n_n works now =) EDIT: a Wild problem has appeared! Can you help me with the vehicle checking? i want them to stop if there's no planes or helis near by
  2. So ok i made an amazing A69 sams script. But i got a lil' problem... Seems like the sams will keep spawning no matter if the user got off the vehicle or the vehicle dissapeared. I tried to kill the timers in many ways and i couldn't seem to find a solution. Could you guys please help me? Client MissileSite1 = createObject( 3884, 233.60000610352, 1934.5999755859, 32.500001525879 ) MissileSite2 = createObject( 3884, 267.20001220703, 1895.0999755859, 32.500001525879 ) MissileSite3 = createObject( 3884, 262, 1807.8000488281, 32.500001525879 ) MissileSite4 = createObject( 3884, 166.10000610352, 1849.9000244141, 32.500001525879 ) MissileSite5 = createObject( 3884, 113.40000152588, 1814, 32.500001525879 ) MissileSite6 = createObject( 3884, 103.80000305176, 1901, 32.500001525879 ) MissileSite7 = createObject( 3884, 162, 1932.9000244141, 32.500001525879 ) ------------------------------------------------------------------------------ function Missile1() if target then createProjectile ( localPlayer, 20 , 235.60000610352, 1939.5999755859, 34.90000152587, 1.0, target, 0, 60, 0, 0, 0, 0 ) else if target == nil then killTimer(samsTimer1) end end end function samson1() target = getPedOccupiedVehicle(getLocalPlayer()) if isPedInVehicle(localPlayer) then if (getVehicleType" class="kw2">getVehicleType(target) == "Plane" or "Helicopter") then if source == MissileSite1 then samsTimer1 = setTimer(Missile1, 2000, 0) end end end end addEventHandler("onClientElementStreamIn", root, samson1) function samsoff1() if samsTimer1 then if source == MissileSite1 then killTimer(samsTimer1) end end end addEventHandler("onClientElementStreamOut", root, samsoff1) ----------------- Sams 2 ----------------- function Missile2() if target then createProjectile ( localPlayer, 20 , 268, 1899, 34.90000152587, 1.0, target, 0, 60, 0, 0, 0, 0 ) else if target == nil then killTimer(samsTimer2) end end end function samson2() target = getPedOccupiedVehicle(getLocalPlayer()) if isPedInVehicle(localPlayer) then if (getVehicleType" class="kw2">getVehicleType(target) == "Plane" or "Helicopter") then if source == MissileSite2 then samsTimer2 = setTimer(Missile2, 2000, 0) end end end end addEventHandler("onClientElementStreamIn", root, samson2) function samsoff2() if samsTimer2 then if source == MissileSite2 then killTimer(samsTimer2) end end end addEventHandler("onClientElementStreamOut", root, samsoff2) ----------------- Sams 3 ----------------- function Missile3() if target then createProjectile ( localPlayer, 20 , 263, 1812, 34.90000152587, 1.0, target, 0, 60, 0, 0, 0, 0 ) else if target == nil then killTimer(samsTimer3) end end end function samson3() target = getPedOccupiedVehicle(getLocalPlayer()) if isPedInVehicle(localPlayer) then if (getVehicleType" class="kw2">getVehicleType(target) == "Plane" or "Helicopter") then if source == MissileSite3 then samsTimer3 = setTimer(Missile3, 2000, 0) end end end end addEventHandler("onClientElementStreamIn", root, samson3) function samsoff3() if samsTimer3 then if source == MissileSite3 then killTimer(samsTimer3) end end end addEventHandler("onClientElementStreamOut", root, samsoff3) ----------------- Sams 4 ----------------- function Missile4() if target then createProjectile ( localPlayer, 20 , 167, 1854, 34.90000152587, 1.0, target, 0, 60, 0, 0, 0, 0 ) else if target == nil then killTimer(samsTimer4) end end end function samson4() target = getPedOccupiedVehicle(getLocalPlayer()) if isPedInVehicle(localPlayer) then if (getVehicleType" class="kw2">getVehicleType(target) == "Plane" or "Helicopter") then if source == MissileSite4 then samsTimer4 = setTimer(Missile4, 2000, 0) end end end end addEventHandler("onClientElementStreamIn", root, samson4) function samsoff4() if samsTimer4 then if source == MissileSite4 then killTimer(samsTimer4) end end end addEventHandler("onClientElementStreamOut", root, samsoff4) ----------------- Sams 5 ----------------- function Missile5() if target then createProjectile ( localPlayer, 20 , 115, 1818, 34.90000152587, 1.0, target, 0, 60, 0, 0, 0, 0 ) else if target == nil then killTimer(samsTimer5) end end end function samson5() target = getPedOccupiedVehicle(getLocalPlayer()) if isPedInVehicle(localPlayer) then if (getVehicleType" class="kw2">getVehicleType(target) == "Plane" or "Helicopter") then if source == MissileSite5 then samsTimer5 = setTimer(Missile5, 2000, 0) end end end end addEventHandler("onClientElementStreamIn", root, samson5) function samsoff5() if samsTimer5 then if source == MissileSite5 then killTimer(samsTimer5) end end end addEventHandler("onClientElementStreamOut", root, samsoff5) ----------------- Sams 6 ----------------- function Missile6() if target then createProjectile ( localPlayer, 20 , 105, 1905, 34.90000152587, 1.0, target, 0, 60, 0, 0, 0, 0 ) else if target == nil then killTimer(samsTimer6) end end end function samson6() target = getPedOccupiedVehicle(getLocalPlayer()) if isPedInVehicle(localPlayer) then if (getVehicleType" class="kw2">getVehicleType(target) == "Plane" or "Helicopter") then if source == MissileSite6 then samsTimer6 = setTimer(Missile6, 2000, 0) end end end end addEventHandler("onClientElementStreamIn", root, samson6) function samsoff6() if samsTimer6 then if source == MissileSite6 then killTimer(samsTimer6) end end end addEventHandler("onClientElementStreamOut", root, samsoff6) ----------------- Sams 7 ----------------- function Missile7() if target then createProjectile ( localPlayer, 20 , 163, 1937, 34.90000152587, 1.0, target, 0, 60, 0, 0, 0, 0 ) else if target == nil then killTimer(samsTimer7) end end end function samson7() target = getPedOccupiedVehicle(getLocalPlayer()) if isPedInVehicle(localPlayer) then if (getVehicleType" class="kw2">getVehicleType(target) == "Plane" or "Helicopter") then if source == MissileSite7 then samsTimer7 = setTimer(Missile7, 2000, 0) end end end end addEventHandler("onClientElementStreamIn", root, samson7) function samsoff7() if samsTimer7 then if source == MissileSite7 then killTimer(samsTimer7) end end end
  3. So i'm making my "Car Of The Day" script which allows everyone to buy a brand new car with upgrades and all... but i got a little problem... Whenever i try to set the daily ID it will return me in the debug "setElementModel" <--- Bad Argument. Here's the client, the server won't be necessary. function IDm() if not IDT then IDT = setTimer(IDs, 86400000, 0) end end addEventHandler("onClientResourceStart", root, IDm) function IDs() ID = math.random(400,611) end Shop = createMarker( -1658, 1211, 6.4, "cylinder", 1, 0, 255, 0) function ShopF(theElement) if isPedOnGround(theElement) then if not isPedInVehicle(theElement) then if (theElement ~= localPlayer) then return end -- If the player who hit the colshape isn't the client, cancel the function. CarOfTheDay = createVehicle( 411, -1655, 1209, 21 ) setElementModel(CarOfTheDay, ID) if ( getVehicleType" class="kw2">getVehicleType" class="kw2">getVehicleType( CarOfTheDay ) == "Automobile" ) then showCursor(true) setCameraMatrix( -1664, 1210, 22, 6000, 0, 0, 0, 0) setVehicleColor( CarOfTheDay, math.random(0,255), math.random(0,255), math.random(0,255) ) setElementFrozen( CarOfTheDay, true ) showPlayerHudComponent("all", false) LeftB = guiCreateButton(342,684,176,57,"< Left",false) guiSetFont(LeftB,"default-bold-small") RightB = guiCreateButton(737,684,176,57,"Right >",false) guiSetFont(RightB,"default-bold-small") ExitB = guiCreateButton(539,714,174,26,"Exit",false) guiSetFont(ExitB,"default-bold-small") BuyB = guiCreateButton(539,689,174,26,"Buy",false) guiSetFont(BuyB,"default-bold-small") VehicleL = guiCreateLabel(539,724,174,26,"Vehicle: " .. getVehicleNameFromModel(getElementModel(CarOfTheDay)) .. "",false) guiSetFont(VehicleL,"default-bold-small") guiLabelSetColor ( VehicleL, 0, 0, 255 ) addEventHandler( "onClientGUIClick",LeftB,LeftFEnter,false ) addEventHandler( "onClientGUIClick",RightB,RightFEnter,false ) addEventHandler( "onClientGUIClick",BuyB,BuyF,false ) addEventHandler( "onClientGUIClick",ExitB,ExitF,false ) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(LeftB,false) local x,y = (screenW-windowW)/3.14,(screenH-windowH)/1.01 guiSetPosition(LeftB,x,y,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(RightB,false) local x,y = (screenW-windowW)/1.58,(screenH-windowH)/1.01 guiSetPosition(RightB,x,y,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(ExitB,false) local x,y = (screenW-windowW)/2.1,(screenH-windowH)/1.011 guiSetPosition(ExitB,x,y,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(BuyB,false) local x,y = (screenW-windowW)/2.1,(screenH-windowH)/1.047 guiSetPosition(BuyB,x,y,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(VehicleL,false) local x,y = (screenW-windowW)/1.95,(screenH-windowH)/1.07 guiSetPosition(VehicleL,x,y,false) else outputChatBox( "No car found, please re-enter the marker", 255, 0, 0 ) destroyElement(CarOfTheDay) return end end end end addEventHandler("onClientMarkerHit",Shop,ShopF) function LeftFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ + 10) end end function RightFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ - 10) end end function BuyF() CW = guiCreateWindow(470,244,543,180,"Confirmation",false) CL = guiCreateLabel(2,47,545,20,"Are you sure you want to buy this car for $3.000?",false,CW) guiLabelSetColor(CL,0,255,0) guiLabelSetHorizontalAlign(CL,"center",false) guiSetFont(CL,"default-bold-small") YesB = guiCreateButton(59,115,159,39,"Yes",false,CW) NoB = guiCreateButton(322,115,159,39,"No",false,CW) addEventHandler("onClientGUIClick",NoB,NoF,false) addEventHandler("onClientGUIClick",YesB,YesF,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(CW,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(CW,x,y,false) end function NoF() destroyElement(CW) end function YesF() destroyElement(CW) destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(VehicleL) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) colr1, colg1, colb1, colr2, colg2, colb2, colr3, colg3, colb3, colr4, colg4, colb4 = getVehicleColor(CarOfTheDay, true) Model = getElementModel(CarOfTheDay) destroyElement(CarOfTheDay) triggerServerEvent("spawnCar",getRootElement(),localPlayer, Model, colr1, colg1, colb1, colr2, colg2, colb2, colr3, colg3, colb3, colr4, colg4, colb4) showCursor(false) end function onStop() setCameraTarget(localPlayer) end addEventHandler("onClientResourceStop",root,onStop) function ExitF() if not CW then destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(VehicleL) destroyElement(CarOfTheDay) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) else if CW then destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(VehicleL) destroyElement(CarOfTheDay) destroyElement(CW) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) end end end
  4. It works now =D My system is complete. Thank you =) May i kiss you? Well.. better not if i'm not a girl. Thanks for you help! Everyone!!!! You're always welcome to my server in "Oriental Night Gaming"
  5. I get an error when touching the reward marker. "ERROR: JobsONG/jobs_s.lua:72: bad argument #1 to 'ceil' (number expected, got boolean)"
  6. Works like charm Now one more thing, do the same. But as for when the player exit's the truck! After that, i gotta test the reward part and we're done in here =) P.S: In the explosión the text color doesn't change, any idea why this?
  7. Console outputs error: " ERROR: JobsONG/jobs_s.lua:56: ')' expected near 'kw2' " <---- ??? ^ Another error with the same but saying that the loading of the script failed.
  8. When the vehicle explodes, it doesn't get destroyed.
  9. Possibly an MTA Problem?... Well i'll just get the Truck's HP then. EDIT: function Fail( theVehicle ) outputChatBox("Congratulations, you've earned a free...", source, 0, 255, 0) setTimer( outputChatBox, 1000, 1, "GTFO.", source, 255, 0, 0 ) triggerClientEvent("markersOn",root) triggerClientEvent("destroyFail",root, source) if isElement(vehicles[source]["truck"]) then destroyElement(vehicles[source]["truck"]) end if isElement(vehicles[source]["trailer"]) then destroyElement(vehicles[source]["trailer"]) end end ^ Server. Doesn't work.
  10. Works now but we got 2 issues. 1. Trailer's HP will be "0". (Unless attached) 2. Trailer won't loose health.
  11. Solid, Your code is winning so far. Tho' it outputs me many errors in the debug they all say... "ERROR: JobsONG//jobs_c.lua:37: bad argument #1 to 'ceil' (number expected, got nil)"... Whenever i crash the vehicle. Kenix, your codes were correct but it had many errors that prevent the script from working. Thanks for the help anyways. Scooby, actually it's only triggered by the localPlayer, tested with other people and works perfectly.
  12. So... Remember the jobs script? I'm just 99% to complete it and i really need help on this one guys, please! ___________________________________________________________________________________________________________ Client DeliveryLocations = { "-1838, 14, 16, 0", "-1708, 12, 4, 0", "-2464, 787, 36, 0", "-1935, 272, 42, 0", "653, 1691, 8, 0", "1052, 2088, 11, 0", "2185, 1976, 11, 0", "2868, 2577, 11, 0", "2244, 2234, 11, 0", "2351, 1891, 11, 0", "2842, 899, 11, 0", "2793, -2417, 14, 0", "2057, -2195, 14, 0", "1619, -1554, 14, 0", "988, -913, 43, 0", "1340, 285, 20, 0", "2260, -85, 27, 0", "708, -607, 17, 0", "202, -173, 2, 0", "-546, -499, 26, 0", "-1019, -649, 33, 0", "-165, 1016, 21, 0", "273, 1344, 12, 0" } ----------------------------------------------------------- local sWidth,sHeight = guiGetScreenSize() local loca = {} local DeliveryLocationTableSize = table.maxn ( DeliveryLocations ) local randomLocationIdx = math.random ( 1, DeliveryLocationTableSize ) local locString = tostring( DeliveryLocations[randomLocationIdx] ) loca.Location = split ( locString, string.byte( "," ) ) local DelX = loca.Location[1] local DelY = loca.Location[2] local DelZ = loca.Location[3] JobStart = createColSphere( -50, -271, 5.7, 1 ) JobStartM = createMarker( -50, -271, 5.7, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) function giveVehicle( theElement ) if ( theElement == getLocalPlayer() ) then removeEventHandler("onClientColShapeHit",JobStart,giveVehicle) triggerServerEvent("start",root, theElement) addEventHandler("onClientRender",root,renderHP) destroyElement(JobStart) destroyElement(JobStartM) destroyElement(JobStartB) end end addEventHandler("onClientColShapeHit",JobStart,giveVehicle) addEvent("HP",true) addEventHandler("HP",root, function(mVehicle, mTrailer) TruckHP = getElementHealth(mVehicle) TrailerHP = getElementHealth(mTrailer) TruckHP2 = tonumber(TruckHP) TrailerHP2 = tonumber(TrailerHP) TruckHPF = math.ceil(TruckHP2) TrailerHPF = math.ceil(TrailerHP2) end ) function renderHP() truHP = dxDrawText("HP(Truck): " .. tostring(TruckHPF) .. "", sWidth/1.2,sHeight-47, sWidth, sHeight ) traHP = dxDrawText("HP(Trailer): " .. tostring(TrailerHPF) .. "", sWidth/1.2,sHeight-57, sWidth, sHeight ) end addEvent("trailerAtt",true) addEventHandler("trailerAtt",root, function() Destiny = createColSphere( DelX, DelY, DelZ, 3 ) DestinyM = createMarker( DelX, DelY, DelZ, "cylinder", 3, 0, 200, 0 ) DestinyB = createBlipAttachedTo( Destiny, 52 ) addEventHandler("onClientColShapeHit",Destiny,Reward) end ) addEvent("trailerDet",true) addEventHandler("trailerDet",root, function() removeEventHandler("onClientRender",root,renderHP) destroyElement(Destiny) destroyElement(DestinyM) destroyElement(DestinyB) end ) addEvent("markersOn",true) addEventHandler("markersOn",root, function() JobStart = createColSphere( -50, -271, 5.7, 1 ) JobStartM = createMarker( -50, -271, 5.7, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) addEventHandler("onClientColShapeHit",JobStart,giveVehicle) end ) addEvent("destroyWin",true) addEventHandler("destroyWin",root, function( theElement ) if ( theElement == getLocalPlayer() ) then removeEventHandler("onClientRender",root,renderHP) JobStart = createColSphere( -50, -271, 5.7, 1 ) JobStartM = createMarker( -50, -271, 5.7, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) addEventHandler("onClientColShapeHit",JobStart,giveVehicle) end end ) addEvent("destroyFail",true) addEventHandler("destroyFail",root, function() removeEventHandler("onClientRender",root,renderHP) if (Destiny) then if (DestinyM) then if (DestinyB) then removeEventHandler("onClientRender",root,renderHP) destroyElement(Destiny) destroyElement(DestinyM) destroyElement(DestinyB) end end end end ) addEvent("destroyFailE",true) addEventHandler("destroyFailE",root, function() removeEventHandler("onClientRender",root,renderHP) if (Destiny) then if (DestinyM) then if (DestinyB) then destroyElement(Destiny) destroyElement(DestinyM) destroyElement(DestinyB) end end end end ) function Reward( theElement ) if ( theElement == getLocalPlayer() ) then removeEventHandler("onClientRender",root,renderHP) triggerServerEvent("win",root, theElement) destroyElement(Destiny) destroyElement(DestinyM) destroyElement(DestinyB) end end Server addEvent("start",true) addEventHandler("start",root, function( theElement ) if theElement then mVehicle = createVehicle( 403, -22, -291, 6, 0, 0, 180 ) mTrailer = createVehicle ( 435, -14, -285, 7, 0, 0, 180 ) triggerClientEvent("HP",root,mVehicle,mTrailer) warpPedIntoVehicle(theElement, mVehicle) end end ) function FailE() if (source == mTrailer or mVehicle) then outputChatBox("Congratulations, you've earned a free...", getVehicleController(source), 0, 255, 0) setTimer( outputChatBox, 1000, 1, "GTFO. For making the vehicle go BOOM! And we ain't paying the hospital.", getVehicleController(source), 255, 0, 0 ) triggerClientEvent("markersOn",root) triggerClientEvent("destroyFail",root) destroyElement(mVehicle) destroyElement(mTrailer) end end addEventHandler("onVehicleExplode",root,FailE) addEvent("win",true) addEventHandler("win",root, function( theElement ) if theElement then vHP = getElementHealth(mVehicle) vTHP = getElementHealth(mTrailer) Money = 3000 + math.ceil(vHP) + math.ceil(vTHP) outputChatBox("Thanks, your reward is " .. Money .. "$", theElement, 0, 255, 0) triggerClientEvent("destroyWin",root, theElement) givePlayerMoney( theElement, Money) destroyElement(mVehicle) destroyElement(mTrailer) end end ) function attachT( theTruck ) if (source == mTrailer) then outputChatBox("Deliver these parts to the indicated location. Do no step out of the vehicle or loose your trailer. if so YOU'RE FIRED.", getVehicleController(theTruck), 0, 255, 0) triggerClientEvent("trailerAtt",root) end end addEventHandler("onTrailerAttach",root,attachT) function detachT( theTruck ) if (source == mTrailer) then outputChatBox("Nice fail, you just lost your trailer.", getVehicleController(theTruck), 0, 255, 0) setTimer(outputChatBox,1500,1,"Oh yeah... YOU'RE FIRED.", getVehicleController(theTruck), 255, 0, 0) triggerClientEvent("trailerDet",root) triggerClientEvent("markersOn",root) destroyElement(mVehicle) destroyElement(mTrailer) end end addEventHandler("onTrailerDetach",root,detachT) function Fail( theVehicle ) if (source) and ( theVehicle == mVehicle) then outputChatBox("Congratulations, you've earned a free...", source, 0, 255, 0) setTimer( outputChatBox, 1000, 1, "GTFO.", source, 255, 0, 0 ) triggerClientEvent("markersOn",root) triggerClientEvent("destroyFail",root, source) destroyElement(mVehicle) destroyElement(mTrailer) end end addEventHandler("onPlayerVehicleExit",root,Fail) The problem is: I'm trying to use math.ceil and tostring. To get the exact vehicle HP, and because the vehicles are created server-side and i can't just get the element hp. I needed to create an event. So everythign is perfect. But Health does not update.
  13. No i test this if you lock car and exit and again enter then your car unlock. So you need lock car. You said if this car owner then unlock car. Just change the code as you want. Ook! Thanks anyways =) Sorry for the Trouble c:
  14. fixed it myself. Thanks for the help tho' =) <3 function fire() outputChatBox("Congratulations, you've earned a free...", playa, 0, 255, 0) setTimer( outputChatBox, 1000, 1, "GTFO.", playa, 255, 0, 0 ) end addEvent("win",true) addEventHandler("win",root, function( localPlayer ) outputChatBox("Thanks, your reward is 5000$", localPlayer, 0, 255, 0) triggerClientEvent("markersOn",root) givePlayerMoney( localPlayer, 5000) end ) addEvent("start",true) addEventHandler("start",root, function( theElement ) if theElement then outputChatBox("Deliver these parts to Pay N' Spray. Do no step out of the vehicle or YOU'RE FIRED.", theElement, 0, 255, 0) mVehicle = createVehicle( 462, -2755, 203, 7 ) warpPedIntoVehicle(theElement, mVehicle) end end ) function Fail() if (mVehicle) then triggerClientEvent("markersOn",root) destroyElement(mVehicle) end end addEventHandler("onPlayerVehicleExit",root,Fail) ^ Server. DeliveryLocations = { "-2572, 1150, 56, 0", "-2398, 1130, 56, 0", "-2462, 792, 35, 0" } ----------------------------------------------------------- local loca = {} local DeliveryLocationTableSize = table.maxn ( DeliveryLocations ) local randomLocationIdx = math.random ( 1, DeliveryLocationTableSize ) local locString = tostring( DeliveryLocations[randomLocationIdx] ) loca.Location = split ( locString, string.byte( "," ) ) local DelX = loca.Location[1] local DelY = loca.Location[2] local DelZ = loca.Location[3] JobStart = createColSphere( -2749, 204, 8, 1 ) JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) function giveVehicle( theElement ) if ( theElement == getLocalPlayer() ) then destroyElement(JobStart) destroyElement(JobStartM) destroyElement(JobStartB) triggerServerEvent("start",root, theElement) Destiny = createColSphere( DelX, DelY, DelZ, 3 ) DestinyM = createMarker( DelX, DelY, DelZ, "cylinder", 3, 0, 200, 0 ) DestinyB = createBlipAttachedTo( Destiny, 52 ) addEventHandler("onClientColShapeHit",Destiny,Reward) end end addEventHandler("onClientColShapeHit",JobStart,giveVehicle) addEvent("markersOn",true) addEventHandler("markersOn",root, function() JobStart = createColSphere( -2749, 204, 8, 1 ) JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) end ) function Reward() triggerServerEvent("win",root, localPlayer) end ^ Client. used "if ( theElement == getLocalPlayer() ) then". EDIT: New issue. Client DeliveryLocations = { "-2572, 1150, 56, 0", "-2398, 1130, 56, 0", "-2462, 792, 35, 0" } ----------------------------------------------------------- local loca = {} local DeliveryLocationTableSize = table.maxn ( DeliveryLocations ) local randomLocationIdx = math.random ( 1, DeliveryLocationTableSize ) local locString = tostring( DeliveryLocations[randomLocationIdx] ) loca.Location = split ( locString, string.byte( "," ) ) local DelX = loca.Location[1] local DelY = loca.Location[2] local DelZ = loca.Location[3] JobStart = createColSphere( -2749, 204, 8, 1 ) JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) function giveVehicle( theElement ) if ( theElement == getLocalPlayer() ) then removeEventHandler("onClientColShapeHit",JobStart,giveVehicle) destroyElement(JobStart) destroyElement(JobStartM) destroyElement(JobStartB) triggerServerEvent("start",root, theElement) Destiny = createColSphere( DelX, DelY, DelZ, 3 ) DestinyM = createMarker( DelX, DelY, DelZ, "cylinder", 3, 0, 200, 0 ) DestinyB = createBlipAttachedTo( Destiny, 52 ) addEventHandler("onClientColShapeHit",Destiny,Reward) end end addEventHandler("onClientColShapeHit",JobStart,giveVehicle) addEvent("markersOn",true) addEventHandler("markersOn",root, function() JobStart = createColSphere( -2749, 204, 8, 1 ) JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) addEventHandler("onClientColShapeHit",JobStart,giveVehicle) end ) function Reward() triggerServerEvent("win",root, localPlayer) end When exiting the vehicle, the markers will retun to normal state, but when triggered again, they will triggerd the "Reward function as well" and double the money (major bug) Edit: Solved.
  15. Well tried, it is indeed a nice way to detect more specificly. but... No, seems like my double vehicle problem is not over x_x
  16. Well... Used colshapes. Markers are problematic as for tiggering, they have a strange bug that also makes them trigger no matter what's your "Z" position. So it would be a problem when someone is driving a plane. Colshape for function triggering and markers to make em' visible. Used "theElement" instead of "hitElemt" as i noticed it changed in the wiki I'll try that, ty.
  17. So... I'm working in a job's script which consist in the delivery of many things to different places. The problem is that whenever i start the delivery, i get 2 Faggios and i just want to spawn one. I don't see where's the problem on this. Can you guys please help me once again? =) Thanks Server function fire() outputChatBox("Congratulations, you've earned a free...", playa, 0, 255, 0) setTimer( outputChatBox, 1000, 1, "GTFO.", playa, 255, 0, 0 ) end addEvent("win",true) addEventHandler("win",root, function( localPlayer ) outputChatBox("Thanks, your reward is 5000$", localPlayer, 0, 255, 0) triggerClientEvent("markersOn",root) givePlayerMoney( localPlayer, 5000) end ) addEvent("start",true) addEventHandler("start",root, function( source ) if source then outputChatBox("Deliver these parts to Pay N' Spray. Do no step out of the vehicle or YOU'RE FIRED.", source, 0, 255, 0) mVehicle = createVehicle( 462, -2755, 203, 7 ) warpPedIntoVehicle(source, mVehicle) end end ) function Fail() if (mVehicle) then triggerClientEvent("destroyFail",root) triggerClientEvent("markersOn",root) destroyElement(mVehicle) end end addEventHandler("onPlayerVehicleExit",root,Fail) Client DeliveryLocations = { "-2572, 1150, 56, 0", "-2398, 1130, 56, 0", "-2462, 792, 35, 0" } ----------------------------------------------------------- local loca = {} local DeliveryLocationTableSize = table.maxn ( DeliveryLocations ) local randomLocationIdx = math.random ( 1, DeliveryLocationTableSize ) local locString = tostring( DeliveryLocations[randomLocationIdx] ) loca.Location = split ( locString, string.byte( "," ) ) local DelX = loca.Location[1] local DelY = loca.Location[2] local DelZ = loca.Location[3] JobStart = createColSphere( -2749, 204, 8, 1 ) JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) function giveVehicle( source ) if source then destroyElement(JobStart) destroyElement(JobStartM) destroyElement(JobStartB) triggerServerEvent("start",root, source) Destiny = createColSphere( DelX, DelY, DelZ, 3 ) DestinyM = createMarker( DelX, DelY, DelZ, "cylinder", 3, 0, 200, 0 ) DestinyB = createBlipAttachedTo( Destiny, 52 ) addEventHandler("onClientColShapeHit",Destiny,Reward) end end addEventHandler("onClientColShapeHit",JobStart,giveVehicle) addEvent("markersOn",true) addEventHandler("markersOn",root, function() JobStart = createColSphere( -2749, 204, 8, 1 ) JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) JobStartB = createBlipAttachedTo( JobStart, 58 ) end ) function Reward() triggerServerEvent("win",root, localPlayer) end Honto ni, arigato =)
  18. Works perfectly. I found another bug. Which makes it work incorrectly. I can lock it and unlock it once. then it will just only keep unlocking it. And second, when you get outside and inside the car, it will +1 the unlocking function. Thanks for your help, Kenix =)
  19. Sorry for interrupting your sleeptime >w< It works now but it has a big major bug... I press "l" and i get triple "You vehicle has been unlocked."
  20. Woah!... And i got 2 errors now... When the client enters the vehicle: "ERROR: lockONG/lockong.lua:17: attempt to index a boolean value" When the client exits the vehicle: "ERROR: lockONG/lockong.lua:30: attempt to index a boolean value"
  21. Actually, no =P Because as you saw... If all those conditions will be passed, the vehicle will unlock. So, actually it should be like it is... What i mean with "setElementData" is... 1. Get the player's name. 2. Save it 3. Whenever the players leaves the car, the name is saved. 4. If another player tries to get in the car, it wont be able. (setElementData is not present here) 5. But now if the original player returns to the car. The vehicle will open itself (if locked) Note: Wierdly i had another experiences with car locks system that whenever you were getting out of the car, you could lock the car and then you couldn't get in again as it would be closed. The idea is not to let anyone lock the car unless its the vehicle creator =P Thanks for your patience though =)
  22. Well i wanted to use "setElementData" and "getElementData" to get the actual player occupying a vehicle. So the vehicle will lock ONLY if the player that got in first triggers the function. So it doesn't just get stolen by anoyne else (as i also want it to unlock itself when the owner player gets inside the vehicle) Thanks GanJa and Kenix =) But it still doesn't work, my vehicle doesn't get locked and no outputChatBox appears, i'm hoping it's just a condition (if) problem.
×
×
  • Create New...