SA-MP Forums Archive
Function spams the same text - 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: Function spams the same text (/showthread.php?tid=617820)



Function spams the same text - ShoortyFl - 26.09.2016

Hello, i have a problem with this function, what i'm trying to do is loop through all created teleports and also get the distance, but it spam for examle, if i have only one spawn, and its like 1 meter from me it will display sth like


Spawn - 1 meters
2100.9 meters
2100.9 meters
2100.9 meters
2100.9 meters
2100.9 meters
2100.9 meters
2100.9 meters
2100.9 meters
2100.9 meters


Code:

pawn Код:
for(new i = 0; i < sizeof(Teleport); i++)
        {
            format(str, sizeof(str), "%s - %0.2f\n", Teleport[i][Naziv], GetPlayerDistanceFromPoint(playerid, Teleport[i][PozX], Teleport[i][PozY], Teleport[i][PozZ]));
            strcat(info, str, sizeof(info));
        }



Re: Function spams the same text - Konstantinos - 27.09.2016

Check if the name of the teleport is not null before getting the distance.