IT error. - 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: IT error. (
/showthread.php?tid=620571)
IT error. -
KessMan - 31.10.2016
Not work.
Код HTML:
new Iterator:Gangs[MAX_PLAYERS]<4>;
Iter_Add(Gangs[playerid], 2);
foreach(new i : Gangs[i]<2>)
{
// code ......
}
Re: IT error. -
KessMan - 31.10.2016
Anyone?
Re: IT error. -
Eoussama - 31.10.2016
Never used foreach before, but could this work?
PHP код:
foreach(new i , Gangs[i]<2>)
{
// code ......
}
Re: IT error. -
X337 - 31.10.2016
Код:
new Iterator:Gangs[4]<MAX_PLAYERS>;
Iter_Init(Gangs); // You need to use this for multidimensional array
Iter_Add(Gangs[2], playerid);
foreach(new i : Gangs[2])
{
print("Player id %d is a member of gang id 2", i);
}
You should use Iter_Init for multidimensional array.
And i guess you're trying to insert playerid into gang iterator, so i've changed the way you declare "Gangs" variable and the loop code.
Re: IT error. -
KessMan - 31.10.2016
Quote:
Originally Posted by X337
Код:
new Iterator:Gangs[4]<MAX_PLAYERS>;
Iter_Init(Gangs); // You need to use this for multidimensional array
Iter_Add(Gangs[2], playerid);
foreach(new i : Gangs[2])
{
print("Player id %d is a member of gang id 2", i);
}
You should use Iter_Init for multidimensional array.
And i guess you're trying to insert playerid into gang iterator, so i've changed the way you declare "Gangs" variable and the loop code.
|
I must use the "Iter_Init(Gangs);" every time you add or remove a playerid of iterations?
Exemple:
Код HTML:
Iter_Init(Gangs), Iter_Add(Gangs[2], playerid); // code ....
Код HTML:
Iter_Init(Gangs), Iter_Remove(Gangs[2], playerid); // code ....
Re: IT error. -
Konstantinos - 31.10.2016
No, only once in
OnGameModeInit/
OnFilterScriptInit callback.
If you use YSI 4, you can use a more optimized way:
pawn Код:
new Iterator:Gangs<4, MAX_PLAYERS>;
which is
4 + MAX_PLAYERS and not
4 * MAX_PLAYERS. With that, you don't need to call Iter_Init too.
Re: IT error. -
X337 - 31.10.2016
No, just once after you declare the "Gangs" variable
Re: IT error. -
KessMan - 31.10.2016
thank you all.
Re: IT error. -
KessMan - 31.10.2016
Quote:
Originally Posted by X337
No, just once after you declare the "Gangs" variable
|
Код HTML:
if(hittype == 1 && (pInfo[playerid][pMember] == pInfo[hitid][pMember] || Iter_Contains(HuntEventPlayers, playerid)))
If they use "Iter_contains" in this "if" pawn has crash...
why?...
Re: IT error. -
X337 - 31.10.2016
Can you show me how you declare "HuntEventPlayers" ?