AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Code Errors Please Help (https://forums.alliedmods.net/showthread.php?t=221714)

Viggi Bear 07-25-2013 10:57

Code Errors Please Help
 
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.


11530 07-25-2013 11:57

Re: Code Errors Please Help
 
  • 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.

Eden.Campo 07-25-2013 12:49

Re: Code Errors Please Help
 
Quote:

Originally Posted by Viggi Bear (Post 1998481)
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;
}


Viggi Bear 07-26-2013 05:29

Re: Code Errors Please Help
 
Code:

/groups/sourcemod/upload_tmp/textVwJ7Lc.sp(2) : fatal error 120: cannot read from file: "morecolors"

Viggi Bear 07-26-2013 05:29

Re: Code Errors Please Help
 
urggh

Viggi Bear 07-26-2013 06:01

Re: Code Errors Please Help
 
urggh

Sillium 07-26-2013 07:08

Re: Code Errors Please Help
 
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!

Eden.Campo 07-26-2013 07:36

Re: Code Errors Please Help
 
1 Attachment(s)
Quote:

Originally Posted by Viggi Bear (Post 1998985)
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.

Viggi Bear 07-27-2013 02:54

Re: Code Errors Please Help
 
Im getting undefined symbols even with the offline compiler. Damn!

Eden.Campo 07-27-2013 04:26

Re: Code Errors Please Help
 
Quote:

Originally Posted by Viggi Bear (Post 1999678)
Im getting undefined symbols even with the offline compiler. Damn!

I gave you a compiled working version, post above.


All times are GMT -4. The time now is 21:46.

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