Raised This Month: $51 Target: $400
 12% 

Solved Help with mostactive


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 06-25-2018 , 17:26   Help with mostactive
Reply With Quote #1

I tryed to make a chat message at sm_hours command

PHP Code:
public void OnPluginStart()
{
    
RegConsoleCmd("sm_hours"ChatHours);  // change the default commands
    
RegConsoleCmd("sm_menuhours"DOMenu);
}

public 
Action ChatHours(int clientint args)
{
    
char sName[CENTER][/CENTER][32];
    
GetClientName(clientsNamesizeof(sName));
    
    
PrintToChatAll("%s Got%i h as CT, %i h as TERO, %i h as SPEC!"sNameg_iPlayTimeCTg_iPlayTimeTg_iPlayTimeSpec);

In chat it looks like this:
Code:
 KRATOS ★  Got 0 h as CT, 0 h as TERO, 0 h as SPEC!
But in menu I have 17 hours. What I did wrong?

Plugin I try to edit >> MOSTACTIVE

Last edited by kratoss1812; 06-26-2018 at 06:26.
kratoss1812 is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 06-25-2018 , 17:40   Re: Help with mostactive
Reply With Quote #2

Instead editing mostactive, I suggest to make a new one using it's natives

Btw:
I think in your code these
PHP Code:
[CENTER][/CENTER
while declaring the char array aren't actually present

other than that those vars are array of ints so you should write something like:
PHP Code:
PrintToChatAll("%s Got%i h as CT, %i h as TERO, %i h as SPEC!"sNameg_iPlayTimeCT[client], g_iPlayTimeT[client], g_iPlayTimeSpec[client]); 
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 06-25-2018 at 17:40.
Papero is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 06-25-2018 , 17:42   Re: Help with mostactive
Reply With Quote #3

Quote:
Originally Posted by Papero View Post
Instead editing mostactive, I suggest to make a new one using it's natives

Btw:
I think in your code these
PHP Code:
[CENTER][/CENTER
while declaring the char array aren't actually present

other than that those vars are array of ints so you should write something like:
PHP Code:
PrintToChatAll("%s Got%i h as CT, %i h as TERO, %i h as SPEC!"sNameg_iPlayTimeCT[client], g_iPlayTimeT[client], g_iPlayTimeSpec[client]); 
I will try, thank you!
kratoss1812 is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 06-26-2018 , 03:58   Re: Help with mostactive
Reply With Quote #4

Quote:
Originally Posted by Papero View Post
Instead editing mostactive, I suggest to make a new one using it's natives

Btw:
I think in your code these
PHP Code:
[CENTER][/CENTER
while declaring the char array aren't actually present

other than that those vars are array of ints so you should write something like:
PHP Code:
PrintToChatAll("%s Got%i h as CT, %i h as TERO, %i h as SPEC!"sNameg_iPlayTimeCT[client], g_iPlayTimeT[client], g_iPlayTimeSpec[client]); 


So.. that was a fix, but now, the time is displayed in seconds and not in minutes or hours.. How can I fix it?

In game:
Code:
 Kratos Got 25607 h as CT, 18512 h as TERO, 2564 h as SPEC!
kratoss1812 is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 06-26-2018 , 04:37   Re: Help with mostactive
Reply With Quote #5

Just dividing it to 3600 would do the trick
__________________
ambn is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 06-26-2018 , 06:05   Re: Help with mostactive
Reply With Quote #6

Quote:
Originally Posted by ambn View Post
Just dividing it to 3600 would do the trick

Code:
	int iHoursSec = 3600;
	int iHoursCT = float(g_iPlayTimeCT[client]) / float(iHoursSec);
like this?
kratoss1812 is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 06-26-2018 , 06:25   Re: Help with mostactive
Reply With Quote #7

thank you all guys!
PHP Code:
public Action ChatHours(int clientint args)
{
    
char sName[32];
    
GetClientName(clientsNamesizeof(sName));
    
    
int iHoursSec 3600;
    
    
float iHoursCT float(g_iPlayTimeCT[client])/float(iHoursSec);
    
float iHoursTR float(g_iPlayTimeT[client])/float(iHoursSec);
    
float iHoursSPEC float(g_iPlayTimeSpec[client])/float(iHoursSec);
    
    
char sHoursCT[128];
    
char sHoursTR[128];
    
char sHoursSPEC[128];    
    
    
FloatToString(iHoursCTsHoursCTsizeof(sHoursCT));
    
FloatToString(iHoursSPECsHoursSPECsizeof(sHoursSPEC));
    
FloatToString(iHoursTRsHoursTRsizeof(sHoursTR));
    
    
PrintToChatAll("\x0c %s\x04  Got \x03 %s \x04  h as CT, \x03 %s \x04 h as TERO, \x03 %s \x04 h as SPEC!"sNamesHoursCTsHoursTRsHoursSPEC);

in game it's like
Code:
kRatos Got 15,7943 h as ct
kratoss1812 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 15:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode