error 017: undefined symbol "i"
#1

Hello,

I keep getting: error 017: undefined symbol "i" with the code below

Код:
public UpdateTextdraw()
{
	new szString[40];
    foreach(Player, i)
	{
	    // AFK
		if (GetPVarInt(i, "AFK") == 1) TextDrawShowForPlayer(i, afk);
		else TextDrawHideForPlayer(i, afk);
	    if (IsPlayerInAnyVehicle(i))
	    {
	    	new Float:X, Float:Y, Float:Z;
	    	GetPlayerPos(i, X, Y, Z);

	    	 // FUEL
	        format(szString, 40, "Fuel:~w~ %d", Gas[GetPlayerVehicleID(i)]);
	        TextDrawSetString(TD_0[i], szString);

	        // DIST
	        new Float:Dist;
			Dist = GetDistanceBetweenPoints(X, Y, Z, IslandX[i], IslandY[i], IslandZ[i]);
	        if (GetPVarInt(i, "Flight") > 0 || GetPVarInt(i, "Work") > 0)
	        {
	     		format(szString, 40, "DIST:~w~ %d", floatround(Dist, floatround_round));
	        	TextDrawSetString(TD_4[i], szString);
			}
			else
			{
			    TextDrawSetString(TD_4[i], "DIST:~w~ None");
			}

	        // DMG
	        new Float:HP;
			GetVehicleHealth(GetPlayerVehicleID(i), HP);
	        format(szString, 40, "DMG:~w~ %d", floatround(HP, floatround_round));
	        TextDrawSetString(TD_3[i], szString);

	        // ALT

	        format(szString, 40, "ALT:~w~ %d", floatround(Z, floatround_ceil));
	        TextDrawSetString(TD_5[i], szString);

	        // VEHICLE
	        format(szString, 40, "VEH:~w~ %s", GetVehicleFriendlyName(GetPlayerVehicleID(i)));
	        TextDrawSetString(TD_6[i], szString);

	        // STATUS
	        if (GetPVarInt(i, "Work") > 0)
	        {
	            TextDrawSetString(TD_7[i], "Status:~w~ Work");
			}

			if (GetPVarInt(i, "Flight") == 1)
			{
				TextDrawSetString(TD_7[i], "Status:~w~ On Route");
			}

			if (GetPVarInt(i, "Flight") == 0)
			{
			    if (GetPVarInt(i, "Work") == 0)
			    {
			        if (IsAirVehicle(GetPlayerVehicleID(i)))
			        {
			            TextDrawSetString(TD_7[i], "Status:~w~ Flying");
					}
					else
					{
						TextDrawSetString(TD_7[i], "Status:~w~ None");
					}
				}
			}
Any help on how I can fix it??
Reply
#2

I really don't know much about Foreach, but create a new integer.

pawn Код:
new szString[40], i;
Reply
#3

Update your foreach include to the lastest version, becauser you're using an old one and replace:
pawn Код:
foreach(Player, i)
To
pawn Код:
foreach (new i : Player)
Reply
#4

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Update your foreach include to the lastest version, becauser you're using an old one and replace:
pawn Код:
foreach(Player, i)
To
pawn Код:
foreach (new i : Player)
Alright I updated and replaced it here is the code now:

Код:
public UpdateTextdraw()
{
	new szString[40];
    foreach (new i : Player)
	{
	    // AFK
		if (GetPVarInt(i, "AFK") == 1) TextDrawShowForPlayer(i, afk);
		else TextDrawHideForPlayer(i, afk);
	    if (IsPlayerInAnyVehicle(i))
	    {
	    	new Float:X, Float:Y, Float:Z;
	    	GetPlayerPos(i, X, Y, Z);

	    	 // FUEL
	        format(szString, 40, "Fuel:~w~ %d", Gas[GetPlayerVehicleID(i)]);
	        TextDrawSetString(TD_0[i], szString);

	        // DIST
	        new Float:Dist;
			Dist = GetDistanceBetweenPoints(X, Y, Z, IslandX[i], IslandY[i], IslandZ[i]);
	        if (GetPVarInt(i, "Flight") > 0 || GetPVarInt(i, "Work") > 0)
	        {
	     		format(szString, 40, "DIST:~w~ %d", floatround(Dist, floatround_round));
	        	TextDrawSetString(TD_4[i], szString);
			}
			else
			{
			    TextDrawSetString(TD_4[i], "DIST:~w~ None");
			}

	        // DMG
	        new Float:HP;
			GetVehicleHealth(GetPlayerVehicleID(i), HP);
	        format(szString, 40, "DMG:~w~ %d", floatround(HP, floatround_round));
	        TextDrawSetString(TD_3[i], szString);

	        // ALT

	        format(szString, 40, "ALT:~w~ %d", floatround(Z, floatround_ceil));
	        TextDrawSetString(TD_5[i], szString);

	        // VEHICLE
	        format(szString, 40, "VEH:~w~ %s", GetVehicleFriendlyName(GetPlayerVehicleID(i)));
	        TextDrawSetString(TD_6[i], szString);

	        // STATUS
	        if (GetPVarInt(i, "Work") > 0)
	        {
	            TextDrawSetString(TD_7[i], "Status:~w~ Work");
			}

			if (GetPVarInt(i, "Flight") == 1)
			{
				TextDrawSetString(TD_7[i], "Status:~w~ On Route");
			}

			if (GetPVarInt(i, "Flight") == 0)
			{
			    if (GetPVarInt(i, "Work") == 0)
			    {
			        if (IsAirVehicle(GetPlayerVehicleID(i)))
			        {
			            TextDrawSetString(TD_7[i], "Status:~w~ Flying");
					}
					else
					{
						TextDrawSetString(TD_7[i], "Status:~w~ None");
					}
				}
			}
and these are the errors I get now:

Код:
error 017: undefined symbol "foreach"
error 029: invalid expression, assumed zero
error 017: undefined symbol "i"
fatal error 107: too many error messages on one line
All the errors are on "foreach (new i : Player)". Any ideas on how I can fix it??

P.S Sorry I am pretty newby on PAWNO
Reply
#5

Did you include it at the top?
pawn Код:
#include <a_samp>
#include <foreach>
Reply
#6

Did you get the latest version of foreach? The above doesn't work for older versions.
Reply
#7

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Did you include it at the top?
pawn Код:
#include <a_samp>
#include <foreach>
Quote:
Originally Posted by Sinner
Посмотреть сообщение
Did you get the latest version of foreach? The above doesn't work for older versions.
Yes the error is still the same
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)