Jump to content

Odd spawnbug.


laurens

Recommended Posts

Hello. I'm here for your help; I'm experiencing this incredibly odd spawnbug in my gamemode.

Whenever you die, and respawn, the chances are big you will get stuck.

This is the stripped-down version of the gamemode, where the bug still occurs.

Server.lua

local resourceRoot = getResourceRootElement(getThisResource()) 
local startX 
local startY 
  
function spawn ( player ) 
    local x = randInt ( startX - 15, startX + 15 ) 
    local y = randInt ( startY - 15, startY - 5 ) 
    fadeCamera ( player, true )  
    spawnPlayer ( player, x, y, 10.82 ) 
end 
  
function spawnAll ()  
    local players = getElementsByType ( "player" ) 
    for Key, player in ipairs( players ) do 
        spawn ( player ) 
    end 
end 
  
function placeObjects() 
    createObject ( 3374, 1354, 1270, 11) 
    createObject ( 3374, 1358, 1270, 11) 
    createObject ( 3374, 1362, 1270, 11) 
    createObject ( 3374, 1354, 1274, 11) 
    createMarker (       1358, 1274, 10, "cylinder", 3, 255, 0, 0, 170) 
    createObject ( 3374, 1362, 1274, 11) 
    createObject ( 3374, 1354, 1278, 11) 
    createObject ( 3374, 1358, 1278, 11) 
    createObject ( 3374, 1362, 1278, 11) 
    startX = 1358 
    startY = 1270 
    setTimer ( spawnAll, 500, 1 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, placeObjects ) 
  
function player_Wasted () 
    local x = randInt ( startX - 15, startX + 15 ) 
    local y = randInt ( startY - 15, startY - 5 ) 
    setTimer( spawnPlayer, 500, 1, source, 1485.5, 1168.5, 17 ) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) 
  
addCommandHandler ( "kill",  
function ( source )  
    killPlayer ( source ) 
end 
) 

Client.lua

local invloedveld = 20 
local allObjects = {} 
local bufferTimer 
  
function objectBuffer() 
    allObjects = getElementsByType ( "object" ) 
    local px, py, pz = getElementPosition ( getLocalPlayer() )   
    for Key,Object in ipairs(allObjects) do 
        local ox, oy, oz = getElementPosition ( Object )     
        local relativeX = px - ox 
        local relativeY = py - oy 
        if (relativeX < invloedveld) and (relativeX > -invloedveld) and (relativeY < invloedveld) and (relativeY > -invloedveld) then 
            if ( getElementDimension ( Object ) == 1 ) then 
                setElementDimension ( Object, 0 )    
            end 
        else 
            if ( getElementDimension ( Object ) == 0 ) then 
                setElementDimension ( Object, 1 )    
            end 
        end 
    end 
end 
  
function startBuffer ( ) 
    objectBuffer() 
    setTimer ( objectBuffer, 3000, 0 ) 
end 
  
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), startBuffer ) 

I think I can call this a MTA bug, because I did not code it to get stuck like that.

Does anyone know a work-around to not let this happen, but still keep the functionality of the script?

Or best of all, can the MTA team take a look at this and tell me the technical details of what happens?

Thanks in advance.

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