• 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!

Lua Creaturescripts temperature bug.

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
595
Solutions
2
Reaction score
66
Location
México
Hello, otlanders. i have this script.
its a temperatura script, when u are underground, desert, etc your temperatura raises and start losing hitpoints over time (1000 msecs)
the bug: the event of damage (1hp/1s or 5hp/1s) is not working properly, it removes 1 hp or 5 hp like 10 times in 1 second.
(the event occurs 10 times or more in 1 second)

Im using TFS Rev 3777

LUA:
function onThink(cid, interval)
if isPlayer(cid) and getPlayerAccess(cid) == 0 and getPlayerStorageValue(cid, 4444470) <= 0 then

------------------------- CONFIG ----------------------
-- Como configurar: Modifique os numeros abaixo da direita para
-- determinar a temperatura da outfit...
outfit_temp = {
-- Female Outfits
[136] = 6, 
[137] = 5, 
[138] = 5, 
[139] = 6, 
[140] = 17, 
[141] = 6, 
[142] = 8, 
[147] = 11, 
[146] = 3, 
[148] = 6, 
[149] = 6, 
[150] = 3, 
[155] = 7, 
[156] = 2, 
[157] = 5, 
[158] = 3, 
[152] = 9,
[259] = 8,
[270] = 8,
[279] = 15,
[288] = 4,
[324] = 5,
[336] = 6,
[329] = 6,
[366] = 1,
-- Male Outfits
[128] = 6, 
[129] = 5, 
[130] = 5,
[131] = 6,
[132] = 17,
[133] = 6,
[134] = 8,
[143] = 11,
[144] = 6,
[145] = 6,
[151] = 8,
[152] = 7,
[153] = 5, 
[154] = 3, 
[251] = 25, 
[252] = 25, 
[268] = 9,
[273] = 8,
[278] = 14,
[279] = 15,
[289] = 4,
[325] = 5,
[335] = 6,
[328] = 6,
[367] = 1,
[266] = 1,
[7131] = 1,
[267] = 1,
[113] = 1,
[114] = 1,
[115] = 1,
}

temp_base = 25
min_dano = 1 -- Dano por temperatura um pouco alta/baixa
max_dano = 5 -- Dano por temperatura muito alta/baixa
delay = 1000 -- tempo em milissigundos dos danos
sub_config = 1 -- Ativar temperatura subterranea? ( 0 - Nao ) ( 1 - SIM )

-----------------------------FIM DAS CONFIG ------------------------
temp_local = getPlayerStorageValue(cid, 121314)
pos = getCreaturePosition(cid)

if temp_local == -1 then temp_local = 0 end
temp_user = (temp_base + temp_local + outfit_temp[getCreatureOutfit(cid).lookType])
if sub_config == 1 then
----------------------- Subterraneo -------------------------------
sub = { -11, -10, -8,-5 ,-3 ,-55 , [7] = 0, 55, 5, 7, 10, 12, 15, [6] = 0, 55, 5, 7, 10, 12, 15}
if pos.z ~= 7 then 
if pos.z ~= 6 then 
if pos.z ~= 5 then
if pos.z ~= 4 then 
if pos.z ~= 3 then
if pos.z ~= 2 then
if pos.z ~= 1 then
if pos.z ~= 0 then
temp_user = temp_user + sub[pos.z] 
end 
end
end 
end
end
end
end
end
end
-------------------------------------------------------------------
setPlayerStorageValue(cid, 12345, temp_user) 
if temp_user >= 40 and temp_user < 50  then
addEvent(Quente, delay, cid, min_dano)
elseif (getTilePzInfo(getPlayerPosition(cid)) == true) or (getPlayerVocation(cid) == 0) then
stopEvent(Quente,cid)
elseif temp_user >=50 then
addEvent(Quente, delay, cid, max_dano)
elseif (getTilePzInfo(getPlayerPosition(cid)) == true) or (getPlayerVocation(cid) == 0) then
stopEvent(Quente, delay, cid,max_dano)
else if temp_user <= 10 and temp_user > 0 then
addEvent(Frio, delay, cid, min_dano)
elseif (getTilePzInfo(getPlayerPosition(cid)) == true) or (getPlayerVocation(cid) == 0) then
stopEvent(Frio, delay, cid, min_dano)
elseif temp_user < 0 then
addEvent(Frio, delay, cid, max_dano)
elseif (getTilePzInfo(getPlayerPosition(cid)) == true) or (getPlayerVocation(cid) == 0) then
stopEvent(Frio, delay, cid, max_dano)
end
end
end 
end

function Quente(cid,dano,r)
if isPlayer(cid) and (getPlayerVocation(cid) >= 1) and (getTilePzInfo(getPlayerPosition(cid)) == false) then
if getPlayerStorageValue(cid, 444447806) == -1 then
doPlayerPopupFYI(cid, "[Tutorial]: Temperature!\
\
1-.You must protect yourself from weather.\
2-.Check your '!status' command.\
3-.Entering dungeons, deserts, jungle or icelands will change your temperature.\
\
Try to change your outfit!\
")
setPlayerStorageValue(cid, 444447806, 1)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "[Warning]: Temperature is "..getPlayerStorageValue(cid, 12345).." grades ")
doCreatureAddHealth(cid, -dano)
r = math.random(1,100)
if r <= 30 then
doCreateItem(2018, getCreaturePosition(cid))
end
end
end
function Frio(cid,dano)
if isPlayer(cid) and (getPlayerVocation(cid) > 1) and (getTilePzInfo(getPlayerPosition(cid)) == false)then
if getPlayerStorageValue(cid, 444447806) == -1 then
doPlayerPopupFYI(cid, "[Tutorial]: Temperature!\
\
1-.You must protect yourself from weather.\
2-.Check your '!status' command.\
3-.Entering dungeons, deserts, jungle or icelands will change your temperature.\
\
Try to change your outfit!\
")
setPlayerStorageValue(cid, 444447806, 1)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "[Warning]: Temperature is "..getPlayerStorageValue(cid, 12345).." grades ")
doCreatureAddHealth(cid, -dano)
return true
end
end
 
did you edit your tfs to have fast attack?
aka changing the number for creature check interval in the sources?
that's the only other explanation i see that would make onThink execute 10x per second.
 
did you edit your tfs to have fast attack?
aka changing the number for creature check interval in the sources?
that's the only other explanation i see that would make onThink execute 10x per second.
hmmm i dont changed stuff in source, to be sure, where can i found that intervals?
 
Back
Top