Raised This Month: $ Target: $400
 0% 

Invalid function or declaration


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-12-2005 , 13:15   Invalid function or declaration
Reply With Quote #1

Why aren't these 2 codings good enough to compile?

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <cstrike> #define TOTALCOLORS 3 new Float:colors[TOTALCOLORS][3] colors[0] = {123.0, 123.0, 123.0} colors[1] = {456.0, 456.0, 456.0} colors[2] = {789.0, 789.0, 789.0} //rest of code

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <cstrike> #define TOTALCOLORS 3 new Float:colors[TOTALCOLORS][3] colors[0][0] = 255.0; colors[0][1] = 0.0; colors[0][2]  = 0.0; colors[1][0] = 165.0; colors[1][1] = 0.0; colors[1][2]  = 0.0; colors[2][0] = 255.0; colors[2][1] = 100.0; colors[2][2]  = 100.0;

In fact, the 2 pieces of code are the same (code 2 is done much more differcult ;) )
(they both don't work)

Whats the problem?

TiA
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-12-2005 , 13:17  
Reply With Quote #2

Are you implying that one of those works and the other gives you the error?
Brad is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-12-2005 , 13:23  
Reply With Quote #3

No, they both give me a compile error

(error 010: invalid function or declaration)
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-12-2005 , 13:28  
Reply With Quote #4

Would you be so kind as to provide the entire source?
Brad is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 12-12-2005 , 13:28  
Reply With Quote #5

I hope you aren't doing that on the global scope.
__________________
hello, i am pm
PM is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-12-2005 , 13:31  
Reply With Quote #6

Yes, I was actually doing it on a global scope

Could you expain me whats wrong with that then?

(@brad ... the whole source doesn't matter, besides, I want to make it a surprise for someone else)
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 12-12-2005 , 13:37  
Reply With Quote #7

Well, in small, you can only have these things on global scope:
  • - comments
    - preprocessor stuff
    - global variable definitions
    - function declarations and definitions

Real statements like assigments are not allowed there (the only entry points in small programs are public functions; the host applications decides when to call those; so from a logical point of view, when would code placed outside any function be executed?) .

If you want to simply initialize the global variable to the specified values, do:
Code:
new Float:colors[TOTALCOLORS][3] = { {123.0, 123.0, 123.0}, {456.0, 456.0, 456.0}, {789.0, 789.0, 789.0} }

Maybe you'd like to declare the variable const as well if small supports it.

edit: freaking typos!

Brad: I'm CHUCK NORRIS and I HAVE A BEARD
__________________
hello, i am pm
PM is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-12-2005 , 13:41  
Reply With Quote #8

Perhaps your problem is that you have code outside of the a function. Either assign the values within your new statement or assign them somewhere else such as plugin_cfg.

Edit: Damn you and your quickness, PM! ;)
Brad is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-12-2005 , 13:46  
Reply With Quote #9

Ah, thnx PM and Brad
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Reply



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 16:10.


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