Sign in to follow this  
☻ᶠᶸᶜᵏᵧₒᵤ☻

Timer a mappe di una gamemode

Recommended Posts

Salve a tutti

Volevo chiedervi come faccio a mettere il timer alle mappe di una gamemode, per esempio, c'è una gamemode che si chiama "aa" dove ci sono per esempio due mappe.

Ora come faccio che dopo 10 minuti si starta l'altra mappa??

Ora metto anche il Codice della gamemode cosi se mi fate un piacere mi mettete già all'interno il codice per il countdown ,Vi prego, mi serve...

Ecco la gamemode :

local aa_root = getRootElement()

teamSurvivor = createTeam ( "Humans", 0, 255, 0 )

teamZombies = createTeam ( "Zombies", 255, 0, 0 )

function loadmap(startmap, player)

mapRoot = getResourceRootElement(startmap)

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

setElementData( plr, "Deaths", 0 )

-- ////////////////// MISION \\\\\\\\\\\\\\\\\\

local total_markers = getElementChildrenCount( getElementByID( "markers" ) )

local num = math.random( 0, total_markers - 1 )

local marker_spawn = getElementChild ( getElementByID( "markers" ), num)

local mx = getElementData ( marker_spawn, "posX" )

local my = getElementData ( marker_spawn, "posY" )

local mz = getElementData ( marker_spawn, "posZ" )

setPlayerTeam ( plr, teamSurvivor )

objectiveMarker = createMarker(mx, my, mz)

-- ///////////////// SPAWN \\\\\\\\\\\\\\\\\\\\

