Genius Posted May 26, 2012 Share Posted May 26, 2012 When i take job then car is spawned but i cant get in the vehicle /debugscript 3 nothing Can someone fix it pls! carjacker = createMarker( 2055.6, -1769.3, 13.5,"cylinder",1.5,0,0,0,0 ) local carjackerTable = { {826,858.9,12}; {579.9,1220.2,11.7}; {65,-275,1.5}; {1673.6, -37.6,3.5}; {-540.6,-497.7,25.5}; {2783.8,-2418.2,13.6}; } function unpackCarjacker () return unpack ( carjackerTable [ math.random ( #carjackerTable ) ] ) end function createCarrou (hitPlayer) if hitPlayer and hitPlayer == localPlayer then x, y, z = unpackCarjacker() carBlip = createBlipAttachedTo ( vehicle, 32 ) vehicle = createVehicle ( 541,x, y, z ) addEventHandler ( "onClientVehicleEnter", vehicle, carHit ) end end addEventHandler ( "onClientMarkerHit", carjacker, createCarrou ) function carHit ( hitPlayer ) carmarker = createMarker( 0,0,0, "cylinder", 3, 250, 250, 90 ) addEventHandler ("onClientMarkerHit", carmarker, functio ) end function functio ( hitElement ) if ( not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then triggerServerEvent ( "carmoney", localPlayer ) destroyElement ( vehicle ) destroyElement ( carBlip ) destroyElement ( marker ) createRoute() end end function functi () cancelEvent () end addEventHandler ( "onClientPedDamage", resourceRoot, functi ) Link to comment
kaos057 Posted May 26, 2012 Share Posted May 26, 2012 put line 22 before line 21. if that doesnt work comment out line 23 and see if that allows you to enter. I think switching the lines should work though because you are trying to use the variable "vehicle" before it is assigned. Link to comment
Genius Posted May 26, 2012 Author Share Posted May 26, 2012 I made that but dont work Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 try this: carjacker = createMarker( 2055.6, -1769.3, 13.5,"cylinder",1.5,0,0,0,0 ) local carjackerTable = { {826,858.9,12}; {579.9,1220.2,11.7}; {65,-275,1.5}; {1673.6, -37.6,3.5}; {-540.6,-497.7,25.5}; {2783.8,-2418.2,13.6}; } function createCarrou (hitPlayer) if getElementType(hitPlayer)=="player" and hitPlayer == localPlayer then x, y, z = unpack ( carjackerTable [ math.random ( #carjackerTable ) ] ) vehicle = createVehicle ( 541,x, y, z ) carBlip = createBlipAttachedTo ( vehicle, 32 ) --create a blip after the car is created addEventHandler ( "onClientVehicleEnter", vehicle, carHit ) end end addEventHandler ( "onClientMarkerHit", carjacker, createCarrou ) function carHit ( hitPlayer ) carmarker = createMarker( 0,0,0, "cylinder", 3, 250, 250, 90 ) addEventHandler ("onClientMarkerHit", carmarker, functio ) end function functio ( hitElement ) if ( hitElement == localPlayer ) then if(not isPedInVehicle ( localPlayer ))then triggerServerEvent ( "carmoney", localPlayer ) destroyElement ( vehicle ) destroyElement ( carBlip ) destroyElement ( marker ) createRoute() end end end function functi () cancelEvent () end addEventHandler ( "onClientPedDamage",root, functi ) --it's root not resource root Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 try stopping the resource and see if you could enter the vehicle Link to comment
Genius Posted May 26, 2012 Author Share Posted May 26, 2012 try stopping the resource and see if you could enter the vehicle I can enter the vehicle. Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 Did you restart the resource with the current script I gave you? Link to comment
Genius Posted May 26, 2012 Author Share Posted May 26, 2012 Did you restart the resource with the current script I gave you? Yes Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 (edited) ok, try this: carjacker = createMarker( 2055.6, -1769.3, 13.5,"cylinder",1.5,0,0,0,0 ) local carjackerTable = { {826,858.9,12}, --if your making another line of table, use a comma , if your ending the table, then use that semicolon {579.9,1220.2,11.7}, {65,-275,1.5}, {1673.6, -37.6,3.5}, {-540.6,-497.7,25.5}, {2783.8,-2418.2,13.6}; } function createCarrou (hitPlayer) if(getElementType(hitPlayer)=="player")and(hitPlayer==localPlayer)then local x, y, z = unpack ( carjackerTable [ math.random ( #carjackerTable ) ] ) vehicle = createVehicle ( 541,x, y, z ) carBlip = createBlipAttachedTo ( vehicle, 32 ) --create a blip after the car is created setElementData(hitPlayer,"Car",vehicle) end end addEventHandler ( "onClientMarkerHit", carjacker, createCarrou ) function carHit (player) if(getElementData(player,"Car")==source)then carmarker = createMarker( 0,0,0, "cylinder", 3, 250, 250, 90 ) addEventHandler ("onClientMarkerHit", carmarker, functio ) end end addEventHandler ( "onClientVehicleEnter",root, carHit ) function functio ( hitElement ) if ( hitElement == localPlayer ) then triggerServerEvent ( "carmoney", localPlayer ) destroyElement ( vehicle ) destroyElement ( carBlip ) destroyElement ( marker ) createRoute() end end addEventHandler ( "onClientPedDamage",root, cancelEvent) --it's root not resource root Edited May 26, 2012 by Guest Link to comment
Genius Posted May 26, 2012 Author Share Posted May 26, 2012 I've edited it again, try it Again dont work Link to comment
kaos057 Posted May 26, 2012 Share Posted May 26, 2012 you sure theres not any other scripts that have anything canceling the onClientVehicleEnter event? Link to comment
Genius Posted May 26, 2012 Author Share Posted May 26, 2012 you sure theres not any other scripts that have anything canceling the onClientVehicleEnter event? Yes Link to comment
Genius Posted May 26, 2012 Author Share Posted May 26, 2012 now in /debugscript said me addEventHandler "onClientVehicleDamage" with this function already handled Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 Post your Meta.xml and if you have any other scripts with this resource, I suggest posting it now, and for sure I know this isn't the full script Link to comment
TAPL Posted May 26, 2012 Share Posted May 26, 2012 You can't enter any vehicle that created from client side, you have to create it server side. Link to comment
Castillo Posted May 26, 2012 Share Posted May 26, 2012 Jaysd, what TAPL said is correct, if you try to, you'll notice that you cannot enter on them. Link to comment
TAPL Posted May 26, 2012 Share Posted May 26, 2012 Where did this info came from? from wiki https://wiki.multitheftauto.com/wiki/CreateVehicle Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only. Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 oh, ok EDIT: Genuis, put this Server Sided: carjacker = createMarker( 2055.6, -1769.3, 13.5,"cylinder",1.5,0,0,0,0 ) local carjackerTable = { {826,858.9,12}, {579.9,1220.2,11.7}, {65,-275,1.5}, {1673.6, -37.6,3.5}, {-540.6,-497.7,25.5}, {2783.8,-2418.2,13.6}; } function createCarrou (hitPlayer) if (getElementType(hitPlayer)=="player") then local x, y, z = unpack ( carjackerTable [ math.random ( #carjackerTable ) ] ) vehicle = createVehicle ( 541,x, y, z ) carBlip = createBlipAttachedTo ( vehicle, 32 ) --create blip after the vehicle is created addEventHandler ( "onVehicleEnter", vehicle, carHit ) end end addEventHandler ( "onMarkerHit", carjacker, createCarrou ) function carHit(enterer) carmarker = createMarker( 0,0,0, "cylinder", 3, 250, 250, 90 ) addEventHandler ("onMarkerHit", carmarker, functio ) end function functio ( hitElement ) if ( getElementType(hitElement) == "player" ) then triggerEvent ( "carmoney", source ) destroyElement ( vehicle ) destroyElement ( carBlip ) destroyElement ( marker ) createRoute() --not sure what your going to do with this end end addEventHandler ( "onPedDamage", root, cancelEvent ) Link to comment
Genius Posted May 26, 2012 Author Share Posted May 26, 2012 Solidsnake14 helped me by PM Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 ok, if you need any help with this script, remember to post it here instead of making another topic 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