New syntax troubles
Hello I'm trying to transfer this to the new syntax:
Code:
stock ZMarketCookiesToArray(client, String:rebuyweapons[WeaponsSlot][], maxweapons, maxlen) Code:
stock void ZMarketCookiesToArray(int client, String:rebuyweapons[WeaponsSlot][], int maxweapons, int maxlen) Code:
stock void ZMarketCookiesToArray(int client, char rebuyweapons[WeaponsSlot][], int maxweapons, int maxlen) Code:
/** error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x') Is there a possibility to solve that? Also I have another doubt. Usually when we want to declare multiple variables with the same value we do: int a, b, c, d; (all initialized as 0) in the old syntax we could do this: Code:
new targets[MAXPLAYERS], bool:tn_is_ml, result; If I try to make it like: Code:
int targets[MAXPLAYERS], bool tn_is_ml, result; I use that here: Code:
result = ProcessTargetString(target, client, targets, sizeof(targets), COMMAND_FILTER_ALIVE, targetname, sizeof(targetname), tn_is_ml); |
Re: New syntax troubles
You don't have to define a size (WeaponsSlot), you can do this:
PHP Code:
PHP Code:
PHP Code:
|
Re: New syntax troubles
I forgot to mention that rebuyweapons is declared like this:
Code:
char rebuyweapons[WeaponsSlot][WEAPONS_MAX_LENGTH]; Code:
/** Code:
stock void ZMarketCookiesToArray(int client, char[][] rebuyweapons, int maxweapons, int maxlen) // zr/weapons/zmarket.inc(1168) : warning 213: tag mismatch // zr/weapons/zmarket.inc(1168) : warning 229: index tag mismatch (symbol "rebuyweapons") What does these errors means? How can I solve that? |
Re: New syntax troubles
PHP Code:
|
Re: New syntax troubles
Dynamic array so gotta convert it to this:
PHP Code:
|
Re: New syntax troubles
that makes sense now. And I have a last question I promise :D
let's say we have this Code:
KnockbackSetVelocity(client, const Float:startpoint[3], const Float:endpoint[3], Float:magnitude) Code:
void KnockbackSetVelocity(int client, const float startpoint[3], const float endpoint[3], float magnitude) Code:
void KnockbackSetVelocity(int client, const float[3] startpoint, const float[3] endpoint, float magnitude) I ended up having this doubt too after reading BAILOPAN's first post from 2014 where he demonstrates us how weird would it be if we try to express this using the tagging system and the declaration rules of chars also contributed to increase my doubts his example: Code:
native float[3] GetEntOrigin(); |
Re: New syntax troubles
Yes, they seem to work the same way.
|
Re: New syntax troubles
Quote:
|
Re: New syntax troubles
No, they're different - but the difference is immaterial until SourcePawn moves further along.
float[3] foo = type is float[3], a fixed array of 3 floats, foo is a single float[3]. float bar[3] = type is float, bar is a dynamic array of 3 floats. You almost always want the former, especially for vectors. |
Re: New syntax troubles
Quote:
|
All times are GMT -4. The time now is 18:46. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.