damien111 Posted August 19, 2012 Share Posted August 19, 2012 I need help with this car jacker script. i have everything done but this code. I need help with how to tell if a player is in a car when they go into the marker, and also. at the moment when a player walks into the marker , its suppose to delete the car and give them 10000$. it is not even doing that im very lost and any advise and wiki links will be greatly appreciated There are no debugscript 3 errors heres the code: SERVER theMarker = createMarker ( 2281.0270996094, 2451.3420410156, 10, "cylinder", 1.5, 255, 255, 0, 170 ) theVehicle = createVehicle ( 432, 2268.3127441406, 2451.1025390625, 10 ) function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then destroyElement ( theVehicle ) triggerClientEvent ( "sellcar", localPlayer) end end addEventHandler ( "onMarkerHit", theMarker, spawnveh ) CLIENT function sellCar ( ) givePlayerMoney ( 10000 ) outputChatBox ( "You have sold your stolen car" ) end addEvent("sellcar", true) addEventHandler("sellcar",root,sellCar) That Code Is Just For When They Drive Into The Marker, i just need help making it give the money, which wont work for some reason, and restricting it so only people in cars can enter. So again, this is just a piece of the code the part i need help with Also! How can i lock cars to user's/players Link to comment
manve1 Posted August 19, 2012 Share Posted August 19, 2012 use: createMarker onMarkerHit onMarkerLeave that will fix it Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 I am positive that is what i did O_O Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Also here is a update on my code CLIENT function sellCar ( ) givePlayerMoney ( 10000 ) outputChatBox ( "You have sold your stolen car" ) end addEvent("sellcar", true) addEventHandler("sellcar",root,sellCar) --JOB local marker = createMarker( 1734.7218017578, 1993.3072509766, 11, "Cylinder", 2, 6, 183, 248, 153) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(1031,232,301,397,"Car Jacker job",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take Car Jacker team job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) function Medicjob(hitElement) if getElementType(hitElement) == "player" then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, Medicjob) function Medicjobleave(leaveElement) if getElementType(leaveElement) == "player" then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, Medicjobleave) function joinTeam() triggerServerEvent("setMedic",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeMedicWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeMedicWindow, false) SERVER theMarker = createMarker ( 1728.0740966797, 2010.6652832031, 10.5, "cylinder", 2, 255, 255, 0, 170 ) function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then destroyElement ( theCar ) triggerClientEvent ( "sellcar", localPlayer) end end addEventHandler ( "onMarkerHit", theMarker, spawnveh ) --job function createMedicTeam () MedicTeam = createTeam ("Car Jackers", 255, 0, 0) end local coordinates = { { 1725.9757080078, 1946.7092285156, 10, 0, 0, 0 }, { 1747.3811035156, 1980.2396240234, 10, 0, 0, 0 } } function getRandomCoordinates ( ) return unpack ( coordinates [ math.random ( #coordinates ) ] ) end local IDS = { { 402 }, { 542 }, { 603 }, { 475 }, { 576 }, { 575 }, { 567 } } function getRandomCoordinates1 ( ) return unpack ( IDS [ math.random ( #IDS ) ] ) end function deleteCar ( ) if ( isVehicleBlown ( theCar ) ) then destroyElement ( theCar ) end end function joinMedic() setPlayerTeam(source,MedicTeam) setElementModel(source,293) setElementData( source, "Occupation", "Car Jacker", true ) outputChatBox("You are now Car Jacker.",source,0,255,0) x, y, z, rx, ry, rz = getRandomCoordinates ( ) ID = getRandomCoordinates1 ( ) theCar = createVehicle ( ID, x, y, z, rx, ry, rz ) end addEvent("setMedic", true) addEventHandler("setMedic",root,joinMedic) it wont do the Client sellcar Function, i did trigger event and everything, also. the line of code: function deleteCar ( ) if ( isVehicleBlown ( theCar ) ) then destroyElement ( theCar ) end end wont work, it is suppose to destroy the spawned car if it blows ps - also can you gimme some functions and things for locking cars to players. pss - how to restrict how many times you can spawn something ill keep looking though. but still, it would be great if i could have some wiki links or something, cause i dont even know what to search on the wiki S: Link to comment
Castillo Posted August 19, 2012 Share Posted August 19, 2012 If you give/take/set money client side, it won't really do it, you must do it server side. Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Ah..... Thats good to know. Can you answer any of the other questions? Like the one bout locking cars, or restricting it so each player can only spawn 1, or the one about the code that wasnt working, the one that deleted the car if blown? I hope im not spamming the forums btw. im just trying to get help Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Ah, okay Also, im having a new problem. It wont give the money still, and. it wont set the team. and i cant get the function deleteCar ( ) if ( isVehicleBlown ( theCar ) ) then destroyElement ( theCar ) end end to work. im having so many problems. i also still need to restrict the spawn, can you give me the functions like the one u just gave me for that? Thanks either way Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 (edited) This won't work in this way function deleteCar ( ) if ( isVehicleBlown ( theCar ) ) then destroyElement ( theCar ) end end You should use event onVehicleExplode and This triggerClientEvent ( "sellcar", localPlayer) should be: triggerClientEvent(hitElement, "sellcar", hitElement) and still i don't understand why you give the money client side? and i don't see where function createMedicTeam begin called. Edited August 19, 2012 by Guest Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 I didnt know what it would do and it doesnt give the money still so ( And yes i change it to server side ) Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Thanks! Theres 1 more thing! when i said i wanted to lock the car. i wanted to lock it to the player who spawned it and i need help restricting the spawn so it spawns only 1 per player and knows who spawned it so they can take it to the marker for the money , also here is my code so far, i cant get it to detect the car as theCar function sellCar ( ) givePlayerMoney ( 10000 ) outputChatBox ( "You have sold your stolen car" ) end addEvent("sellcar", true) addEventHandler("sellcar",root,sellCar) function dontHave ( ) outputChatBox ( "You do not have the Vehicle!", thePlayer, 255, 0, 0, true ) end addEvent("donthave", true) addEventHandler("donthave",root,dontHave) --JOB local marker = createMarker( 1734.7218017578, 1993.3072509766, 9, "Cylinder", 2, 6, 183, 248, 153) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(1031,232,301,397,"Car Jacker job",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take Car Jacker team job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) function Medicjob(hitElement) if getElementType(hitElement) == "player" then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, Medicjob) function Medicjobleave(leaveElement) if getElementType(leaveElement) == "player" then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, Medicjobleave) function joinTeam() triggerServerEvent("setMedic",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeMedicWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeMedicWindow, false) theMarker = createMarker ( 1728.0740966797, 2010.6652832031, 9, "cylinder", 2, 255, 255, 0, 170 ) function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then theVehicle = getPedOccupiedVehicle ( thePlayer ) if ( theVehicle == theCar ) then destroyElement ( theCar ) triggerClientEvent(hitElement, "sellcar", hitElement) givePlayerMoney ( source, 10000 ) else triggerClientEvent (hitElement, "donthave", hitElement ) end end end addEventHandler ( "onMarkerHit", theMarker, spawnveh ) --job local coordinates = { { 1725.9757080078, 1946.7092285156, 10, 0, 0, 0 }, { 1747.3811035156, 1980.2396240234, 10, 0, 0, 0 } } function getRandomCoordinates ( ) return unpack ( coordinates [ math.random ( #coordinates ) ] ) end local IDS = { { 402 }, { 542 }, { 603 }, { 475 }, { 576 }, { 575 }, { 567 } } function getRandomCoordinates1 ( ) return unpack ( IDS [ math.random ( #IDS ) ] ) end function destroyCar ( ) destroyElement( theCar ) end addEventHandler ( "onVehicleExplode", vagosVehicle, destroyCar ) function createMedicTeam () theTeam = createTeam ( "Car Jackers" ) end function joinMedic() setPlayerTeam ( source, theTeam ) setElementModel(source,293) setElementData( source, "Occupation", "Car Jacker", true ) outputChatBox("You are now Car Jacker.",source,0,255,0) x, y, z, rx, ry, rz = getRandomCoordinates ( ) ID = getRandomCoordinates1 ( ) theCar = createVehicle ( ID, x, y, z, rx, ry, rz ) end addEventHandler ( "onVehicleExplode", theCar, destroyCar ) addEvent("setMedic", true) addEventHandler("setMedic",root,joinMedic) Link to comment
TAPL Posted August 20, 2012 Share Posted August 20, 2012 -- Client Side -- local marker = createMarker(1734.7218017578, 1993.3072509766, 10, "Cylinder",2,6,183,248,153) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} local x,y = guiGetScreenSize() windowjob = guiCreateWindow(x/2-150,y/2-199,301,397,"Car Jacker job",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take Car Jacker team job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) function Medicjob(hitElement) if getElementType(hitElement) == "player" then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, Medicjob) function Medicjobleave(leaveElement) if getElementType(leaveElement) == "player" then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, Medicjobleave) function joinTeam() triggerServerEvent("setMedic",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeMedicWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeMedicWindow, false) -- Server Side -- theMarker = createMarker(1728.0740966797, 2010.6652832031, 10, "cylinder", 2, 255, 255, 0, 170) theTeam = createTeam("Car Jackers") local coordinates = { {1725.9757080078, 1946.7092285156, 10, 0, 0, 0}, {1747.3811035156, 1980.2396240234, 10, 0, 0, 0} } local IDS = { { 402 }, { 542 }, { 603 }, { 475 }, { 576 }, { 575 }, { 567 } } function getRandomCoordinates() return unpack(coordinates[math.random(#coordinates)]) end function getRandomCoordinates1() return unpack(IDS[math.random(#IDS)]) end veh = {} function joinMedic() setPlayerTeam(source, theTeam) setElementModel(source,293) setElementData(source, "Occupation", "Car Jacker", true) outputChatBox("You are now Car Jacker.",source,0,255,0) x, y, z, rx, ry, rz = getRandomCoordinates() ID = getRandomCoordinates1() if isElement(veh[source]) then destroyElement(veh[source]) veh[source] = nil end veh[source] = createVehicle(ID, x, y, z, rx, ry, rz ) end addEvent("setMedic", true) addEventHandler("setMedic",root,joinMedic) function spawnveh(player) if (getElementType(player) == "player") then theVehicle = getPedOccupiedVehicle(player) if (theVehicle and theVehicle == veh[player]) then destroyElement (veh[player]) veh[player] = nil givePlayerMoney(player, 10000) outputChatBox("You have sold your stolen car",player,0,255,0) else outputChatBox("You do not have the Vehicle!", player,255,0,0,true) end end end addEventHandler("onMarkerHit", theMarker, spawnveh) function destroyCar() for i, player in ipairs (getElementsByType("player")) do if veh[player] == source then veh[player] = nil end end setTimer(destroyElement,3500,1,source) end addEventHandler("onVehicleExplode", root, destroyCar) addEventHandler("onPlayerQuit",root, function() if isElement(veh[source]) then destroyElement(veh[source]) veh[source] = nil end end) Link to comment
damien111 Posted August 20, 2012 Author Share Posted August 20, 2012 Okay, its not giving the money, taking the car, or setting the team. Also, it opens the panel for everyone on the server. can you help more? Link to comment
TAPL Posted August 20, 2012 Share Posted August 20, 2012 Okay, its not giving the money, taking the car, or setting the team. Also, it opens the panel for everyone on the server. can you help more? oops, forgot about the client the money and setting the team work 100% local marker = createMarker(1734.7218017578, 1993.3072509766, 10, "Cylinder",2,6,183,248,153) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} local x,y = guiGetScreenSize() windowjob = guiCreateWindow(x/2-150,y/2-199,301,397,"Car Jacker job",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take Car Jacker team job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) function Medicjob(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, Medicjob) function Medicjobleave(leaveElement) if getElementType(leaveElement) == "player" and leaveElement == localPlayer then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, Medicjobleave) function joinTeam() triggerServerEvent("setMedic",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeMedicWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeMedicWindow, false) Link to comment
damien111 Posted August 20, 2012 Author Share Posted August 20, 2012 how to set blip client side attached to something serverside? 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