Leonard.DC Posted June 8, 2014 Share Posted June 8, 2014 Srv Side: pickupM1 = createPickup (1058.2626953125, -1032.2587890625, 32.042984008789, 3, 1239, 1) pickupM2 = createPickup (2127.4814453125, -1147.63671875, 24.440776824951, 3, 1239, 1) function openGUIMiniJobMec (hitElement) if (hitElement and getElementType(hitElement) == "player" and not isPedInVehicle (hitElement)) then if getPlayerTeam ( hitElement ) == getTeamFromName ( "Mechanic" ) then triggerClientEvent (hitElement, "openTheGUIMiniMec", hitElement) cancelEvent () else outputChatBox ("*********", hitElement, 255, 0, 0) cancelEvent () end end end addEventHandler ("onPickupHit", pickupM1, openGUIMiniJobMec) addEventHandler ("onPickupHit", pickupM2, openGUIMiniJobMec) function finishMiniJobMecSrv() givePlayerMoney (source, 3000) end addEvent ("finishMiniJobMec", true) addEventHandler("finishMiniJobMec", root, finishMiniJobMecSrv) function creVehMiniJobEvent () local x,y,z = getElementPosition (source) local theveh = createVehicle (525,x,y,z) warpPedIntoVehicle (source, theveh, 0) end addEvent ("createMiniJobMecVeh", true) addEventHandler("createMiniJobMecVeh", root, creVehMiniJobEvent) function AttachTheTrailerSrv () addEventHandler("onTrailerAttach", resourceRoot, aUnamedFunction1) end addEvent ("AttachTheTrailer123", true) addEventHandler("AttachTheTrailer123", root, AttachTheTrailerSrv) function aUnamedFunction1() triggerServerEvent (source, "mechanictriggernow1", source) end function AttachTheTrailerSrv2() addEventHandler("onTrailerDetach", resourceRoot, aUnamedFunction2) end addEvent ("AttachTheTrailer12345", true) addEventHandler("AttachTheTrailer12345", root, AttachTheFuckinTrailerSrv) function aUnamedFunction2() triggerServerEvent (source, "mechanictriggernow2", source) end Cl Side window = guiCreateWindow(434, 321, 420, 398, "Mech Minijob", false) guiWindowSetSizable(window , false) guiSetVisible( window , false ) acceptm = guiCreateButton(10, 292, 180, 96, "Acept", false, window ) guiSetFont(acceptm , "default-bold-small") close = guiCreateButton(230, 292, 180, 96, "NO", false, window ) guiSetFont(cerrarm, "default-bold-small") memom = guiCreateMemo(10, 26, 400, 249, "*******************", false, window ) guiMemoSetReadOnly(memom, true) function openTheGUIMiniMecCl() guiSetVisible (window , true) showCursor (true) end addEvent ("openTheGUIMiniMec", true) addEventHandler("openTheGUIMiniMec", root, openTheGUIMiniMecCl) vehicleslocations = { {2052.7880859375, -1905.509765625, 13.546875}, {2191.0205078125, -2251.978515625, 13.509453773499}, {2370.25, -1938.7373046875, 13.546875}, {835.4384765625, -2051.4296875, 12.8671875}, {384.708984375, -2079.1875, 7.8300905227661}, {405.171875, -1153.5087890625, 77.260643005371}, {2300.0322265625, -1439.8896484375, 24}, {1904.9677734375, -1782.392578125, 13.546875}, {2409.6337890625, -1138.8134765625, 30.617359161377}, {2679.671875, -2531.0771484375, 13.306663513184}, {1560.0185546875, -2313.302734375, 13.544898033142} } idlist = { 602, 410, 545, 436, 551 } vehid = idlist[math.random(#idlist)] function createMiniJobEventMec () local loc = math.random(1,#vehicleslocations) vehicleToGive = createVehicle(vehid, vehicleslocations[loc][1], vehicleslocations[loc][2], vehicleslocations[loc][3]) vehicleToGiveBlip = createBlipAttachedTo(vehicleToGive, 41, localPlayer) triggerServerEvent ("AttachTheTrailer123", localPlayer) setVehicleDamageProof (vehicleToGive, true) setElementHealth (vehicleToGive, 450) setVehicleEngineState ( vehicleToGive, false ) setVehicleLocked ( vehicleToGive, true ) end addEventHandler ("onClientGUIClick", root, function () if (source == acceptm) then guiSetVisible (window, false) showCursor (false) triggerServerEvent ("createMiniJobMecVeh", localPlayer) outputChatBox ("Go to the icon", 255, 255, 0) createMiniJobEventMec () playSound ("fail.mp3") elseif (source == close) then guiSetVisible (window, false) showCursor (false) end end) function createMarkerFinalMiniJobMec () marker = createMarker (1669.40234375, -1065.4619140625, 22.8984375, "cylinder", 3, 255, 255, 0, 255, localPlayer) blip = createBlip (1669.40234375, -1065.4619140625, 22.8984375, 60, localPlayer) outputChatBox ("Go and leave the car", 255, 255, 0) addEventHandler ("onClientMarkerHit", marker, rewardMecJob) triggerServerEvent ("AttachTheTrailer12345", localPlayer) end addEvent ("mechanictriggernow1", true) addEventHandler("mechanictriggernow1", root, createMarkerFinalMiniJobMec) function destroyMarkerAndBlipMiniJob () destroyElement (marker ) destroyElement (blip ) outputChatBox ("Ops, Fail xD", 255, 0, 0) end addEvent ("mechanictriggernow2", true) addEventHandler("mechanictriggernow2", root, destroyMarkerAndBlipMiniJob) function rewardMecJob(hitElement) if (hitElement == localPlayer and isPedInVehicle (localPlayer)) then local veh = getPedOccupiedVehicle ( localPlayer ) if (getElementModel ( veh ) == 525) then triggerServerEvent ("finishMiniJobMec", localPlayer) playSound ("fail.mp3") destroyElement (vehicleToGive) destroyElement (vehicleToGiveBlip) createMiniJobEventMec () outputChatBox ("******************", 0, 255, 0) else outputChatBox ("*******************", 255, 0, 0) end end end Problem: when a player attach the vehicle to the Towtruck, it doesn't create any marker and blip to delivery this, i have tested with onClientTrailerAttach but it doesn't work anyway, i have tried all i know and i am very tired, it still doesn't create the marker and the blip, can anyone fix it or say why it doesn't work please I will not pass all to server side because i dont want the car creates up to one and it bug the server, im explain, when a player take the minijob the car spawn, when other player take job, other car spawn up the other car math randomed, and if the server have very mutch people, it will bug and lag with 300 cars created with this jobs for all people, and the clever people know how to abuse with this and break doors and catch its, please i need the vehicles will be created on client side and attached in client side, as i say onClientTrailerAttach doesn't work PD: Any debugscript errors found Link to comment
Den. Posted June 8, 2014 Share Posted June 8, 2014 Line 41 in the server-side script should be : triggerClientEvent (source, "mechanictriggernow1", source) Instead of triggerServerEvent. onClientTrailerAttach probably works, you were likely using it incorrectly. Link to comment
Max+ Posted June 8, 2014 Share Posted June 8, 2014 And, some functions are shared , no need for trigger like destoryElement Link to comment
Den. Posted June 8, 2014 Share Posted June 8, 2014 And, some functions are shared , no need for trigger like destoryElement According to the wiki, you can't destroy server-side elements with client-side destroyElement. Link to comment
Leonard.DC Posted June 9, 2014 Author Share Posted June 9, 2014 function createMiniJobEventMec () local loc = math.random(1,#vehicleslocations) vehicleToGive = createVehicle(vehid, vehicleslocations[loc ][1], vehicleslocations[loc ][2], vehicleslocations[loc ][3]) vehicleToGiveBlip = createBlipAttachedTo(vehicleToGive, 41, localPlayer) addEventHandler("onClientTrailerAttach", vehicleToGive, createMarkerFinalMiniJobMec) setVehicleDamageProof (vehicleToGive, true) setElementHealth (vehicleToGive, 450) setVehicleEngineState ( vehicleToGive, false ) setVehicleLocked ( vehicleToGive, true ) end addEventHandler ("onClientGUIClick", root, function () if (source == accept) then guiSetVisible (window, false) showCursor (false) triggerServerEvent ("createMiniJobMecVeh", localPlayer) outputChatBox ("**************", 255, 255, 0) createMiniJobEventMec () playSound ("fail.mp3") elseif (source == close) then guiSetVisible (window, false) showCursor (false) end end) function createMarkerFinalMiniJobMec () marker = createMarker (1669.40234375, -1065.4619140625, 22.8984375, "cylinder", 3, 255, 255, 0, 255, localPlayer) blip = createBlip (1669.40234375, -1065.4619140625, 22.8984375, 60, localPlayer) outputChatBox ("Delivery The Car", 255, 255, 0) addEventHandler("onClientTrailerDetach", vehicleToGive, destroyMarkerAndBlipMiniJob) addEventHandler ("onClientMarkerHit", marker, traervehiculoRecompensa) end function destroyMarkerAndBlipMiniJob () destroyElement (marker) destroyElement (blip) outputChatBox ("Ops Fail xD", 255, 0, 0) end function traervehiculoRecompensa (hitElement) if (hitElement == localPlayer and isPedInVehicle (localPlayer)) then local veh = getPedOccupiedVehicle ( localPlayer ) if (getElementModel ( veh ) == 525) then triggerServerEvent ("finishJob", localPlayer) playSound ("fail.mp3") destroyElement (vehicleToGive) destroyElement (vehicleToGiveBlip) createMiniJobEventMec () outputChatBox ("Nice Job!", 0, 255, 0) else outputChatBox ("Error", 255, 0, 0) end end end Doesn't work using this and onClientTrailerAttach/onClientTrailerDetach , WHY? No debugscript Errors Link to comment
Max+ Posted June 11, 2014 Share Posted June 11, 2014 Well First your code is speghti i tryed fixing what i can , and you fliped the triggerEvents , and it's not organized so the scripters can help you , Try Now , --ClientSide window = guiCreateWindow(434, 321, 420, 398, "Mech Minijob", false) guiWindowSetSizable(window , false) guiSetVisible( window , false ) acceptm = guiCreateButton(10, 292, 180, 96, "Acept", false, window ) guiSetFont(acceptm , "default-bold-small") close = guiCreateButton(230, 292, 180, 96, "NO", false, window ) guiSetFont(cerrarm, "default-bold-small") memom = guiCreateMemo(10, 26, 400, 249, "*******************", false, window ) guiMemoSetReadOnly(memom, true) addEvent('openTheGUIMiniMec', true) addEventHandler('openTheGUIMiniMec', root, function () guiSetVisible (window, true) showCursor(true) end ) vehicleslocations = { {2052.7880859375, -1905.509765625, 13.546875}, {2191.0205078125, -2251.978515625, 13.509453773499}, {2370.25, -1938.7373046875, 13.546875}, {835.4384765625, -2051.4296875, 12.8671875}, {384.708984375, -2079.1875, 7.8300905227661}, {405.171875, -1153.5087890625, 77.260643005371}, {2300.0322265625, -1439.8896484375, 24}, {1904.9677734375, -1782.392578125, 13.546875}, {2409.6337890625, -1138.8134765625, 30.617359161377}, {2679.671875, -2531.0771484375, 13.306663513184}, {1560.0185546875, -2313.302734375, 13.544898033142} } idlist = { 602, 410, 545, 436, 551 } vehid = idlist[math.random(#idlist)] function createMiniJobEventMec () local loc = math.random(1,#vehicleslocations) vehicleToGive = createVehicle(vehid, vehicleslocations[loc][1], vehicleslocations[loc][2], vehicleslocations[loc][3]) vehicleToGiveBlip = createBlipAttachedTo(vehicleToGive, 41, localPlayer) triggerServerEvent ("AttachTheTrailer123", localPlayer) setVehicleDamageProof (vehicleToGive, true) setElementHealth (vehicleToGive, 450) setVehicleEngineState ( vehicleToGive, false ) setVehicleLocked ( vehicleToGive, true ) end addEventHandler ("onClientGUIClick", root, function () if (source == acceptm) then guiSetVisible (window, false) showCursor (false) triggerServerEvent ("createMiniJobMecVeh", localPlayer) outputChatBox ("Go to the icon", 255, 255, 0) createMiniJobEventMec () playSound ("fail.mp3") elseif (source == close) then guiSetVisible (window, false) showCursor (false) end end ) addEvent ("mechanictriggernow1", true) addEventHandler("mechanictriggernow1", root, function() marker = createMarker (1669.40234375, -1065.4619140625, 22.8984375, "cylinder", 3, 255, 255, 0, 255, localPlayer) blip = createBlip (1669.40234375, -1065.4619140625, 22.8984375, 60, localPlayer) outputChatBox ("Go and leave the car", 255, 255, 0) addEventHandler ("onClientMarkerHit", marker, rewardMecJob) triggerServerEvent ("AttachTheTrailer12345", localPlayer) end ) addEvent ("mechanictriggernow2", true) addEventHandler("mechanictriggernow2", root, function () destroyElement (marker ) destroyElement (blip ) outputChatBox ("Ops, Fail xD", 255, 0, 0) end ) function rewardMecJob(hitElement) if (hitElement == localPlayer and isPedInVehicle (localPlayer)) then local veh = getPedOccupiedVehicle ( localPlayer ) if (getElementModel ( veh ) == 525) then triggerServerEvent ("finishMiniJobMec", localPlayer) playSound ("fail.mp3") destroyElement (vehicleToGive) destroyElement (vehicleToGiveBlip) createMiniJobEventMec () outputChatBox ("******************", 0, 255, 0) else outputChatBox ("*******************", 255, 0, 0) end end end ---ServerSide , pickupM1 = createPickup (1058.2626953125, -1032.2587890625, 32.042984008789, 3, 1239, 1) pickupM2 = createPickup (2127.4814453125, -1147.63671875, 24.440776824951, 3, 1239, 1) addEventHandler ("onPickupHit", pickupM1, function (hitElement) if (hitElement and getElementType(hitElement) == "player" and not isPedInVehicle (hitElement)) then if getPlayerTeam ( hitElement ) == getTeamFromName ( "Mechanic" ) then triggerClientEvent (hitElement, "openTheGUIMiniMec", hitElement) else outputChatBox ("You are not Mechanic to do this", hitElement, 255, 0, 0) end end end ) addEventHandler ("onPickupHit", pickupM2, function (hitElement) if (hitElement and getElementType(hitElement) == "player" and not isPedInVehicle (hitElement)) then if getPlayerTeam ( hitElement ) == getTeamFromName ( "Mechanic" ) then triggerClientEvent (hitElement, "openTheGUIMiniMec", hitElement) else outputChatBox ("You are not Mechanic to do this", hitElement, 255, 0, 0) end end end ) addEvent('finishMiniJobMec', true) addEventHandler('finishMiniJobMec', root, function () givePlayerMoney(source, 3000) end ) addEvent('createMiniJobMecVeh', true) addEvent('createMiniJobMecVeh', root, function () local x,y,z = getElementPosition (source) local theveh = createVehicle ( 525, x, y, z ) warpPedIntoVehicle (source, theveh, 0 ) end ) addEvent ("AttachTheTrailer123", true) addEventHandler("AttachTheTrailer123", root, function () addEventHandler("onTrailerAttach", resourceRoot) triggerClientEvent (source, "mechanictriggernow1", source) end ) addEvent ("AttachTheTrailer12345", true) addEventHandler("AttachTheTrailer12345", root, function() triggerClientEvent (source, "mechanictriggernow2", source) end ) Link to comment
Leonard.DC Posted June 11, 2014 Author Share Posted June 11, 2014 It still doesn't mark the blip and the marker to delivery the car, and no debugscript errors when attach the car Link to comment
Max+ Posted June 11, 2014 Share Posted June 11, 2014 Try This , window = guiCreateWindow(434, 321, 420, 398, "Mech Minijob", false) guiWindowSetSizable(window , false) guiSetVisible( window , false ) acceptm = guiCreateButton(10, 292, 180, 96, "Acept", false, window ) guiSetFont(acceptm , "default-bold-small") close = guiCreateButton(230, 292, 180, 96, "NO", false, window ) guiSetFont(cerrarm, "default-bold-small") memom = guiCreateMemo(10, 26, 400, 249, "*******************", false, window ) guiMemoSetReadOnly(memom, true) addEvent('openTheGUIMiniMec', true) addEventHandler('openTheGUIMiniMec', root, function () guiSetVisible (window, true) showCursor(true) end ) vehicleslocations = { {2052.7880859375, -1905.509765625, 13.546875}, {2191.0205078125, -2251.978515625, 13.509453773499}, {2370.25, -1938.7373046875, 13.546875}, {835.4384765625, -2051.4296875, 12.8671875}, {384.708984375, -2079.1875, 7.8300905227661}, {405.171875, -1153.5087890625, 77.260643005371}, {2300.0322265625, -1439.8896484375, 24}, {1904.9677734375, -1782.392578125, 13.546875}, {2409.6337890625, -1138.8134765625, 30.617359161377}, {2679.671875, -2531.0771484375, 13.306663513184}, {1560.0185546875, -2313.302734375, 13.544898033142} } idlist = { 602, 410, 545, 436, 551 } vehid = idlist[math.random(#idlist)] function createMiniJobEventMec () local loc = math.random(1,#vehicleslocations) vehicleToGive = createVehicle(vehid, vehicleslocations[loc][1], vehicleslocations[loc][2], vehicleslocations[loc][3]) vehicleToGiveBlip = createBlipAttachedTo(vehicleToGive, 41) triggerServerEvent ("AttachTheTrailer123", localPlayer) setVehicleDamageProof (vehicleToGive, true) setElementHealth (vehicleToGive, 450) setVehicleEngineState ( vehicleToGive, false ) setVehicleLocked ( vehicleToGive, true ) end addEventHandler ("onClientGUIClick", root, function () if (source == acceptm) then guiSetVisible (window, false) showCursor (false) triggerServerEvent ("createMiniJobMecVeh", localPlayer) outputChatBox ("Go to the icon", 255, 255, 0) createMiniJobEventMec () playSound ("fail.mp3") elseif (source == close) then guiSetVisible (window, false) showCursor (false) end end ) addEvent ("mechanictriggernow1", true) addEventHandler("mechanictriggernow1", root, function() marker = createMarker (1669.40234375, -1065.4619140625, 22.8984375, "cylinder", 3, 255, 255, 0, 255, localPlayer) local blip = createBlipAttachedTo(marker, 41) outputChatBox ("Go and leave the car", 255, 255, 0) addEventHandler ("onClientMarkerHit", marker, rewardMecJob) triggerServerEvent ("AttachTheTrailer12345", localPlayer) end ) addEvent ("mechanictriggernow2", true) addEventHandler("mechanictriggernow2", root, function () destroyElement (marker ) destroyElement (blip ) outputChatBox ("Ops, Fail xD", 255, 0, 0) end ) function rewardMecJob(hitElement) if (hitElement == localPlayer and isPedInVehicle (localPlayer)) then local veh = getPedOccupiedVehicle ( localPlayer ) if (getElementModel ( veh ) == 525) then triggerServerEvent ("finishMiniJobMec", localPlayer) playSound ("fail.mp3") destroyElement (vehicleToGive) destroyElement (vehicleToGiveBlip) createMiniJobEventMec () outputChatBox ("******************", 0, 255, 0) else outputChatBox ("*******************", 255, 0, 0) end end end Link to comment
Leonard.DC Posted June 11, 2014 Author Share Posted June 11, 2014 I dont see any new changes in your script Link to comment
Leonard.DC Posted June 13, 2014 Author Share Posted June 13, 2014 Anyone can fix this please!? 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