[HELPME] Something mistake.. but what? -
KoczkaHUN - 26.04.2011
What is wrong with it? My eyes went out but I can't find the problem. The compiler goes crazy if I put this in:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
cmd("motoz", 5)
new msg[92], weap[64];
new kit = GetNearestPlayer(playerid);
if (!IsPlayerConnected(kit)) return SendClientMessage(playerid, 0xffff10ff, "Go near the player!");
new ammo[13][2];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(kit, i, ammo[i][0], ammo[i][1]);
GetWeaponName(ammo[i][0], weap, sizeof(weap));
format(msg, sizeof(msg), "finds a(n) %s", weap);
if (ammo[i][1] > 0)
{
Act(playerid, msg);
}
}
end
The cmd define is:
Код:
#define cmd("%1",%2) if (strcmp(cmdtext[1], #%1, true, (%2)) == 0 && (cmdtext[(%2) + 1] == 0 || cmdtext[(%2) + 1] == 32)) \
{ \
new params[128]; \
if ((cmdtext[(%2) + 1]) == 0) strcat(params, ""); \
if ((cmdtext[(%2) + 1]) == 32) strcat(params, cmdtext[(%2) + 2]);
#define end return 1; \
}
altough this is not the problem, because I've got a bunch of cmd blocks in the GM, and they're working.
GetNearestPlayer (if it helps):
Код:
GetNearestPlayer(playerid, Float:range = 2.5)
{
if (!IsPlayerConnected(playerid)) return -1;
new Float:x, Float:y, Float:z;
for (new i = 0; i < MAXPLAYERS; i++)
{
if (i == playerid) continue;
if (!IsPlayerConnected(i)) continue;
GetPlayerPos(i, x, y, z);
if (IsPlayerInRangeOfPoint(playerid, range, x, y, z)) return i;
}
return -1;
}
MAXPLAYERS variable is set on OnGameModeInit, this is not the problem:
Код:
MAXPLAYERS = GetServerVarAsInt("maxplayers");
Please help me :S
Re: [HELPME] Something mistake.. but what? -
DeadAhead - 26.04.2011
Im not sure but it might be this end. Try removing it?
Re: [HELPME] Something mistake.. but what? -
KoczkaHUN - 29.04.2011
this is not the problem. as I said, I have a bunch of command like this, put in one OnPlayerCommandText. Those are working, if i put this one in, the compiler says for all the following commands
Код:
error 021: symbol already defined: "params"
Re: [HELPME] Something mistake.. but what? -
KoczkaHUN - 29.04.2011
I have an other command now which works exactly the same (bi-dimensional array created inside the expression).
I thought it is the "for" or it is the "switch" but neither is bad.
When I used a superglobal bi-dimensional array, it doesn't throw this error.
Please help me!
Re: [HELPME] Something mistake.. but what? -
MadeMan - 29.04.2011
Maybe you have the same thing?
https://sampforum.blast.hk/showthread.php?tid=200893
Re: [HELPME] Something mistake.. but what? -
DeadAhead - 29.04.2011
Oh geeze this is messy. If im not wrong he screwed everything up.
anyway...
you forgot a } at the end
and this code will execute whenever any player types any command
you also forgot return 0;
really messy ^^
Re: [HELPME] Something mistake.. but what? -
KoczkaHUN - 29.04.2011
This is not the full code. I have the """missing""" '}' bracket at the end, as following:
Код:
return SendClientMessage(playerid, 0xff0000aa, "* Hiba: a parancs nem lйtezik!");
}
Also, I have a lot of commands after that written by the same syntax like this.
Quote:
and this code will execute whenever any player types any command
|
check-it again, this method is tested and works.
I just fixed the problems by declaring the two 2-dimensional arrays before any strcmp() , now it works...
it's likely a pawno bug.
Re: [HELPME] Something mistake.. but what? -
KoczkaHUN - 29.04.2011
yes, i think it's a pawno bug, because it says "symbol already defined" for all variables that I use inside it and somewhere else in a command.
Re: [HELPME] Something mistake.. but what? -
Seven_of_Nine - 29.04.2011
Miйrt nem hasznбlsz ZCMD-t? Egyszerűbb, gyorsabb, jobban kezelhetőbb. Jameghбt sscanf-ot.
Hogyha azzal kell, йn meg tudom нrni a kуdot
Re: [HELPME] Something mistake.. but what? -
KoczkaHUN - 29.04.2011
sscanf-et hasznбlok. amъgy zcmd-t azйrt nem, mert abban nem kezelhetek йkezetes parancsokat (funkciуnйv, lбsd CMD:бrvнztűrőtьkцrfъrуgйp( bla bla bla) == FATAL ERROR. )