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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Loop. (
/showthread.php?tid=105904)
Loop. -
Striker_Moe - 31.10.2009
Hi there.
This loop is not working and I need to know why.
Код:
public sotd()
{
new string[128],planame[MAX_PLAYER_NAME];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(kills[i] > highestkills)
{
bestkiller[i] = 1;
GetPlayerName(i, planame, sizeof(planame));
format(string, sizeof(string), "Soldier of the day: %s [%d kills]", planame, highestkills );
SendClientMessageToAll(GREEN, string);
}
else
{
if(!highestkills < kills[i])
{
highestkills = kills[i];
}
}
}
}
Re: Loop. -
Nero_3D - 31.10.2009
if you say the loop isnt working I understand that the code stops working after
pawn Код:
new string[128],planame[MAX_PLAYER_NAME];
but that is wrong because the loop looks ok
Test where exactly the code doesnt works with some prints, like I put it in your code
pawn Код:
public sotd()
{
print("*** sotd got called!");
new string[128],planame[MAX_PLAYER_NAME];
print("*** variables created!");
for(new i=0; i<MAX_PLAYERS; i++)
{
printf("*** Loop %d!", i);
if(kills[i] > highestkills)
{
bestkiller[i] = 1;
GetPlayerName(i, planame, sizeof(planame));
format(string, sizeof(string), "Soldier of the day: %s [%d kills]", planame, highestkills );
SendClientMessageToAll(GREEN, string);
}
else
{
if(!highestkills < kills[i])
{
highestkills = kills[i];
}
}
}
print("sotd got successfully executed!");
}
if you dont see the first message in the server window then the function never got called!