Paulix
Active Member
- Joined
- Sep 13, 2012
- Messages
- 129
- Solutions
- 7
- Reaction score
- 26
I'm trying to create a weapon to count how many attacks per second the player can deal using it, but since os.time() only return seconds, I dont know exactly what to do, can someone help me?
Idk the tfs version, but tibia version is 8.6, but im not new in proggraming, just a rude idea would help me a lot
Idk the tfs version, but tibia version is 8.6, but im not new in proggraming, just a rude idea would help me a lot
Lua:
function onUseWeapon(cid, var)
local avg = 0.000
local attime = os.time()
local oltime = getCreatureStorage(cid, 50033)
local hits = getCreatureStorage(cid, 50032)
if attime-oltime >= 3 then
doCreatureSetStorage(cid, 50033, attime)
doCreatureSetStorage(cid, 50032, 1)
end
if oltime == attime then
doCreatureSetStorage(cid, 50032, hits+1)
avg = hits/1
elseif oltime ~= attime then
avg = hits/1
doCreatureSetStorage(cid, 50033, attime)
doCreatureSetStorage(cid, 50032, 1)
end
doSendAnimatedText(getPlayerPosition(cid), ""..string.format("%.3f", avg), COLOR_RED)
doCombat(cid, combat, var)
return 1
end