I help a friend with a prison rp gamemode and i found this:
Anyone here that can explain me this:
I know its a loop type of deal but i wonder how its work more precise. And if there is a alternative to this. For me look strange....
PHP Code:
COMMAND:pm(playerid, params[])
{
new targetid, message[128], str[128], i;
i = 0;
if(sscanf(params,"us[128]", targetid, message))return SendClientMessage(playerid, GREY, "USAGE: /pm [playerid] [message]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, GREY, "ID-ul tinta nu exista.");
if(targetid == playerid) return SendClientMessage(playerid, GREY, "Nu iti poti trimite PM singur.");
if(PlayerStat[playerid][TogPM] == 1) return SendClientMessage(playerid, GREY, "You have disabled PMs (/togpm to enable them).");
if(PlayerStat[playerid][AdminLevel] < 1 && PlayerStat[targetid][TogPM] == 1) return SendClientMessage(playerid, GREY, "The player has disabled PMs.");
if(PlayerStat[playerid][AdminLevel] < 1 && AutoPM[targetid][0] != 0)
{
format(str, sizeof(str), "(([%d]AutoPM from %s: %s))", targetid, GetOOCName(targetid), AutoPM[targetid]);
SendClientMessage(playerid, YELLOW, str);
return 1;
}
if(Server[PMsStatus] == 0) return SendClientMessage(playerid, GREY, "PMs are disabled by an admin.");
if(strlen(message) < 1) return SendClientMessage(playerid, GREY, "Mesajul este prea scurt.");
if(strlen(message) > 100) return SendClientMessage(playerid, GREY, "Mesajul este prea lung.");
format(str, sizeof(str), "(([%d]PM from %s: %s))", playerid, GetOOCName(playerid), message);
SendClientMessage(targetid, YELLOW, str);
if(PMsTracked[targetid] == 1)
{
loop_start1:
if(IsPlayerConnected(i) == 1)
{
if(i > MAX_PLAYERS)
{
goto script_continue;
}
if(TrackPMs[i] == targetid)
{
format(str, sizeof(str), "((PM from %s to %s: %s))", GetOOCName(playerid), GetOOCName(targetid), message);
SendClientMessage(i, YELLOW, str);
PlayerPlaySound(i, 1085, 0, 0 ,0);
i++;
goto loop_start1;
}
else
{
i++;
goto loop_start1;
}
}
else
{
i++;
goto loop_start1;
}
}
if(PMsTracked[playerid] == 1)
{
loop_start2:
if(IsPlayerConnected(i) == 1)
{
if(i > MAX_PLAYERS)
{
goto script_continue;
}
if(TrackPMs[i] == playerid)
{
format(str, sizeof(str), "((PM from %s to %s: %s))", GetOOCName(playerid), GetOOCName(targetid), message);
SendClientMessage(i, YELLOW, str);
PlayerPlaySound(i, 1085, 0, 0 ,0);
i++;
goto loop_start2;
}
else
{
i++;
goto loop_start2;
}
}
else
{
i++;
goto loop_start2;
}
}
script_continue:
PlayerPlaySound(targetid, 1085, 0, 0 ,0);
format(str, sizeof(str), "(([%d]PM to %s: %s))", targetid, GetOOCName(targetid), message);
PlayerPlaySound(playerid, 1137, 0, 0 ,0);
SendClientMessage(playerid, YELLOW, str);
format(str, sizeof(str), "%s PM'd %s: %s", GetOOCName(playerid), GetOOCName(targetid), message);
PMLog(str);
return 1;
}
PHP Code:
loop_start1:
if(IsPlayerConnected(i) == 1)
{
if(i > MAX_PLAYERS)
{
goto script_continue;
}
if(TrackPMs[i] == targetid)
{
format(str, sizeof(str), "((PM from %s to %s: %s))", GetOOCName(playerid), GetOOCName(targetid), message);
SendClientMessage(i, YELLOW, str);
PlayerPlaySound(i, 1085, 0, 0 ,0);
i++;
goto loop_start1;
}
else
{
i++;
goto loop_start1;
}
}
else
{
i++;
goto loop_start1;
}