AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Array sizes do not match. (https://forums.alliedmods.net/showthread.php?t=49917)

[ --<-@ ] Black Rose 01-15-2007 17:18

Array sizes do not match.
 
I dunno what's wrong really... wont even compile.
The origin part is the problem.

Edit:It's not really important, I'm using separate arrays instead, I just wondered why it didn't work.
Code:
#include <amxmodx> enum info {     Float:origin[3],     str[10] } new array[1][info] public plugin_init() {     func(array[0][str], array[0][origin]) } stock func(str[], Float:origin[3]) {     }

XxAvalanchexX 01-15-2007 19:16

Re: Array sizes do not match.
 
Why do you create a multi-dimensional array, the first dimension having a size of 1? I'm suprised that it even lets you. You should just create a one-dimensional array.

[ --<-@ ] Black Rose 01-15-2007 20:05

Re: Array sizes do not match.
 
It was just an example.

Bad_Bud 01-16-2007 02:02

Re: Array sizes do not match.
 
AMXX compiler doesn't always tell you the correct location of the problem every time. A size 1 array is just... a variable... I bet if you just changed the size 1 arrays to variables the problems would go away and it would compile, even if it is pointing to Origin.

[ --<-@ ] Black Rose 01-16-2007 03:34

Re: Array sizes do not match.
 
It isn't pointing to origin. but if I would use this script it would work.
So the problem is really I can't use the origin in my func()
Code:
#include <amxmodx> enum info {     Float:origin[3],     str[10] } new array[1][info] public plugin_init() {     new Origin[3]     func(array[0][str], Origin) } stock func(str[], Float:origin[3]) {     }

schnitzelmaker 01-16-2007 09:30

Re: Array sizes do not match.
 
A Way is using a Temp Variable,here an example
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Test" #define VERSION "1.0" #define AUTHOR "Administrator" enum info{     ORIGIN[3],     STR[31] } new array[1][info] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)    } public client_putinserver(id){     new TempOrigin[3]         get_user_name(id,array[0][STR],31)     get_user_origin(id,TempOrigin)         //copy all [3]     array[0][ORIGIN] = TempOrigin     //copy only [1]     array[0][ORIGIN][1] = 100         func(array[0][STR], array[0][ORIGIN]) } //recommend use [],not [3] stock func(str[], origin[]) {     console_print(0,"test:%s,%d,%d,%d",str,origin[0],origin[1],origin[2]) }

dutchmeat 01-16-2007 09:53

Re: Array sizes do not match.
 
shouldn't 'origin[]' in the stock func be a float ?

P34nut 01-16-2007 09:54

Re: Array sizes do not match.
 
Quote:

Originally Posted by dutchmeat (Post 427931)
shouldn't 'origin[]' in the stock func be a float ?

no because he is using get_user_origin()

schnitzelmaker 01-16-2007 10:19

Re: Array sizes do not match.
 
Here a little better way with fakemeta and float:
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define PLUGIN "Test" #define VERSION "1.0" #define AUTHOR "Administrator" enum info{     Float:ORIGIN[3],     STR[31] } new array[1][info] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)    } public client_putinserver(id){     pev(id,pev_netname,array[0][STR],31)     pev(id,pev_origin,array[0][ORIGIN])     func(array[0][STR], array[0][ORIGIN]) }       //recommend use [],not [3] stock func(str[], Float:origin[]) {     console_print(0,"test:%s,%f,%f,%f",str,origin[0],origin[1],origin[2]) }

Simon Logic 01-16-2007 11:18

Re: Array sizes do not match.
 
Black Rose, here is fixed version of your code:
Code:
#include <amxmodx> enum info {     Float:vecOrigin[3],     str[10] } new array[1][info] public plugin_init() {     func(array[0][str], array[0][vecOrigin]) } stock func(str[], Float:origin[3]) {     }

Remember, that enumeration items are visible in global scope.

I suggest to name items with struc name prefix, i.e. "info" in your case, like this:
Code:
enum info {     Float:info_vecOrigin[3],     info_str[10] }


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

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