[Include] Downloads por Jogador (Beta)
#1

Sobre
Esta include tem uma fбcil utilizaзгo. Esta й apenas para verificar se um jogador comeзou a realizar downloads, alйm de ter funзхes para saber se estб ainda baixando, tempo em segundos (int/string) de a quanto tempo estб realizando downloads, e tambйm saber quantos arquivos (modelos, texturas) foram baixados. Havia disponibilizado um link antes de criar um tуpico, mas estava aguardando o lanзamento da versгo 0.3.8... Quando foi cancelada, acabei me esquecendo de criar o tуpico.

Funзхes Disponнveis
Код:
// Jogador
IsPlayerDownloading(playerid);
GetPlayerDownloadTime(playerid);
GetPlayerDownloadedFiles(playerid, virtualworld=0);
GetPlayerDownloadedTextures(playerid, virtualworld=0);
GetPlayerDownloadedModels(playerid, virtualworld=0);
GetPlayerDownloadVirtualWorld(playerid);	
GetPlayerDownloadTimeString(playerid);

Float:GetPlayerDownloadProgress(playerid);
GetPlayerDownloadedBytes(playerid);
IsPlayerUseRedirectDownload(playerid);


// Servidor
IsServerUseArtwork();
GetServerArtworkFolder(folder[]);

GetArtworkGlobalSimpleModels();
GetArtworkGlobalCharModels();
GetArtworksModelFiles();
GetArtworksTextureFiles();
	
GetArtworkModelFilesInVW(virtualworld);
GetArtworkTextureFilesInVW(virtualworld);
GetArtworkSimpleModelInVW(virtualworld);
Callbacks Disponнveis
Код:
OnPlayerStartedDownloading(playerid, virtualworld);
Exemplo: Link

Changelog
Код:
v1.0
- Versгo inicial

v2.0
- Possibilidade de contar quantos arquivos foram baixados (em bytes). (NOTA: Isto sу й funcional caso o download seja feito pelo servidor e nгo usando RedirectDownload. O download pelo servidor sofre compressгo, entгo os dados obtidos por esta nгo serгo os mesmos que na pasta do cliente).
- Possibilidade de saber o progresso de downloads (em %). (NOTA: Isto sу serб funcional caso o jogador nгo tenha feito nenhum download inicial ou no mundo virtual que este entrou).
- Й possнvel agora contar quantos objetos, skins, modelos e texturas foram adicionados via script.
- Callback OnPlayerStartedDownload renomeada para OnPlayerStartedDownloading.
Download
GitHub

Requesitos
SA-MP 0.3.DL
Reply
#2

legal, muito util vou utilizar aqui, ficou muito bom o code, sу nгo entendi porque:
PHP код:
CallLocalFunction("OnPlayerStartedDownload""dd"playeridPlayerDownload[playerid][_VirtualWorld]); 
e nгo:
PHP код:
#if defined OnPlayerStartedDownload
    
OnPlayerStartedDownload(playeridPlayerDownload[playerid][_VirtualWorld]);
#endif 
Reply
#3

Quote:
Originally Posted by RazorGuigo
Посмотреть сообщение
legal, muito util vou utilizar aqui, ficou muito bom o code, sу nгo entendi porque:
PHP код:
CallLocalFunction("OnPlayerStartedDownload""dd"playeridPlayerDownload[playerid][_VirtualWorld]); 
e nгo:
PHP код:
#if defined
    
OnPlayerStartedDownload(playeridPlayerDownload[playerid][_VirtualWorld]);
#endif 
Isto poderia gerar um erro caso a callback nгo seja usada no script.
Reply
#4

Quote:
Originally Posted by Locky_
Посмотреть сообщение
Isto poderia gerar um erro caso a callback nгo seja usada no script.
mals meu erro de digitaзгo da para colocar "#if defined OnPlayerStartedDownload " deboas que nгo da erro na compilaзгo e o cуdigo tem um melhor desempenho,

fiz um pullrequest com as seguintes contribuiзхes se quiser elas:

