Jump to content

I cant enter vehicle :/


Genius

Recommended Posts

Posted

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 ) 

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted

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.

Posted

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 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted
try stopping the resource and see if you could enter the vehicle

I can enter the vehicle.

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted
Did you restart the resource with the current script I gave you?

Yes

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted (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 by Guest

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted
I've edited it again, try it

Again dont work :(

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted
you sure theres not any other scripts that have anything canceling the onClientVehicleEnter event?

Yes

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted

now in /debugscript said me addEventHandler "onClientVehicleDamage" with this function already handled :/

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted

You can't enter any vehicle that created from client side, you have to create it server side.

CiTLh.png
Posted

Jaysd, what TAPL said is correct, if you try to, you'll notice that you cannot enter on them.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 ) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...