26.04.2011, 09:36
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:
The cmd define is:
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):
MAXPLAYERS variable is set on OnGameModeInit, this is not the problem:
Please help me :S
Код:
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
Код:
#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; \
}
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 = GetServerVarAsInt("maxplayers");

