SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 03/03/2018, 07:27 AM   #1
MafiaOink
Big Clucker
 
MafiaOink's Avatar
 
Join Date: Jun 2014
Location: Pakistan
Posts: 167
Reputation: 15
Default DownloadMeter (0.3.DL)

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:
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;
}
Filterscript:
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;
}

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):
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.
Attached Files
File Type: pwn DownloadMeter.pwn (1.1 KB, 32 views)
File Type: amx DownloadMeter.amx (2.8 KB, 0 views)
__________________
MafiaOink is offline   Reply With Quote
Old 03/03/2018, 11:15 AM   #2
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,498
Reputation: 325
Default Re: DownloadMeter (0.3.DL)

Shouldn't this be an include?
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link




Code:
You may only contact me through the links on my signature, if else then its an impersonating one, i am not on any other place not mentioned in my signature.
RogueDrifter is offline   Reply With Quote
Old 03/03/2018, 05:33 PM   #3
Locky_
High-roller
 
Locky_'s Avatar
 
Join Date: Jul 2012
Posts: 1,570
Reputation: 311
Default Re: DownloadMeter (0.3.DL)

Did you get to test this correctly?

I used their logic and it was not even accurate ... I downloaded 30MB in files and the native's return told me that I downloaded about 40KB.
Locky_ is offline   Reply With Quote
Old 04/03/2018, 05:58 AM   #4
MafiaOink
Big Clucker
 
MafiaOink's Avatar
 
Join Date: Jun 2014
Location: Pakistan
Posts: 167
Reputation: 15
Default Re: DownloadMeter (0.3.DL)

Quote:
Originally Posted by Locky_ View Post
Did you get to test this correctly?

I used their logic and it was not even accurate ... I downloaded 30MB in files and the native's return told me that I downloaded about 40KB.
I know, I couldn't find a way to calculate but I noticed that the bytes received from server increased as you were downloading so I thought to use it instead, but when I tried in my local server the results were like close to what I downloaded,
downloaded: 37 MB in actual
server detected: 35 MB


but do you mean 40 KB or 40 MB?
__________________
MafiaOink is offline   Reply With Quote
Old 04/03/2018, 11:50 AM   #5
Locky_
High-roller
 
Locky_'s Avatar
 
Join Date: Jul 2012
Posts: 1,570
Reputation: 311
Default Re: DownloadMeter (0.3.DL)

Quote:
Originally Posted by MafiaOink View Post
I know, I couldn't find a way to calculate but I noticed that the bytes received from server increased as you were downloading so I thought to use it instead, but when I tried in my local server the results were like close to what I downloaded,
downloaded: 37 MB in actual
server detected: 35 MB


but do you mean 40 KB or 40 MB?
Downloaded: 30mb
By the native: 40kb (bytes / 1024)

PS: I believe that because I use RedirectDownload this is not functional. Downloading through the server it seems that the progress estimated by the NetStats function can work.

Last edited by Locky_; 04/03/2018 at 02:17 PM.
Locky_ is offline   Reply With Quote
Old 05/03/2018, 11:25 AM   #6
MafiaOink
Big Clucker
 
MafiaOink's Avatar
 
Join Date: Jun 2014
Location: Pakistan
Posts: 167
Reputation: 15
Default Re: DownloadMeter (0.3.DL)

Quote:
Originally Posted by Locky_ View Post
Downloaded: 30mb
By the native: 40kb (bytes / 1024)

PS: I believe that because I use RedirectDownload this is not functional. Downloading through the server it seems that the progress estimated by the NetStats function can work.
Well I didnt have RedirectDownload in my mind so... it wouldnt work with that.
__________________
MafiaOink is offline   Reply With Quote
Old 05/03/2018, 11:53 AM   #7
Locky_
High-roller
 
Locky_'s Avatar
 
Join Date: Jul 2012
Posts: 1,570
Reputation: 311
Default Re: DownloadMeter (0.3.DL)

I've noticed that size may never really be what we have on disk. The server uses compression during download. I for example bass by 13mb game, on disk are 30mb.

Quote:
Originally Posted by Kalcor
- Adds data compression to file downloads. Note: Downloads with thousands of small files can still be slow.
Downloading features are best accounted for using in a single script (fs / gm). I made this include if you want to know more: http://forum.sa-mp.com/showthread.php?t=650640
Locky_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 08:35 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.