Jump to content

[REQ] Simple Gamemode


Recommended Posts

If it's so simple then why can't you do it? :lol:

If it's so simple, why don't you show him ?

hi all,

Im requesting an simple gamemode that can load an map and spawn players at the maps spawnpoint.

Just an simple script that i need as my base and build from there.

Greatings Frank

Edit : To be constructive. Look at this post I've made. It is what you want (almost) - a basic dumb freeroam mode. It doesn't use a map for spawn points however, but should get you started.

Link to comment

hey, ive got some problems with this gamemode, its all working now, you do spawn, but i have some problems with the teams, ive got the TeamBalance but i want that on Spawn player gets random put in Team1 or Team2, ive looked trough some functions but i can't seem to get it working.

My GM:

   
addEventHandler("onPlayerJoin",getRootElement(), 
    function() 
    local joinedPlayerName = getClientName ( source ) 
        joinHandler(source) 
        outputChatBox ( "Welcome " .. joinedPlayerName .. " to the official Arena Deathmatch server!!" , source, 255, 255, 255 ) 
    end 
) 
  
addEventHandler("onPlayerWasted",getRootElement(), 
    function() 
        setTimer(joinHandler,5000,1,source) 
    end 
) 
         
addEventHandler("onResourceStart",getRootElement(),  
    function(res) 
        if res == getThisResource() then 
            for _,player in pairs(getElementsByType("player")) do 
                joinHandler(player) 
            end 
        end 
    end 
) 
  
function joinHandler(player) 
    fadeCamera(player,true) 
    spawnPlayer(player,math.random(10) * 3,math.random(10) * 3,5) 
end 
  
function onGameResourceStart() 
      team1 = createTeam("Team1", 255, 0, 0) 
      team2 = createTeam("Team2", 255, 255, 0) 
end 
addEventHandler("onResourceStart", getRootElement(), onGameResourceStart) 
   
function balanceTeams ( thePlayer ) 
        local team1 = getTeamFromName ( "Team1" ) 
        local team2 = getTeamFromName ( "Team2" ) 
        local team1Count = countPlayersInTeam ( team1 ) 
        local team2Count = countPlayersInTeam ( team2 ) 
        if team1Count == team2Count then  
                setPlayerTeam ( thePlayer , team1 ) 
        elseif team1Count > team2Count then  
                setPlayerTeam ( thePlayer , team2Team )  
        elseif team1Count < team2Count then 
                setPlayerTeam ( thePlayer , team1Team )  
        end 
end 
addEventHandler("onPlayerJoin", getRootElement(), blanceTeams) 
  

Can someone help me with what?

Greatings Frank

Link to comment

I changed your code to this :

  
addEventHandler("onPlayerJoin",getRootElement(), 
    function() 
        local joinedPlayerName = getClientName ( source ) 
        joinHandler(source) 
        outputChatBox ( "Welcome " .. joinedPlayerName .. " to the official Arena Deathmatch server!!" , source, 255, 255, 255 ) 
    end 
) 
  
addEventHandler("onPlayerWasted",getRootElement(), 
    function() 
        setTimer(joinHandler,5000,1,source) 
    end 
) 
        
addEventHandler("onResourceStart",getRootElement(), 
    function(res) 
        if res == getThisResource() then 
             
            team1 = createTeam("Team1", 255, 0, 0) 
            team2 = createTeam("Team2", 255, 255, 0) 
  
            for _,player in pairs(getElementsByType("player")) do 
                setTimer(joinHandler,1000,1,player) 
            end 
        end 
    end 
) 
  
function joinHandler(player) 
    fadeCamera(player,true) 
    spawnPlayer(player,math.random(10) * 3,math.random(10) * 3,5) 
    balanceTeams(player) 
end 
  
function balanceTeams ( thePlayer ) 
        if countPlayersInTeam(team1) > countPlayersInTeam(team2) then 
                setPlayerTeam ( thePlayer , team2 ) 
        else 
                setPlayerTeam ( thePlayer , team1 ) 
        end 
end 
  

A few things:

1. You miss-spelled the call to balanceTeams() in the addEventHandler(). This should have come up as an error in the server console for you to find.

2. You weren't handling the team assingment when somebody was already connected on game mode start.

What's odd is that it didn't work when I started the game mode while connected but did when I joined (with it running). This is the reason for adding another timer into the onResourceStart() bit for player spawning - without it, it appears that using the newly created teams directly after seems to fail ?

Edit: You may need to clear the play team on wasted so that when he player goes through the balance process again, he's not already in a team e.g.

  
setPlayerTeam(player,nil) 
  

If you don't want to do that (which may swap a players team on death), you could just check to see if the players in a team and only assign them one if not e.g.

  
function balanceTeams ( thePlayer ) 
    if not getPlayerTeam(thePlayer) then 
        if countPlayersInTeam(team1) > countPlayersInTeam(team2) then 
                setPlayerTeam ( thePlayer , team2 ) 
        else 
                setPlayerTeam ( thePlayer , team1 ) 
        end  
    end 
end 
  

Link to comment
Oh yeah, now that you tell me i see it myself to, tanks mate!

May i ask you this last thing? :P

i don't understand how to load an map into the mode, can you explain me how to do this? it would realy help me :D

if you could do that i will be all happy.

Thanks, Grtz. Frank

Turn the mode on? Lol

Link to comment
Oh yeah, now that you tell me i see it myself to, tanks mate!

May i ask you this last thing? :P

i don't understand how to load an map into the mode, can you explain me how to do this? it would realy help me :D

if you could do that i will be all happy.

Thanks, Grtz. Frank

Turn the mode on? Lol

Omg, dude i mean to load an .map file -.-

Link to comment
Oh yeah, now that you tell me i see it myself to, tanks mate!

May i ask you this last thing? :P

i don't understand how to load an map into the mode, can you explain me how to do this? it would realy help me :D

if you could do that i will be all happy.

Thanks, Grtz. Frank

Turn the mode on? Lol

Omg, dude i mean to load an .map file -.-

What's the mapfile name?

Link to comment
But does this automaticly load the map into de mode? and how to tell the script to use the .map Spawnpoints inplace of the Random spawn?

Yes, it should load the spawnpoints. If you then want to spawn a player at a random spawnpoint, swap:

  
spawnPlayer(player,math.random(10) * 3,math.random(10) * 3,5) 
  

for

  
call(getResourceFromName("spawnmanager"),"spawnPlayerAtSpawnpoint",player) 
  

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