PHP код:
//server
stock GetTotalFilesDownload()
//Player Functions:
stock GetRemainingFiles(playerid)
stock Float:GetPlayerPercentageFiles(playerid
Reply
#5

Quote:
Originally Posted by RazorGuigo
Посмотреть сообщение
mals meu erro de digitaзгo da para colocar "#if defined OnPlayerStartedDownload " deboas que nгo da erro na compilaзгo e o cуdigo tem um melhor desempenho,

fiz um pullrequest com as seguintes contribuiзхes se quiser elas:

PHP код:
//server
stock GetTotalFilesDownload()
//Player Functions:
stock GetRemainingFiles(playerid)
stock Float:GetPlayerPercentageFiles(playerid
Sei que hб melhoria em desempenho, porйm eu fiz testes no compilador e quando a funзгo nгo estб implementada ocorre o erro de funзгo nгo implementada com a linha da include. Por isso estб sendo usado CallLocalFunction.

Irei analisar as novas funзхes em breve.
Reply
#6

@Topic mto bom.
Serб que NetStats_BytesSent й influenciado pelos modelos baixados? Se for seria possнvel obter: bytes baixados, velocidade atual do download, tempo restante de download, etc..

@off й insignificante a diferenзa.
Quote:
Originally Posted by RazorGuigo
Посмотреть сообщение
legal, muito util vou utilizar aqui, ficou muito bom o code, sу nгo entendi porque:
PHP код:
CallLocalFunction("OnPlayerStartedDownload""dd"playeridPlayerDownload[playerid][_VirtualWorld]); 
e nгo:
PHP код:
#if defined OnPlayerStartedDownload
    
OnPlayerStartedDownload(playeridPlayerDownload[playerid][_VirtualWorld]);
#endif 
Reply
#7

mt bom cara " Thanks for adding reputation to this user. May you be lucky enough to receive the same Reputation back in turn. "
Reply
#8

Quote:
Originally Posted by Dayvison_
Посмотреть сообщение
@Topic mto bom.
Serб que NetStats_BytesSent й influenciado pelos modelos baixados? Se for seria possнvel obter: bytes baixados, velocidade atual do download, tempo restante de download, etc..

@off й insignificante a diferenзa.
Eu realizei testes e nгo tive resultados bons. Havia baixado 30mb e enquanto a funзгo me retornou cerca de 40kb.
Reply
#9

Estava olhando seu include, tenho algumas sugestхes:
  • Renomear OnPlayerStartedDownload para OnPlayerStartedDownloading apenas para concordвncia com OnPlayerFinishedDownloading
  • OnPlayerStartedDownload suportar virtualworlds
  • Adicionar funзхes para medir a quantidade baixada.(Use estб lуgica abaixo)
    PHP код:
    static
        
    downloadBytes[MAX_PLAYERS],
        
    finishedDownload[MAX_PLAYERS char]
    ;
    public 
    OnPlayerStartedDownload(playeridvirtualworld); {
        
    downloadBytes[playerid] = NetStats_BytesSent(playerid);
    }
    public 
    OnPlayerFinishedDownloading(playeridvirtualworld) {
        
    downloadBytes[playerid] = GetDownloadedBytes(playerid);
        
    finishedDownload{playerid} = 1;
        return 
    1;
    }
    GetDownloadedBytes(playerid)
    {
        if(
    finishedDownload{playerid})
            return 
    downloadBytes[playerid];
        return 
    NetStats_BytesSent(playerid) - downloadBytes[playerid];

  • Agora que temos como medir a quantidade baixada, adicionar tambйm:
    • GetDownloadBytesRemaing total_bytes - downloaded_bytes
    • GetDownloadSpeed started_time / downloaded_bytes
    • GetDownloadTimeRemaing download_speed / bytes_remaing
Reply
#10

Quote:
Originally Posted by Dayvison_
Посмотреть сообщение
Estava olhando seu include, tenho algumas sugestхes:
  • Renomear OnPlayerStartedDownload para OnPlayerStartedDownloading apenas para concordвncia com OnPlayerFinishedDownloading
  • OnPlayerStartedDownload suportar virtualworlds
  • Adicionar funзхes para medir a quantidade baixada.(Use estб lуgica abaixo)
    PHP код:
    static
        
    downloadBytes[MAX_PLAYERS],
        
    finishedDownload[MAX_PLAYERS char]
    ;
    public 
    OnPlayerStartedDownload(playeridvirtualworld); {
        
    downloadBytes[playerid] = NetStats_BytesSent(playerid);
    }
    public 
    OnPlayerFinishedDownloading(playeridvirtualworld) {
        
    downloadBytes[playerid] = GetDownloadedBytes(playerid);
        
    finishedDownload{playerid} = 1;
        return 
    1;
    }
    GetDownloadedBytes(playerid)
    {
        if(
    finishedDownload{playerid})
            return 
    downloadBytes[playerid];
        return 
    NetStats_BytesSent(playerid) - downloadBytes[playerid];

  • Agora que temos como medir a quantidade baixada, adicionar tambйm:
    • GetDownloadBytesRemaing total_bytes - downloaded_bytes
    • GetDownloadSpeed started_time / downloaded_bytes
    • GetDownloadTimeRemaing download_speed / bytes_remaing
Em meus testes eu verifiquei que isto nгo й funcional caso utilize um redirecionamento de downloads.

OnPlayerStartedDownload jб tem suporte aos mundos virtuais.
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)