[AYUDA] foreach error [[ + REP ]] - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [AYUDA] foreach error [[ + REP ]] (
/showthread.php?tid=578622)
[AYUDA] foreach error [[ + REP ]] -
alanmn88 - 21.06.2015
En este momento estoy modificando un GM llamdo LV:RP para agregar objetos y edificios etc... al querer compilar denuevo, me pidio demasiados includes que poco a poco fui consiguiendo, una vez termine con eso, solucione casi todos los problemas que tenia el codigo pero me falto uno y no se como resolverlo
Mi problema inicia con el include "foreach"
Esta en la parte casi final de esta parte de codigo
Код:
// Stocks
stock Float:GetPlayerPacketLoss(playerid) {
new stats[401], stringstats[70];
GetPlayerNetworkStats(playerid, stats, sizeof(stats));
new len = strfind(stats, "Packetloss: ");
new Float:packetloss = 0.0;
if(len != -1) {
strmid(stringstats, stats, len, strlen(stats));
new len2 = strfind(stringstats, "%");
if(len != -1) {
strdel(stats, 0, strlen(stats));
strmid(stats, stringstats, len2-3, len2);
packetloss = floatstr(stats);
}
}
return packetloss;
}
forward OnScriptUpdate();
public OnScriptUpdate()
{
foreach(new i : Player)
{
new pPing = GetPlayerPing(i);
new Float:pPacket = GetPlayerPacketLoss(i);
new iString[128];
format(iString,sizeof(iString),"~w~~h~~h~Ping ~r~~h~~h~%d ~w~~h~~h~PacketLoss ~r~~h~~h~%.1f%%", pPing, pPacket);
PlayerTextDrawSetString(i, FPSPingPacket[i],iString);
}
}
Estos son los errores que me da en el Pawno Compiler: (Todos los errores son en la misma linea: foreach(new i : Player))
C:\Users\MLG_OPBoT\Desktop\GTA San Andreas\SERVER\gamemodes\lvrp.pwn(40117) : error 017: undefined symbol "foreach"
C:\Users\MLG_OPBoT\Desktop\GTA San Andreas\SERVER\gamemodes\lvrp.pwn(40117) : error 029: invalid expression, assumed zero
C:\Users\MLG_OPBoT\Desktop\GTA San Andreas\SERVER\gamemodes\lvrp.pwn(40117) : error 017: undefined symbol "i"
C:\Users\MLG_OPBoT\Desktop\GTA San Andreas\SERVER\gamemodes\lvrp.pwn(40117) : fatal error 107: too many error messages on one line
Porfavor Alguien que me pueda dar una soluciуn?
Re: [AYUDA] foreach error [[ + REP ]] -
Dusan01 - 21.06.2015
U should read forum rules, its only english!!!
and ur foreach is not good, try using it like this:
Re: [AYUDA] foreach error [[ + REP ]] -
Konstantinos - 21.06.2015
Quote:
Originally Posted by Dusan01
and ur foreach is not good, try using it like this:
|
It's the other way around. Your syntax is old and deprecated.
@alanmn88: Include foreach or y_iterate to the script.
Respuesta: [Help] foreach error [[ + REP ]] -
alanmn88 - 21.06.2015
Sorry for the post in spanish :/ , Thanks to the people that posted a solution to my problem, Now its fixed! Yay!