SA-MP Forums Archive
/stats (DIALOG) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /stats (DIALOG) (/showthread.php?tid=628100)



/stats (DIALOG) - AwokenNeoX - 05.02.2017

I want to change that /stats will be shown in a dialog box. Its from the Lux Admin Script

Код:
dcmd_stats(playerid,params[])
{
	new string[128];
	new pDeaths;
	new player1, h, m, s;

	if(!strlen(params)) player1 = playerid;
	else player1 = strval(params);

	if(IsPlayerConnected(player1))
	{
    TotalGameTime(player1, h, m, s);
	if(AccInfo[player1][Deaths] == 0) pDeaths = 1;
	else pDeaths = AccInfo[player1][Deaths];
	format(string, sizeof(string), "|- %s's Statistics -|",PlayerName2(player1));
	SendClientMessage(playerid, green, string);
	format(string, sizeof(string), "Kills: [%d] | Deaths: [%d] | Ratio: [%0.2f] | Money: [$%d] | Time: [%d] hrs [%d] mins [%d] secs |", AccInfo[player1][Kills], AccInfo[player1][Deaths], Float:AccInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s);
	return SendClientMessage(playerid, green, string);
	} else
	return SendClientMessage(playerid, COLOR_MESSAGE_RED, "* Sorry, Player Not Connected!");
}
Thanks a lot


Re: /stats (DIALOG) - Juonis - 05.02.2017

https://sampwiki.blast.hk/wiki/Dialog_Styles
https://sampwiki.blast.hk/wiki/How_to_Create_a_Dialog
https://sampforum.blast.hk/showthread.php?tid=293436
https://sampforum.blast.hk/showthread.php?tid=379247

Just pick and lets go.


Re: /stats (DIALOG) - AwokenNeoX - 05.02.2017

I know how to create a dialog and I tried it a few times, but I dont know how to add the stats into the dialog box.
I want to like:

Player Stats's

Kill: 10
Death: 5
Ratio: 2.00
Money: 60000$
Time: 20 Hours


Re: /stats (DIALOG) - haikalbintang - 06.02.2017

It's really confusing when i read your code
But i clean up your code & use an dialog for your stats here :

PHP код:
#define DIALOG_STATS 9999
forward ShowPlayerStats(playeridtargetid);
public 
ShowStats(playeridgiveplayerid)
{
    new 
string[512], tmp[512], hms;
    
format(tmpsizeof(tmp), "|-  %s's Statistics -|\n\n"GetPlayerNameEx(giveplayerid));
    
strcat(stringtmp);
    
format(tmpsizeof(tmp), "Kills: [%d]\nDeaths: [%d]\nRatio: [%0.2f]\nMoney: [$%d]\nTime: [%d] hrs [%d] mins [%d] secs"AccInfo[player1][Kills], AccInfo[player1][Deaths], Float:AccInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), hms);
    
strcat(stringtmp);
    
ShowPlayerDialog(playeridDIALOG_STATSDIALOG_STYLE_MSGBOX"- Stats -"string"OK""");
    return 
1;
}
dcmd_stats(playeridparams[])
{
    new 
string[128];
    new 
player1;
    if(!
strlen(params)) player1 playerid;
    else 
player1 strval(params);
    if(
IsPlayerConnected(player1))
    {
        if(
AccInfo[player1][Deaths] == 0
        {    
            
AccInfo[player1][Deaths]++;
        }
        else
        {
            
ShowPlayerStats(playeridplayer1);
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_MESSAGE_RED"* Sorry, Player Not Connected!");
    }
    return 
1;

I hope this will be helpful


Re: /stats (DIALOG) - AwokenNeoX - 06.02.2017

Quote:
Originally Posted by haikalbintang
Посмотреть сообщение
It's really confusing when i read your code
But i clean up your code & use an dialog for your stats here :

PHP код:
#define DIALOG_STATS 9999
forward ShowPlayerStats(playeridtargetid);
public 
ShowStats(playeridgiveplayerid)
{
    new 
string[512], tmp[512], hms;
    
format(tmpsizeof(tmp), "|-  %s's Statistics -|\n\n"GetPlayerNameEx(giveplayerid));
    
strcat(stringtmp);
    
format(tmpsizeof(tmp), "Kills: [%d]\nDeaths: [%d]\nRatio: [%0.2f]\nMoney: [$%d]\nTime: [%d] hrs [%d] mins [%d] secs"AccInfo[player1][Kills], AccInfo[player1][Deaths], Float:AccInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), hms);
    
strcat(stringtmp);
    
ShowPlayerDialog(playeridDIALOG_STATSDIALOG_STYLE_MSGBOX"- Stats -"string"OK""");
    return 
1;
}
dcmd_stats(playeridparams[])
{
    new 
string[128];
    new 
player1;
    if(!
strlen(params)) player1 playerid;
    else 
player1 strval(params);
    if(
IsPlayerConnected(player1))
    {
        if(
AccInfo[player1][Deaths] == 0
        {    
            
AccInfo[player1][Deaths]++;
        }
        else
        {
            
ShowPlayerStats(playeridplayer1);
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_MESSAGE_RED"* Sorry, Player Not Connected!");
    }
    return 
1;

I hope this will be helpful
Thank you but I got this little Error Message

Код:
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1502) : warning 235: public function lacks forward declaration (symbol "ShowStats")
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1505) : error 017: undefined symbol "GetPlayerNameEx"
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1507) : error 017: undefined symbol "player1"
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1528) : error 004: function "ShowPlayerStats" is not implemented
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1514) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: /stats (DIALOG) - haikalbintang - 06.02.2017

Quote:
Originally Posted by AwokenNeoX
Посмотреть сообщение
Thank you but I got this little Error Message

Код:
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1502) : warning 235: public function lacks forward declaration (symbol "ShowStats")
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1505) : error 017: undefined symbol "GetPlayerNameEx"
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1507) : error 017: undefined symbol "player1"
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1528) : error 004: function "ShowPlayerStats" is not implemented
C:\Users\Kerem\ii\SERVER\LuxAdmin.pwn(1514) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Oops sorry, change to this xD :

PHP код:
#define DIALOG_STATS 9999 
forward ShowPlayerStats(playeridtargetid); 
public 
ShowPlayerStats(playeridtargetid

    new 
string[512], tmp[512], hms
    
format(tmpsizeof(tmp), "|-  %s's Statistics -|\n\n"PlayerName2(targetid)); 
    
strcat(stringtmp); 
    
format(tmpsizeof(tmp), "Kills: [%d]\nDeaths: [%d]\nRatio: [%0.2f]\nMoney: [$%d]\nTime: [%d] hrs [%d] mins [%d] secs"AccInfo[targetid][Kills], AccInfo[targetid][Deaths], Float:AccInfo[targetid][Kills]/Float:pDeaths,GetPlayerMoney(targetid), hms); 
    
strcat(stringtmp); 
    
ShowPlayerDialog(playeridDIALOG_STATSDIALOG_STYLE_MSGBOX"- Stats -"string"OK"""); 
    return 
1

dcmd_stats(playeridparams[]) 

    new 
player1
    if(!
strlen(params)) player1 playerid
    else 
player1 strval(params); 
    if(
IsPlayerConnected(player1)) 
    { 
        if(
AccInfo[player1][Deaths] == 0)  
        {     
            
AccInfo[player1][Deaths]++; 
        } 
        else 
        { 
            
ShowPlayerStats(playeridplayer1); 
        } 
    } 
    else 
    { 
        
SendClientMessage(playeridCOLOR_MESSAGE_RED"* Sorry, Player Not Connected!"); 
    } 
    return 
1