Raised This Month: $ Target: $400
 0% 

Help this code right?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Toallin
Junior Member
Join Date: Jun 2014
Old 06-22-2014 , 22:28   Help this code right?
Reply With Quote #1

PHP Code:
public ShowHud(taskid)
{
    new 
id taskid-TASK_HUD
    
    
if(!is_user_alive(id)) return;
        
    new 
iTime[9]
    
get_time("%H:%M"iTimecharsmax(iTime))
    new 
Hora str_to_num(iTime)

        
set_hudmessage(01282550.010.2206.00.9)
    
ShowSyncHudMsg(idHud"Time: %s %s"iTimeHora >= 00 && Hora 12 "AM" "PM")

Toallin is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-22-2014 , 22:40   Re: Help this code right?
Reply With Quote #2

Have you tested it yet?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 06-22-2014 at 22:40.
YamiKaitou is offline
Toallin
Junior Member
Join Date: Jun 2014
Old 06-23-2014 , 00:11   Re: Help this code right?
Reply With Quote #3

If I tried I get the PM time but I have not proven if I miss AM wondering why if it was okay if I fix an error.
Toallin is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-23-2014 , 00:41   Re: Help this code right?
Reply With Quote #4

iTime does not contain just the hour, it also contains the minutes. str_to_num should only be used when the only thing the string contains only numbers.

To better help you, look at http://www.cplusplus.com/reference/ctime/strftime/ to see what you can format using get_time
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Toallin
Junior Member
Join Date: Jun 2014
Old 06-23-2014 , 20:48   Re: Help this code right?
Reply With Quote #5

and this would otherwise?

PHP Code:
public ShowHud(taskid

    new 
id taskid-TASK_HUD 
     
    
if(!is_user_alive(id)) return; 
         
    new 
iHours[3], iMinutes[3]
    
get_time("%H"iHourscharsmax(iHours)) 
    
get_time("%M"iMinutescharsmax(iMinutes))
    new 
Hora str_to_num(iTime

        
set_hudmessage(01282550.010.2206.00.9
    
ShowSyncHudMsg(idHud"Time: %s:%s %s"iHoursiMinutesHora >= 00 && Hora 12 "AM" "PM"


Last edited by Toallin; 06-23-2014 at 20:50.
Toallin is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2014 , 22:22   Re: Help this code right?
Reply With Quote #6

Quote:
Originally Posted by Toallin View Post
and this would otherwise?

PHP Code:
public ShowHud(taskid

    new 
id taskid-TASK_HUD 
     
    
if(!is_user_alive(id)) return; 
         
    new 
iHours[3], iMinutes[3]
    
get_time("%H"iHourscharsmax(iHours)) 
    
get_time("%M"iMinutescharsmax(iMinutes))
    new 
Hora str_to_num(iTime

        
set_hudmessage(01282550.010.2206.00.9
    
ShowSyncHudMsg(idHud"Time: %s:%s %s"iHoursiMinutesHora >= 00 && Hora 12 "AM" "PM"

What happens when you test it?
__________________
fysiks is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-24-2014 , 01:11   Re: Help this code right?
Reply With Quote #7

Code:
get_time("%I:%M %p", iTime, charsmax(iTime))
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou 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 21:09.


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