Converting a single digit string (seconds) into (hours:minutes:seconds)
===
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)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", qryTimeI 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)Code:
public convertTime(runTimeInSeconds[32]) { |
Re: Converting a single digit string (seconds) into (hours:minutes:seconds)
It looks like you should look into studying how to use strings in this language because everything you've done with the string variables in that code is incorrect. One thing that isn't usually mentioned is that you should never return a string from a function in an AMX Mod X plugin. "output" string should be passed as an argument with an accompanying length input (strings are always passed by reference into functions). Take a look at other [working] plugins that use strings that are passed into and out of functions.
For the math part, you can use the following code to get hours, minutes, and seconds. Make sure that you you convert your string (which contains a number of seconds) with str_to_num() so iSeconds = str_to_num(szMyString). Quote:
Code:
new szSeconds[32], szSecondsFormatted[14] |
Re: Converting a single digit string (seconds) into (hours:minutes:seconds)
Thank you very much
|
| All times are GMT -4. The time now is 17:03. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.