Raised This Month: $ Target: $400
 0% 

PlayTime Display


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stylaa
Senior Member
Join Date: Oct 2009
Location: Flensburg, Germany
Old 10-11-2010 , 19:46   PlayTime Display
Reply With Quote #1

So i store the Secounds a User was on my Server in a mysql datebase

and if he writes

/playtime

it should display

You already spend 1 Hour 1 Minute and 1 Secound on this Server!

if have a code like this but it doesnt work
( secounds[id] = Secounds the User was on my Server from mysql db )

PHP Code:

public displaytime(id)
{

    new 
hours alltimesecs 3600
        
    
new tmp hours 3600
    
new mins alltimesecs tmp 60
        
    
new tmp2 mins 60
    
new secs alltimesecs tmp tmp2
        
    ColorChat
(idRED"%s Du warst bereits %s Stunden %s Minuten und %s Sekunden auf unserem Server",PREFIXhoursminssecs)


__________________

Some People brings Happynes by Coming
Some by Going
Stylaa is offline
Send a message via ICQ to Stylaa
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 10-11-2010 , 20:13   Re: PlayTime Display
Reply With Quote #2

Code:
public displaytime(id)
{

    new hours = (secounds[id] - (secounds[id] % 3600)) / 3600
    
    new temp = hours * 3600

    new mins = hours * 60

    new temp2 = mins * 60
        
    new seconds = secounds[id] - temp - temp2
    
    ColorChat(id, RED, "%s Du warst bereits %i Stunden %i Minuten und %i Sekunden auf unserem Server",PREFIX, hours, mins, seconds)

}
You say secounds[id] holds the current players play time, yet you never use it in that code, you use alltimesecs instead? I put secounds[id] to replace those. If it's really saved in alltimesecs, then go ahead and change them.

Also: You used %s for the integers, while it should've been %i.

%s = string
%i = integer
%f = float


See more here:http://www.cplusplus.com/reference/c...cstdio/printf/
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 10-11-2010 at 20:15.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Stylaa
Senior Member
Join Date: Oct 2009
Location: Flensburg, Germany
Old 10-11-2010 , 21:05   Re: PlayTime Display
Reply With Quote #3

Thanks found my mistake

My Code works now

PHP Code:

public displaytime(id)
{
 
    new 
hours = (secounds[id] - (secounds[id] % 3600)) / 3600
    
new mins = (secounds[id] - (hours*3600)) / 60
    
new seconds = (secounds[id] - (hours*3600) - (mins*60))
    
    
ColorChat(idRED"%s You spend already %i Hours %i Minutes und %i Secounds on our Server",PREFIXhoursminsseconds)


__________________

Some People brings Happynes by Coming
Some by Going
Stylaa is offline
Send a message via ICQ to Stylaa
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-12-2010 , 01:21   Re: PlayTime Display
Reply With Quote #4

Here is a much simpler conversion from seconds to hours minutes seconds:

PHP Code:
    new total secounds[id]
    new 
hours total 3600
    
new minutes total 3600 60
    
new seconds total 60 
Also, here is an example of formating it as HH:MM:SS,

PHP Code:
    server_print("%02d:%02d:%02d"hoursminutesseconds
__________________
fysiks is offline
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

Forum Jump


All times are GMT -4. The time now is 10:18.


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