Jump to content

Help with gamemode


Kenix

Recommended Posts

I make a new gamemode but the spawn is not working please help

  
function startMap( startedMap ) 
mapRoot = source 
    local mapRoot = getResourceRootElement( startedMap )  
        local xi, yi, zi = 0, 0, 0 
        local spawns = table.merge(getElementsByType("spawnpoint",mapRoot),getElementsByType("spawnpoint2",mapRoot),getElementsByType("spawnpoint1",mapRoot)) 
            for i,spawnpoint in ipairs(spawns) do 
                xi = xi + getElementData( spawnpoint, "posX" ) 
                yi = yi + getElementData( spawnpoint, "posY" ) 
                zi = zi + getElementData( spawnpoint, "posZ" ) 
             
end 
xi = xi/spawns 
            yi = yi/spawns 
            zi = zi/spawns 
 end 
addEventHandler("onGamemodeMapStart", getRootElement(), startMap) 
  

Link to comment

I have corrected a script of errors wasn't present but all the same not spawn.

  
  
local fa_root = getRootElement() 
teamSurvivor = createTeam ( "Survivors", 0, 255, 0 ) 
teamzombie = createTeam ( "Zombies", 255, 0, 0 ) 
        setTeamFriendlyFire( teamSurvivor, false ) 
        setTeamFriendlyFire( teamzombie, false ) 
  
function startzmMap( startedMap ) -- startedMap e la mappa appena avviata 
mapRoot = source 
    local mapRoot = getResourceRootElement( startedMap )  
        local xi, yi, zi = 0, 0, 0 
        local spawns = table.merge(getElementsByType("spawnpoint",mapRoot),getElementsByType("spawnpoint2",mapRoot),getElementsByType("spawnpoint1",mapRoot)) 
            for i,spawnpoint in ipairs(spawns) do 
             getElementData( spawnpoint, "posX" ) 
             getElementData( spawnpoint, "posY" ) 
             getElementData( spawnpoint, "posZ" ) 
             
end 
end 
addEventHandler("onGamemodeMapStart", getRootElement(), startzmMap) 
  
function zm_onResourceStart( resourcename, res ) 
    setTeamFriendlyFire(Survivors , false ) 
    setTeamFriendlyFire(Zombies , false ) 
    if ( resourcename == getThisResource () ) then 
        local plrs = getElementsByType( "player" ); 
        for i, plr in pairs( plrs ) do 
            setElementData( plr, "Deaths", 0 ) 
        end 
        setTimer( call, 1000, 1, getResourceFromName("dxscoreboard"), "addScoreboardColumn", "Deaths" ) 
        end 
        if resourceName == 'mapmanager' then 
            mapmanager = createResourceCallInterface('mapmanager') 
    end 
end 
addEventHandler( "onResourceStart", fa_root, zm_onResourceStart ) 
  
function joinPlayer ( ) 
        setPlayerTeam ( source, Survivors ) 
        giveWeapon ( source, 14, 100 ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), joinPlayer ) 
  
function aa_playerWasted( totalAmmo, killer ) 
    setPlayerTeam ( source, Zombies ) 
        giveWeapon ( source, 4, 1 ) 
end 
addEventHandler ( "onPlayerWasted", aa_root, aa_playerWasted ) 
  
function table.merge(appendTo, ...) 
    -- table.merge(targetTable, table1, table2, ...) 
    -- Append the values of one or more tables to a target table. 
    -- 
    -- In the arguments list, a table pointer can be followed by a 
    -- numeric or textual key. In that case the values in the table 
    -- will be assumed to be tables, and of each of these the value 
    -- corresponding to the given key will be appended instead of the 
    -- subtable itself. 
    local appendval 
    for i=1,arg.n do 
        if type(arg[i]) == 'table' then 
            for k,v in pairs(arg[i]) do 
                if arg[i+1] and type(arg[i+1]) ~= 'table' then 
                    appendval = v[arg[i+1]] 
                else 
                    appendval = v 
                end 
                if appendval then 
                    if type(k) == 'number' then 
                        table.insert(appendTo, appendval) 
                    else 
                        appendTo[k] = appendval 
                    end 
                end 
            end 
        end 
    end 
    return appendTo 
end 
  

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