Raised This Month: $12 Target: $400
 3% 

Code Errors Please Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Viggi Bear
Junior Member
Join Date: Jun 2013
Old 07-25-2013 , 10:57   Code Errors Please Help
Reply With Quote #1

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.
Viggi Bear is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 07-25-2013 , 11:57   Re: Code Errors Please Help
Reply With Quote #2

  • Remove the colons on lines 29 and 57 - colons don't go after function signatures.
  • Add a semicolon to the end of line 21 - the last line of the myinfo box.
  • Remove lines 61 and 62 - you aren't using red or blu in this function.
  • Missing a closing parenthesis and semicolon at the end of line 75 on the CPrintToChat line.
  • And finally, pretty bad indentation. Don't put your first statement in a block on the same line as the curly bracket.
__________________
11530 is offline
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
Viggi Bear
Junior Member
Join Date: Jun 2013
Old 07-26-2013 , 05:29   Re: Code Errors Please Help
Reply With Quote #4

Code:
/groups/sourcemod/upload_tmp/textVwJ7Lc.sp(2) : fatal error 120: cannot read from file: "morecolors"
Viggi Bear is offline
Viggi Bear
Junior Member
Join Date: Jun 2013
Old 07-26-2013 , 05:29   Re: Code Errors Please Help
Reply With Quote #5

urggh
Viggi Bear is offline
Viggi Bear
Junior Member
Join Date: Jun 2013
Old 07-26-2013 , 06:01   Re: Code Errors Please Help
Reply With Quote #6

urggh
Viggi Bear is offline
Sillium
AlliedModders Donor
Join Date: Sep 2008
Location: Germany
Old 07-26-2013 , 07:08   Re: Code Errors Please Help
Reply With Quote #7

You are missing the include file. Get morecolors and compile it with the offline compiler and not the webcompiler.

Also: don't bump your threads!
__________________
brb, dishes have developed their own language and are talking to the garbage about overthrowing me... i must correct this

www.unterwasserpyromanen.de
Sillium is offline
Eden.Campo
Member
Join Date: Mar 2013
Old 07-26-2013 , 07:36   Re: Code Errors Please Help
Reply With Quote #8

Quote:
Originally Posted by Viggi Bear View Post
Code:
/groups/sourcemod/upload_tmp/textVwJ7Lc.sp(2) : fatal error 120: cannot read from file: "morecolors"
You should use the offline compiler, anyways here is the compiled version.
Attached Files
File Type: smx viggijoin.smx (9.7 KB, 107 views)
Eden.Campo is offline
Viggi Bear
Junior Member
Join Date: Jun 2013
Old 07-27-2013 , 02:54   Re: Code Errors Please Help
Reply With Quote #9

Im getting undefined symbols even with the offline compiler. Damn!
Viggi Bear is offline
Eden.Campo
Member
Join Date: Mar 2013
Old 07-27-2013 , 04:26   Re: Code Errors Please Help
Reply With Quote #10

Quote:
Originally Posted by Viggi Bear View Post
Im getting undefined symbols even with the offline compiler. Damn!
I gave you a compiled working version, post above.
Eden.Campo is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode