Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
Is there one? Using format() in a 2000 iteration vehicle loop makes the loop take about 5 seconds! Without it it takes mere miliseconds :/
Even filling the function with tonnes of functions (GetVehiclePos + IsPlayerInRangeOfPoint etc.) doesn't slow it down really at all, but format is taking the piss..
Posts: 1,167
Threads: 57
Joined: Jul 2010
Reputation:
0
Do you really need to use format for each car in less then second?
And what you want to formate, try to narrow, like use formate only for Streamed in cars or for cars in 0 Interior or so, just to avoid from blank loop with 2k format();
Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
I was just messing about, I don't need it tbh. I was just wondering A. why it's so slow and B. if there's a faster alternative.
Posts: 1,167
Threads: 57
Joined: Jul 2010
Reputation:
0
Need to improvise.
like you can do
new PlayerInEvent[MAX_PLAYERS];
In some event command
Loop for i
if(IsPlayerInEventCar(i,car)) { PlayerInEvent[i] = 1; }
Later elsewhere
Loop for i
if(PlayerInEvent[i] == 1) { SendClient(i,-1," you are in event"); }
or
new PlayerInEvent[10]; //As not whole server can be in the same event aka arena orso.
In some event command
Loop for i
if(IsPlayerInEventCar(i,car)) { Loop for B PlayerInEvent[b] = i; }
Later elsewhere
Loop for i
SendClient(PlayerInEvent[i],-1," you are in event");
Hope you got what I mean, like make slots for certain things, not always you have to loop through all cars or players, or like some faction cars can load apples example, you dont need to use Apples[MAX_VEHICLES]; but just Apples[Faction cars count];
Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
I use foreach. I don't WANT to do format for 2000 vehicles. I did it as a TEST. I want to know if there are alternatives that DON'T LAG.
Posts: 91
Threads: 9
Joined: Mar 2012
Reputation:
0
strcat concatenates two strings - might you post an example to use it with floats or integers?