Jump to content

When player leave server vehicle problem


Recommended Posts

Hi :)

I have a new problem :? nothing new for me lol

When a player leave the server and he is a vehicle the vehicle dont respawn back on the .map place.

Here are my idle script:

function idleRespawn () 
        for i,vehicle in ipairs(getElementsByType("vehicle")) do 
            toggleVehicleRespawn(vehicle, true) 
            setVehicleIdleRespawnDelay(vehicle, 20000) 
        end 
    end 
  
  
addEventHandler("onResourceStart", getRootElement(), idleRespawn ) 

i have a vehicle explode script too

addEventHandler( "onVehicleExplode", getRootElement( ), 
    function( ) 
        local parent = getElementParent( source ) 
        if getElementType( parent ) == "map" and getElementID( parent ) ~= "dynamic" then 
            setTimer( respawnVehicle, 80000, 1, source ) 
        else 
            setTimer( destroyElement, 5000, 1, source ) 
        end 
    end 
) 

All scripts work very good only when a player is in a vehicle and leave the sever the vehicle dont respawn on the old .map place.

Can someone help me plz :roll:

THX :D

Link to comment

I have test this:

function leaveplayer () 
for i,vehicle in ipairs(getElementsByType("vehicle")) do 
toggleVehicleRespawn(vehicle, true) 
setVehicleIdleRespawnDelay(vehicle, 10000) 
end 
end 
  
  
addEventHandler("onPlayerQuit", getRootElement(), leaveplayer ) 

onPlayerQuit when the player leave the server but nothing :(

When the player is in a vehicle and leave then the server the vehicle didn't respawn on the old .map place.

Can someone help me with that problem PLZ!

Link to comment

It seems like MTA bug. Maybe it's caused by synching vehicles when player leaves to let the vehicle be in the same place when player leaves the server so that other players can see it there, but IMO it should respawn the vehicle even when player was in it before he/she left.

Link to comment

You need to make another resource which will restart this vehicles resource.

Just put this inside the new resource which will restart the vehicles resource:

addEventHandler( "onResourceStart", getRootElement(), 
    function( resourceStarted ) 
        if( getResourceName( resourceStarted ) == "vehicles" ) then 
            setTimer( restartResource, 1800000, 1, resourceStarted ); 
        end 
    end 
) 

Remember to give this resource access to restartResource function.

Open acl.xml and find Admin group, add a node inside of that group:

...    name="Admin">        ....         name="resource.THIS_NEW_RESOUCE_NAME" />    >...

Link to comment

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...