03.07.2016, 05:51
(
Последний раз редактировалось AbyssMorgan; 17.09.2017 в 18:34.
Причина: Update 1.2.1
)
This include contain function for fast loop for player.
Differences between foreach.inc and FoxForeach.inc
foreach.inc:
FoxForeach.inc:
Speed Test for Operation:
Test #1 Foreach for 500 players, 1000 operations per player
Test #2 Foreach for 400 players, 1000 operations per player (Players id 0 - 99 left the server)
FoxForeach:
Test #1 For 500000 iteration in 489 ms
Test #2 For 400000 iteration in 393 ms
Foreach:
Test #1 For 500000 iteration in 500 ms
Test #2 Server Crash. Why ?
Speed Test Script
Download:
FoxForeach.inc
FoxForeach.inc]
PHP код:
/****************************************************************************************************
* *
* FoX Foreach *
* *
* Copyright © 2016 Abyss Morgan. All rights reserved. *
* *
* Download: https://github.com/AbyssMorgan/SA-MP/tre...nclude/SAM *
* *
* Plugins: None *
* Modules: None *
* *
* File Version: 1.2.1 *
* SA:MP Version: 0.3.7 *
* *
* Functions: *
* FoxForeach(variable,tag); //Tags: Player, Bot, Character *
* *
* Player Functions: *
* CountFoxPlayer(); *
* FoxForeachRandomPlayer(); *
* bool:IsPlayerInFoxPool(playerid); *
* *
* Bot Functions: *
* CountFoxBot(); *
* FoxForeachRandomBot(); *
* bool:IsBotInFoxPool(playerid); *
* *
* Character Functions: *
* CountFoxCharacter(); *
* FoxForeachRandomCharacter(); *
* bool:IsCharacterInFoxPool(playerid); *
* *
* Extended functions: *
* foX(variable,beginning,end); *
* foreach(variable); *
* *
* Auto functions: *
* FoxForeachInit(); *
* bool:FoxAddPlayer(playerid); *
* bool:FoxRemovePlayer(playerid); *
* bool:FoxAddBot(playerid); *
* bool:FoxRemoveBot(playerid); *
* bool:FoxAddCharacter(playerid); *
* bool:FoxRemoveCharacter(playerid); *
* *
****************************************************************************************************/
foreach.inc:
PHP код:
foreach(new i : Player){
SendClientMessage(i,0xFFFFFFFF,"Hello players!");
}
foreach(new i : Bot){
SendClientMessage(i,0xFFFFFFFF,"Hello bot!");
}
foreach(new i : Character){
SendClientMessage(i,0xFFFFFFFF,"Hello all!");
}
PHP код:
FoxForeach(i,Player){
SendClientMessage(i,0xFFFFFFFF,"Hello players!");
}
FoxForeach(i,Bot){
SendClientMessage(i,0xFFFFFFFF,"Hello bots!");
}
FoxForeach(i,Character){
SendClientMessage(i,0xFFFFFFFF,"Hello all!");
}
Test #1 Foreach for 500 players, 1000 operations per player
Test #2 Foreach for 400 players, 1000 operations per player (Players id 0 - 99 left the server)
FoxForeach:
Test #1 For 500000 iteration in 489 ms
Test #2 For 400000 iteration in 393 ms
Foreach:
Test #1 For 500000 iteration in 500 ms
Test #2 Server Crash. Why ?
Speed Test Script
Download:
FoxForeach.inc
FoxForeach.inc]