View Single Post
Eden.Campo
Member
Join Date: Mar 2013
Old 07-25-2013 , 12:49   Re: Code Errors Please Help
Reply With Quote #3

Quote:
Originally Posted by Viggi Bear View Post
I'm trying to make a plugin to make joining teams easier. But i get so many errrors.

Please see

CODE:

Code:
#include <sourcemod>
#include <morecolors>
#include <tf2>
#include <tf2_stocks>
#include <clients>

#pragma semicolon 1

#define TF_Spec 1
#define TF_Red 2 
#define TF_Blue 3


public Plugin:myinfo = 
{
	name = "Viggi Join",
	author = "Viggi",
	description = "Join Team",
	version = "1.0",
	url = "www.sourcemod.net"
}

public OnPluginStart()
{
	RegConsoleCmd("sm_join", Switch_Join);
	RegConsoleCmd("sm_remove", Switch_Remove);
}

public Action:Switch_Join(client,args):
{ if (IsClientConnected(client))
	
	{ new team= GetClientTeam(client);
	  new blu= GetTeamClientCount(TF_Blue);
	  new red= GetTeamClientCount(TF_Red);
	  
	  if (team==TF_Spec && blu==red && blu<6)
	  {ChangeClientTeam(client,TF_Blue);
	   CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You have joined {BLUE}Blu");
	  }
	  
	  if (team==TF_Spec && blu>red && red<6)
	  {ChangeClientTeam(client, TF_Red);
	   CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You have joined {RED}Red");
	  }
	  
	  if (team==TF_Spec && blu==6 && red==6)
	  {CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You cannot join at this period");
	  }
	  
	  if (team==TF_Blue || team==TF_Red)
	 {CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You already have a team");
     }
    }
	return Plugin_Handled;
}

public Action:Switch_Remove(client,args):
{ if (IsClientConnected(client))
	
	{ new team= GetClientTeam(client);
	  new blu= GetTeamClientCount(TF_Blue);
	  new red= GetTeamClientCount(TF_Red);
	  new teamcount = GetTeamClientCount(team);
	  
	  if (team==TF_Blue || team==TF_Red && teamcount<6)
	  {ChangeClientTeam(client,TF_Spec);
	   CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You have left.");
	  }
	  
	  if (team==TF_Blue || team==TF_Red && teamcount==6)
	  {CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You cannot leave.");
	  }
	  
	  if (team==TF_Spec)
	 {CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You are already in spec."
	 }
	  
    }
	return Plugin_Handled;
}
ERRORS:

Code:
/groups/sourcemod/upload_tmp/text8eIPce.sp(29) : error 029: invalid expression, assumed zero
/groups/sourcemod/upload_tmp/text8eIPce.sp(30) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(32) : error 055: start of function body without function header
/groups/sourcemod/upload_tmp/text8eIPce.sp(37) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(40) : error 054: unmatched closing brace ("}")
/groups/sourcemod/upload_tmp/text8eIPce.sp(42) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(45) : error 054: unmatched closing brace ("}")
/groups/sourcemod/upload_tmp/text8eIPce.sp(47) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(49) : error 054: unmatched closing brace ("}")
/groups/sourcemod/upload_tmp/text8eIPce.sp(51) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(53) : error 054: unmatched closing brace ("}")
/groups/sourcemod/upload_tmp/text8eIPce.sp(55) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(58) : error 029: invalid expression, assumed zero
/groups/sourcemod/upload_tmp/text8eIPce.sp(59) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(61) : error 055: start of function body without function header
/groups/sourcemod/upload_tmp/text8eIPce.sp(62) : error 021: symbol already defined: "team"
/groups/sourcemod/upload_tmp/text8eIPce.sp(63) : error 021: symbol already defined: "blu"
/groups/sourcemod/upload_tmp/text8eIPce.sp(64) : error 021: symbol already defined: "red"
/groups/sourcemod/upload_tmp/text8eIPce.sp(67) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(70) : error 054: unmatched closing brace ("}")
/groups/sourcemod/upload_tmp/text8eIPce.sp(72) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(74) : error 054: unmatched closing brace ("}")
/groups/sourcemod/upload_tmp/text8eIPce.sp(76) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(77) : error 054: unmatched closing brace ("}")
/groups/sourcemod/upload_tmp/text8eIPce.sp(77 -- 81) : error 010: invalid function or declaration
/groups/sourcemod/upload_tmp/text8eIPce.sp(77 -- 83) : warning 203: symbol is never used: "CPrintToChat"
/groups/sourcemod/upload_tmp/text8eIPce.sp(34) : warning 203: symbol is never used: "blu"
/groups/sourcemod/upload_tmp/text8eIPce.sp(35) : warning 203: symbol is never used: "red"
/groups/sourcemod/upload_tmp/text8eIPce.sp(65) : warning 203: symbol is never used: "teamcount"

25 Errors.
Your code is quite unreadable because of your indention, you place : in no-where and make statements wrong. I've fixed the code for you, didn't test it ingame but it compiled fine.

Code:
#include <sourcemod>
#include <morecolors>
#include <tf2>
#include <tf2_stocks>
#include <clients>

#pragma semicolon 1

#define TF_Spec 1
#define TF_Red 2 
#define TF_Blue 3


public Plugin:myinfo = 
{
	name = "Viggi Join",
	author = "Viggi",
	description = "Join Team",
	version = "1.0",
	url = "www.sourcemod.net"
}

public OnPluginStart()
{
	RegConsoleCmd("sm_join", Switch_Join);
	RegConsoleCmd("sm_remove", Switch_Remove);
}

public Action:Switch_Join(client,args)
{ 
	if (IsClientConnected(client))
	{ 
		new team = GetClientTeam(client);
		new blu = GetTeamClientCount(TF_Blue);
		new red = GetTeamClientCount(TF_Red);
	  
		if (team==TF_Spec && blu==red && blu<6)
		{
			ChangeClientTeam(client,TF_Blue);
			CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You have joined {BLUE}Blu");
		}
	  
		if (team==TF_Spec && blu>red && red<6)
		{
			ChangeClientTeam(client, TF_Red);
			CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You have joined {RED}Red");
		}
	  
		if (team==TF_Spec && blu==6 && red==6)
		{
			CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You cannot join at this period");
		}
	  
		if (team==TF_Blue || team==TF_Red)
		{
			CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You already have a team");
		}
	}
	return Plugin_Handled;
}

public Action:Switch_Remove(client,args)
{
	if(IsClientConnected(client))
	{
		new team = GetClientTeam(client);
		new teamcount = GetTeamClientCount(team);
	  
		if (team==TF_Blue || team==TF_Red && teamcount<6)
		{
			ChangeClientTeam(client,TF_Spec);
			CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You have left.");
		}
	  
		if (team==TF_Blue || team==TF_Red && teamcount==6)
		{
			CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You cannot leave.");
		}
	  
		if (team==TF_Spec)
		{
			CPrintToChat(client, "{HOTPINK} OAG- {GREEN} You are already in spec.");
		}
	}
	return Plugin_Handled;
}
Eden.Campo is offline