Thread: global variables

Results 1 to 2 of 2
  1. #1 global variables 
    Owner of OmniScape
    OmniPS's Avatar
    Join Date
    Jul 2013
    Posts
    310
    Thanks given
    80
    Thanks received
    49
    Rep Power
    48
    Hey,

    my server has 4 teams, and i want to have a interface that shows the total kills of the certain team. how do i make a global variable to do so?
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Sep 2013
    Posts
    13
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Here's something you can reference off of to make it, this is just an example.

    Code:
    // global team kill count variables
    private static int redTeamTotalKills = 0;
    private static int blueTeamTotalKills = 0;
    private static int greenTeamTotalKills = 0;
    private static int purpleTeamTotalKills = 0;
    
    private enum Team { NO_TEAM, RED_TEAM, BLUE_TEAM, GREEN_TEAM, PURPLE_TEAM }; // enums are constant int data types, represented with identifiers
    
    private int currentTeam = assignTeam(); // sets the players team using the assignTeam() function
    
    // you can assign a player a team like so
    int assignTeam()
    {
    
    	if (player.inRedStartArea())
    		return RED_TEAM;
    	else if (player.inBlueStartArea())
    		return BLUE_TEAM;
    	else if (player.inGreenStartArea())
    		return GREEN_TEAM;
    	else if (player.inPurpleStartArea())
    		return PURPLE_TEAM;
    		
    	return NO_TEAM;
    }
    
    /**
     *
     * @return returns the players team
     *
     */
    int getTeam()
    {
        return currentTeam;
    }
    
    /**
     *
     * @void increases the specific teams kill count
     * @param the players current team
     *
     */
    void increaseTeamKillCount(int team)
    {
    	switch(team)
    	{
    		case RED_TEAM: redTeamTotalKills++; break;
    		case BLUE_TEAM: blueTeamTotalKills++; break;
    		case GREEN_TEAM: greenTeamTotalKills++; break;
    		case PURPLE_TEAM: purpleTeamTotalKills++; break;
    		
    		default: break;
    	}
    }
    Reply With Quote  
     

  3. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [Tut] Adding/Moving/Removing Global Objects
    By XxMixTheMusicxX in forum Tutorials
    Replies: 17
    Last Post: 09-07-2007, 08:44 PM
  2. Environment Variables, An End to Paths.
    By Whitey in forum Tutorials
    Replies: 2
    Last Post: 07-23-2007, 09:28 AM
  3. Setting Variables
    By †ZerohControl† in forum Tutorials
    Replies: 1
    Last Post: 07-19-2007, 09:56 AM
  4. Working global objects for pimpscape!
    By wildy in forum Tutorials
    Replies: 5
    Last Post: 06-02-2007, 11:13 AM
  5. WhiteScape Global Objects
    By Santa Noobie in forum Tutorials
    Replies: 2
    Last Post: 05-29-2007, 10:51 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •