• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

how obtain integers numbers in my operation? HELP PHX add +rep

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
586
Solutions
1
Reaction score
58
how obtain integers numbers in my operation?

on console:

17:51 VIP OUTFIT TIME: 58.251388888889 Hours.

script:
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "VIP OUTFIT TIME: " ..(exhaustion.get(cid, storage) / (3600)).." Hours. ")

i want show just like that:

17:51 VIP OUTFIT TIME: 58 Hours.
 
Last edited:
Not sure If there is output manipulation in lua or not.. try just using math.floor((exhaustion.get(cid, storage) / (3600)))

that will round the number down to 58 or whatever it happens to be

math.ceil to round up

If you want actual rounding do something like math.floor((exhaustion.get(cid, storage) / (3600)) + 0.5)


Edit:

String manipulation
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("Vip OUTFIT TIME: %d Hours", (exhaustion.get(cid, storage) / (3600)) ) )
which would read 17:51 VIP OUTFIT TIME: 58 Hours.

Or maybe nicer in your case:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("Vip OUTFIT TIME: %.1f Hours", (exhaustion.get(cid, storage) / (3600)) ) )
which would read 17:51 VIP OUTFIT TIME: 58.3 Hours.
 
Last edited:
thx bro. can convert hours and minutes?


doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("Vip OUTFIT TIME: %d Hours", (86340) / (3600)) ) )

VIP OUTFIT TIME: 23 Hours 59 minutes.

- - - Updated - - -

i add +rep
 
Last edited:
time = exhaustion.get(cid, storage)
hours = math.floor(time)
minutes = math.floor((math.floor(time*100) - hours*100) * 0.6)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("Vip OUTFIT TIME: %d Hours %d minutes",hours,minutes) ) )
 
i remove one ) and send this
data/lib/034-exhaustion.lua:17: attempt to compare number with boolean
unexpected symbol near ')'
 
time = exhaustion.get(cid, storage)
hours = math.floor(time)
minutes = math.floor((math.floor(time*100) - hours*100) * 0.6)

message = string.format("Vip OUTFIT TIME: %d Hours %d minutes",hours,minutes)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, message )
 
Working 100% :D thanks bro! have others post for i add +rep? XD

19:46 Vip OUTFIT TIME: 71 Hours 20 minutes
19:47 Vip OUTFIT TIME: 71 Hours 19 minutes
 
Back
Top