local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local spawn_random = getElementChild ( getElementByID( "spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setTimer( setPedSkin , 500 , 1 , plr, math.random(9,288))

spawnPlayer( plr, x, y, z, rot);

setCameraTarget ( plr, plr );

fadeCamera( plr, true );

for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do

giveWeapon( plr, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) )

end

end

end

addEventHandler("onGamemodeMapStart", aa_root, loadmap)

function aa_onResourceStart( resourcename, res )

setTeamFriendlyFire(teamSurvivor , 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("scoreboard"), "addScoreboardColumn", "Deaths" )

end

if resourceName == 'mapmanager' then

mapmanager = createResourceCallInterface('mapmanager')

end

end

addEventHandler( "onResourceStart", aa_root, aa_onResourceStart )

function joinHandler()

local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local spawn_random = getElementChild ( getElementByID( "spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setElementData( source, "inmarker", false );

setPlayerTeam ( source, teamSurvivor )

spawnPlayer( source, x, y, z, rot )

setTimer( setPedSkin , 500 , 1 , source, math.random(9,288))

outputChatBox("< Welcome To Against All By CHAOS_IS_ME>", source, 255, 138, 0, true)

outputChatBox("< Current Version: #00FF00 1.0>", source, 255, 138, 0, true)

setCameraTarget ( source, source )

setElementData( source, "Deaths", 0 )

fadeCamera(source, true)

for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do

giveWeapon( source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) )

end

end

addEventHandler("onPlayerJoin", aa_root, joinHandler)

function aa_playerWasted( totalAmmo, killer )

local playerdeaths = getElementData ( source, "Deaths" )

setElementData ( source, "Deaths", playerdeaths+1 )

local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local skin = math.random(9,288)

local spawn_random = getElementChild ( getElementByID( "spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setPlayerTeam ( source, teamZombies )

setTimer( spawnPlayer , 5000 , 1 , source, x, y, z, rot)

setCameraTarget ( source, source )

fadeCamera(source, true)

--[[ idk what the :o is dat

for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do

setTimer( giveWeapon, 5000 , 1 , source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) )

end]]

end

addEventHandler ( "onPlayerWasted", aa_root, aa_playerWasted )

local localPlayerName = getPlayerName(aa_root)

-- misiones

function MarkerHit1 ( hitPlayer, matchingDimension )

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

WinDisplay = textCreateDisplay ()

setTimer( textDisplayAddText, 800, 1, WinDisplay, WinText )

-- textDisplayAddText ( WinDisplay, WinText )

WinText = textCreateTextItem ( getPlayerName(hitPlayer) .. " WIN! Next Map In 10 Seconds", 0.5, 0.5, "low", 255, 0, 0, 255, 2, "center" )

textDisplayAddObserver ( WinDisplay, plr)

setElementData( hitPlayer, "inmarker", true )

setTimer( textDestroyTextItem, 5000, 1, WinText )

setTimer(StartNextMap,10000,1)

setPedFrozen ( aa_root, true )

setTimer( setElementFrozen, 10000, 1, aa_root, false )

end

end

addEventHandler("onMarkerHit", aa_root, MarkerHit1)

function StartNextMap ()

exports.mapmanager:changeGamemode( getResourceFromName('aa') )

end

infection = createPickup (-1, 1, 3.11, 3, 1275, 15000 )

function infected ( thePlayer )

setPlayerTeam ( thePlayer, teamZombies )

setPedSkin ( thePlayer, 13 )

setPedHeadless ( thePlayer, true )

end

addEventHandler ( "onPickupUse", infection, infected )

addEventHandler("onPlayerSpawn", root,

function()

if(getPlayerTeam(source) == teamZombies) then

local weaponsToGive = {

{ id = 4, ammo = 30, setAsCurrent = true }, -- your knife

}

for _, v in ipairs(weaponsToGive) do

giveWeapon(source, v.id, v.ammo, v.setAsCurrent)

end

setElementModel(source, 137)

setPedHeadless ( source, true )

outputChatBox ( "You are now a Zombie.", source, 255, 0, 0 )

end

end

)

Share this post


Link to post

La script Che hai postato non e d aiuto.

Che gm usi come "background"?

Share this post


Link to post

Se la gm funziona con cosa la usi? .map o createObject?

Non è possibile che il codice che hai postato è una gm completa :)

Share this post


Link to post

Ok ho capito il problema,attualmente la gamemode cambia mappa quando un player passa su un marker,mentre invece tu vuoi che cambia mappa quando tutti diventano zombie?

Cmq la funzione è questa :

  
function StartNextMap () 
exports.mapmanager:changeGamemode( getResourceFromName('aa') ) 
end 
  

Se hai cambiato nome alla gm non dimenticare di editare "aa" con quello che hai scelto,e le mappe devono essere tipo lol-mappa invece di aa-mappa

Share this post


Link to post

Se vuoi fare in modo che parte una nuova mappa quando tutti diventano zombie e molto semplice.

Fai uno script client side con onClientRender.

Esempio :

numeroPlayers = get players online

numeroZombie = get players nel team zombie

if numeroPlayers == numeroZombie then -- qui serve il tonumber

setTimer(StartNextMap,10000,1)

oppure solo StartNextMap () se vuoi farla partire sbt

Share this post


Link to post

Si ma non mi hai detto quando deve partire la nuova mappa.

Quando rimane un player o tutti zombie.

Dettagli

Share this post


Link to post
Vorrei che quando rimangono soltanto gli zombies cambi mappa dopo 10 secondi

Si ma mi spieghi perche cazzo fai il post anche in scripting?

Non vuoi essere aiutato allora,aspetto che ti risponda qualcuno li allora.

Share this post


Link to post
  
addEventHandler("onPlayerWasted", root, 
function() 
local numberPLayers = getPlayerCount() 
local numberZombie = getPlayersInTeam ( Zombies ) 
if tonumber (numberPLayers)  == tonumber (numberZombie ) then 
setTimer(StartNextMap,10000,1) 
    end 
end 
) 
  

Non l ho testata,aggiungila sotto e vedi se funge (credo di si)

Share this post


Link to post

L hai testato quello che ti ho dato?

Se hai problemi dagli -1 a numberPlayers

Share this post


Link to post

No, nnt, non funziona neanche con -1

Aspetta, ho appena visto nella console del server, c'è un errore nel codice che mi hai appena dato, nn so come aggiustarlo

E' questo :

[2013-07-08 12:56:57] WARNING: aa\aa.lua:133: Bad argument @ 'getPlayersInTeam'

Share this post


Link to post

Fai una cosa,passami l intera cartella e stasera te la riparo.

Senza la gamemode non posso risolvere questi problemi.

Una cosa ancor piu pratica e che se hai steam mi aggiungi e quando hai bisogno d aiuto ti rispondo subito.

Il nome su steam è Hunterix (lol)

Share this post


Link to post

La gamemode la puoi scaricare da qui:

https://community.multitheftauto.com/in ... ils&id=478

ricorda che io il file aa.lua, c'è l'ho cosi:

local aa_root = getRootElement() 
teamSurvivor = createTeam ( "Humans", 0, 255, 0 ) 
teamZombies = createTeam ( "Zombies", 255, 0, 0 ) 
  
function loadmap(startmap, player) 
    mapRoot = getResourceRootElement(startmap) 
    local plrs = getElementsByType( "player" ); 
    for i, plr in pairs( plrs ) do 
    setElementData( plr, "Deaths", 0 ) 
  
    -- ///////////////// SPAWN \\\\\\\\\\\\\\\\\\\\ 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setTimer( setPedSkin , 500 , 1 , plr, math.random(9,288)) 
    spawnPlayer( plr, x, y, z, rot); 
    setCameraTarget ( plr, plr ); 
    fadeCamera( plr, true ); 
        for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
            giveWeapon( plr, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
        end 
    end 
end 
addEventHandler("onGamemodeMapStart", aa_root, loadmap) 
  
function aa_onResourceStart( resourcename, res ) 
    setTeamFriendlyFire(teamSurvivor , 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("scoreboard"), "addScoreboardColumn", "Deaths" ) 
    end 
    if resourceName == 'mapmanager' then 
        mapmanager = createResourceCallInterface('mapmanager') 
    end 
end 
addEventHandler( "onResourceStart", aa_root, aa_onResourceStart ) 
  
function joinHandler() 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setElementData( source, "inmarker", false ); 
    setPlayerTeam ( source, teamSurvivor ) 
    spawnPlayer( source, x, y, z, rot ) 
    setTimer( setPedSkin , 500 , 1 , source, math.random(9,288)) 
    outputChatBox("< Welcome To Against All By CHAOS_IS_ME>", source, 255, 138, 0, true) 
    outputChatBox("< Current Version: #00FF00 1.0>", source, 255, 138, 0, true) 
    setCameraTarget ( source, source ) 
    setElementData( source, "Deaths", 0 ) 
    fadeCamera(source, true) 
    for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
        giveWeapon( source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
    end 
end 
addEventHandler("onPlayerJoin", aa_root, joinHandler) 
  
  
function aa_playerWasted( totalAmmo, killer ) 
    local playerdeaths = getElementData ( source, "Deaths" ) 
    setElementData ( source, "Deaths", playerdeaths+1 ) 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local skin = math.random(9,288) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setPlayerTeam ( source, teamZombies ) 
    setTimer( spawnPlayer , 5000 , 1 , source, x, y, z, rot) 
    setCameraTarget ( source, source ) 
    fadeCamera(source, true) 
    --[[ idk what the  is dat 
    for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
        setTimer( giveWeapon, 5000 , 1 , source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
    end]] 
end 
addEventHandler ( "onPlayerWasted", aa_root, aa_playerWasted ) 
  
local localPlayerName = getPlayerName(aa_root) 
  
  
  
    -- ///////////////// Cose aggiunte da me \\\\\\\\\\\\\\\\\\\\ 
  
    -- ///////////////// Quando un umano muore, entra nel gruppo zombies \\\\\\\\\\\\\\\\\\\\ 
  
  
infection = createPickup (-1, 1, 3.11, 3, 1275, 15000 ) 
function infected ( thePlayer ) 
    setPlayerTeam ( thePlayer, teamZombies ) 
    setPedSkin ( thePlayer, 13 ) 
    setPedHeadless ( thePlayer, true ) 
end 
addEventHandler ( "onPickupUse", infection, infected )  
  
addEventHandler("onPlayerSpawn", root, 
function() 
    if(getPlayerTeam(source) == teamZombies) then 
    local weaponsToGive = { 
        { id = 4, ammo = 30, setAsCurrent = true }, -- your knife 
    } 
    for _, v in ipairs(weaponsToGive) do 
        giveWeapon(source, v.id, v.ammo, v.setAsCurrent) 
    end 
    setElementModel(source, 137) 
    setPedHeadless ( source, true ) 
    outputChatBox ( "You are now a Zombie.", source, 255, 0, 0 ) 
    end 
end 
) 

Share this post


Link to post

Che faticaccia :mrgreen:

Ci sono alcuni bug che non riguardano quello che ho fatto,ad esempio quando il player spawna non sta nel team humans.

cmq prova ora e fammi sapere,a me funziona ma sono solo io nel Home server.Devi provare con altri giocatori.

  
local aa_root = getRootElement() 
teamSurvivor = createTeam ( "Humans", 0, 255, 0 ) 
teamZombies = createTeam ( "Zombies", 255, 0, 0 ) 
  
function loadmap(startmap, player) 
    mapRoot = getResourceRootElement(startmap) 
    local plrs = getElementsByType( "player" ); 
    for i, plr in pairs( plrs ) do 
    setElementData( plr, "Deaths", 0 ) 
  
    -- ///////////////// SPAWN \\\\\\\\\\\\\\\\\\\\ 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setTimer( setPedSkin , 500 , 1 , plr, math.random(9,288)) 
    spawnPlayer( plr, x, y, z, rot); 
    setCameraTarget ( plr, plr ); 
    fadeCamera( plr, true ); 
        for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
            giveWeapon( plr, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
        end 
    end 
end 
addEventHandler("onGamemodeMapStart", aa_root, loadmap) 
  
function aa_onResourceStart( resourcename, res ) 
    setTeamFriendlyFire(teamSurvivor , 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("scoreboard"), "addScoreboardColumn", "Deaths" ) 
    end 
    if resourceName == 'mapmanager' then 
        mapmanager = createResourceCallInterface('mapmanager') 
    end 
end 
addEventHandler( "onResourceStart", aa_root, aa_onResourceStart ) 
  
function joinHandler() 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setElementData( source, "inmarker", false ); 
    setPlayerTeam ( source, teamSurvivor ) 
    spawnPlayer( source, x, y, z, rot ) 
    setTimer( setPedSkin , 500 , 1 , source, math.random(9,288)) 
    outputChatBox("< Welcome To Against All By CHAOS_IS_ME>", source, 255, 138, 0, true) 
    outputChatBox("< Current Version: #00FF00 1.0>", source, 255, 138, 0, true) 
    setCameraTarget ( source, source ) 
    setElementData( source, "Deaths", 0 ) 
    fadeCamera(source, true) 
    for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
        giveWeapon( source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
    end 
end 
addEventHandler("onPlayerJoin", aa_root, joinHandler) 
  
  
function aa_playerWasted( totalAmmo, killer ) 
    local playerdeaths = getElementData ( source, "Deaths" ) 
    setElementData ( source, "Deaths", playerdeaths+1 ) 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local skin = math.random(9,288) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setPlayerTeam ( source, teamZombies ) 
    setTimer( spawnPlayer , 1000 , 1 , source, x, y, z, rot) 
    setCameraTarget ( source, source ) 
    setTimer(checkZombieForNextMap,3000,1) 
    fadeCamera(source, true) 
    --[[ idk what the  is dat 
    for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
        setTimer( giveWeapon, 5000 , 1 , source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
    end]] 
end 
addEventHandler ( "onPlayerWasted", aa_root, aa_playerWasted ) 
  
local localPlayerName = getPlayerName(aa_root) 
  
  
  
    -- ///////////////// Cose aggiunte da me \\\\\\\\\\\\\\\\\\\\ 
  
    -- ///////////////// Quando un umano muore, entra nel gruppo zombies \\\\\\\\\\\\\\\\\\\\ 
  
  
infection = createPickup (-1, 1, 3.11, 3, 1275, 15000 ) 
function infected ( thePlayer ) 
    setPlayerTeam ( thePlayer, teamZombies ) 
    setPedSkin ( thePlayer, 13 ) 
    setPedHeadless ( thePlayer, true ) 
end 
addEventHandler ( "onPickupUse", infection, infected ) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    if(getPlayerTeam(source) == teamZombies) then 
    local weaponsToGive = { 
        { id = 4, ammo = 30, setAsCurrent = true }, -- your knife 
    } 
    for _, v in ipairs(weaponsToGive) do 
        giveWeapon(source, v.id, v.ammo, v.setAsCurrent) 
    end 
    setElementModel(source, 137) 
    setPedHeadless ( source, true ) 
    outputChatBox ( "You are now a Zombie.", source, 255, 0, 0 ) 
    end 
end 
) 
  
-- // Hai eliminato il nextmap della versione originale -.- 
  
function checkZombieForNextMap () 
local theTeam = getTeamFromName ( "Zombies"  ) 
if theTeam then 
numberPLayers = tonumber( getElementsByType( "player" )) 
numberZombie = tonumber (getPlayersInTeam ( theTeam )) 
if numberPLayers  ==  numberZombie then 
setTimer(StartNextMap,10000,1) 
-- qui puoi aggiungere un trigger client per far apparire un immagine per il nextmap o il tempo o un testo. 
end 
end 
end 
  
function StartNextMap () 
    exports.mapmanager:changeGamemode( getResourceFromName('aa') ) 
end 
  
  

Share this post


Link to post

fUNZIONA :mrgreen:

Ma quando si starta la nuova mappa, il personaggio nn si trova in nessun gruppo, puoi fixare questo cosa??

Nel senzo che se si fa TAB si vedono i due gruppi, e sopra a tutto i player (che nn si trovano in nessun gruppo) rappresentati in bianco.

Fixalo per favore :cry:

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.