[Help] Is this causing Infinite Loop? - 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: [Help] Is this causing Infinite Loop? (
/showthread.php?tid=478241)
[Help] Is this causing Infinite Loop? -
David (Sabljak) - 28.11.2013
Hello i have this 2 things in my script, i think they causing infinite loop so server freezes? Can someone check it
First Code
Код:
new c = 0;
for(new n = 0; n < 20; n++)
{
if(udb_hash(member[n]) == udb_hash("Niko"))
{
//the rest of my code
return 1;
}
else if(udb_hash(member[n]) != udb_hash("Niko"))
{
c++;
if(c == 20) return SCM(playerid... //the rest of my code
}
}
Second Code
Код:
new org[64]; new c = 0;
new ime[MAX_PLAYER_NAME];
GetPlayerName(playerid, ime, sizeof(ime));
format(org,64,"Org_%d.ini",PlayerInfo[playerid][pOrg]);
INI_ParseFile(org, "LoadMembers_%s", .bExtra = true, .extra = playerid);
for(new n = 0; n < 20; n++)
{
if(udb_hash(member[n]) != udb_hash(ime))
{
c++;
}
if(c == 20)
{
//the rest of my code
}
}
Re: [Help] Is this causing Infinite Loop? -
Loot - 28.11.2013
How did you defined 'member' in your first code?
Re: [Help] Is this causing Infinite Loop? -
David (Sabljak) - 28.11.2013
Код:
new member[20][MAX_PLAYER_NAME];
at top of script
Re: [Help] Is this causing Infinite Loop? -
David (Sabljak) - 29.11.2013
Anyone? Advice? Help?
Re: [Help] Is this causing Infinite Loop? -
Threshold - 29.11.2013
I don't know why you're hashing anything in this situation..
First Code:
pawn Код:
new c = 0;
for(new n = 0; n < 20; n++)
{
if(strcmp(member[n], "Niko", false) == 0)
{
//the rest of my code
return 1;
}
else
{
c++;
}
if(c == 20) return SCM(playerid... //the rest of my code
}
Second Code:
pawn Код:
new org[64], c = 0;
new ime[MAX_PLAYER_NAME];
GetPlayerName(playerid, ime, sizeof(ime));
format(org,64,"Org_%d.ini",PlayerInfo[playerid][pOrg]);
INI_ParseFile(org, "LoadMembers_%s", .bExtra = true, .extra = playerid);
for(new n = 0; n < 20; n++)
{
if(strcmp(member[n], ime, false) != 0)
{
c++;
}
if(c == 20)
{
//the rest of my code
}
}
Re: [Help] Is this causing Infinite Loop? -
David (Sabljak) - 30.11.2013
Thanks, i will try to use that.