- OTS Fans http://www.otsfans.pun.pl/index.php - Actions http://www.otsfans.pun.pl/viewforum.php?id=112 - Zegarki pokazujące czas realny i tibijski http://www.otsfans.pun.pl/viewtopic.php?id=24 |
Xelemeleque - 2011-04-17 06:49:01 |
Autorem Jest TPlayer 1. Najpierw kod na czas realistyczny:
Kod:function onUse(cid, item, frompos, item2, topos) data = os.date('%c') doPlayerSendTextMessage(cid, 22, ""..data.."") end return 1 Na koniec otwieramy plik actions.xml w data/actions i dopisujemy to: Kod:<action itemid="2036" script="clock.lua" /> <action itemid="1728" script="clock.lua" /> <action itemid="1729" script="clock.lua" /> <action itemid="1730" script="clock.lua" /> <action itemid="1731" script="clock.lua" />
Kod:function onUse(cid, item, frompos, item2, topos) twentyfour = false tibiantime = true if (tibiantime == false) then if (twentyfour == true) then time = os.date('%H:%M') else time = os.date('%I:%M %p') end else time = rl2tib(os.date('%M'), os.date('%S'), twentyfour) end doPlayerSendTextMessage(cid, 22, "The time is "..time..".") return 1 end function rl2tib(min, sec, twentyfour) suffix = '' varh = (min*60+sec)/150 tibH = math.floor(varh) tibM = math.floor(60*(varh-tibH)) if (twentyfour == false) then if (tonumber(tibH) > 11) then tibH = tonumber(tibH) - 12 suffix = ' pm' else suffix = ' am' end if (tibH == 0) then tibH = 12 end end if (tibH < 10) then tibH = '0'..tibH end if (tibM < 10) then tibM = '0'..tibM end return (tibH..':'..tibM..suffix) end Na koniec otwieramy plik actions.xml w data/actions i dopisujemy to: Kod:<action itemid="2036" script="watch.lua" /> <action itemid="1728" script="watch.lua" /> <action itemid="1729" script="watch.lua" /> <action itemid="1730" script="watch.lua" /> <action itemid="1731" script="watch.lua" /> |