03.03.2018, 07:27
This FS will allow you to get the amount of data downloaded and call onplayerfinishdownloading a proper version which wouldnt call when the virtual world changes, The amount of data downloaded is not exact and not very accurate but its close to it as the amount increases the longer time spent in downloading files, anyways this is just a small workaround for OnPlayerFinishedDownloading broken version and with this FS you can have a proper callback on your gamemode as this will call a function on your gamemode called "OnPlayerFinishDownloading"
To put on gamemode:
Filterscript:
You dont need any plugin or some shit just plug n play.
I know this is useless but im just providing a workaround for ppl who need it. there would be bugs cuz i havent tested this out on a public server only on lan.
Bug(s):
To put on gamemode:
Code:
forward OnPlayerFinishDownloading(playerid, datamb); public OnPlayerFinishDownloading(playerid, datamb) { /*SendClientMessage(playerid, 1, "{00FF33}You have completely downloaded all files."); new String[256]; format(String, 256, "{FFFFFF}Downloaded: {00FF33}%0.2f {FFFFFF}MBs of Data.", datamb); SendClientMessage(playerid, 1, String);*/ // Put whatever you want return 1; }
Code:
#include <a_samp> new Downloaded[MAX_PLAYERS]; new PlayerTick[MAX_PLAYERS]; stock GetTickDiff(newtick, oldtick) { if (oldtick < 0 && newtick >= 0) { return newtick - oldtick; } else if (oldtick >= 0 && newtick < 0 || oldtick > newtick) { return (cellmax - oldtick + 1) - (cellmin - newtick); } return newtick - oldtick; } public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Download Meter SA-MP 0.3.DL"); print("--------------------------------------\n"); return 1; } public OnPlayerConnect(playerid) { Downloaded[playerid] = 0; PlayerTick[playerid] = GetTickCount(); return 1; } public OnPlayerFinishedDownloading(playerid, virtualworld) { if(Downloaded[playerid] == 1) return 1; if(GetTickDiff(GetTickCount(), PlayerTick[playerid]) > 1000) { Downloaded[playerid] = 1; new Float: bytesOfPlayer = NetStats_BytesSent(playerid); new Float: Megabytes = bytesOfPlayer / 1024 / 1024; CallRemoteFunction("OnPlayerFinishDownloading", "df", playerid, Megabytes); } else { Downloaded[playerid] = 1; // Player changed virtual worlds } return 1; }
I know this is useless but im just providing a workaround for ppl who need it. there would be bugs cuz i havent tested this out on a public server only on lan.
Bug(s):
Quote:
If the server change virtual world before the player downloads, the callback will be called, Fix: Don't call SetPlayerVirtualWorld right on connect and only do it after OnplayerFinishDownloading is called. |