Raised This Month: $ Target: $400
 0% 

Converting a single digit string (seconds) into (hours:minutes:seconds)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
HappyTreeElf
New Member
Join Date: Jul 2020
Old 07-09-2020 , 22:23   Converting a single digit string (seconds) into (hours:minutes:seconds)
Reply With Quote #1

===
I messed the title up. It's clearly not a single digit string. It should read "number that's a string" I apologize
===

I've been struggling with this for hours now and I've officially ran out of ideas

I have a database query:

Code:
dbi_result(resultMaps, "time", qryTime, 31)
The "time" is an entry for "seconds". I believe this is returing a string and storing it in the qryTime variable.

Underneath that I have a line (cut it down for the purposes of this this thread) that sends it to the client in-game with the format:

Code:
"%s", qryTime
In game this works perfectly fine, but it only tracks it in seconds. I would like it to print hours:minutes:seconds in the game.

I tried to create a function for this. The aim of this function is to pass "qryTime" into the parameter so it looks like this

Code:
"%s", convertTime(qryTime)
Here is my function

Code:
public convertTime(runTimeInSeconds[32]) {	
	new convertedTime[32]
	new Float:finishTime = str_to_float(runTimeInSeconds[31])	
	new nHours = (floatround(Float:finishTime) / 3600) % 24
	new nMinutes = (floatround(Float:finishTime) / 60) % 60 
	new nSeconds = floatround(Float:finishTime) % 60	
	convertedTime[31] = ("%i:%i:%i", nHours, nMinutes, nSeconds)
	return convertedTime
}
I'm clearly doing something wrong here I can't even get my plug-in to compile now. It's saying "nMinutes" and "nHours" are not being used. Even if it does compile I have a suspicion it's not even going to work the way I want.

Last edited by HappyTreeElf; 07-09-2020 at 22:26.
HappyTreeElf is offline
 



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 17:02.


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