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

Lua Storage when level up-Npc Effects

cuba

New Member
Joined
Feb 24, 2015
Messages
136
Reaction score
2
Using Tfs 0.4 dev 8.6

~storage~
hello otlander how i make when player level up like when he get lvel 500 he get storage 2000
and in login if player get storage ===2000 player will get red skull after he login in 5 seconds


~Npc Effects~
how i make when i speak with npc and say word like start he will make effect in temple and if that effects shoot any players he will dei like fire storm
 
Depense, if he just needs parts and explanations to make something himself, it can be posted here.

You can create an advance script in creaturescripts, check for skill level so it doesn't happen with other skills and use newLevel to get the level.
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
     if skill == SKILL__LEVEL and newLevel == 500 then
         doCreatureSetStorage(cid, 2000, 1)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got some storage.")
     end
     return true
end

In login.lua you can add something that should happen when someone logs in and use addEvent to execute something after a certain time.
The function works like this.
Code:
addEvent(function name, time, parameters)
So it executes a function after a certain time.
So you can write a function that sets the skull (you can choose any name that is not used yet). Also check if cid is a player there incase the player logs out before the function is executed.
Code:
function doAddSkull(cid)
     if isPlayer(cid) then
          doCreatureSetSkullType(cid, SKULL_RED)
     end
end

So addEvent will look like this.
Code:
addEvent(doAddSkull, 5 * 1000, cid)

To check if storage is 1 you can use getCreatureStorage.
Code:
if getCreatureStorage(cid, 2000) == 1 then
Under that the addEvent line, since that should happen if the storagevalue of 2000 is 1.
And if statements need to be closed with end so write that under it.

You can find the Lua functions of your server in doc/LUA_FUNCTIONS and in luascript.cpp.
 
No i can't help support is for help. Not for requesting scripts.
This is what support thread says..
Code:
Encountered an issue related to OpenTibia? Ask for support here.
[Code/]
Edit: No hate mate i really like you! I am just saying this so your post wont get deleted. XD
 
Depense, if he just needs parts and explanations to make something himself, it can be posted here.

You can create an advance script in creaturescripts, check for skill level so it doesn't happen with other skills and use newLevel to get the level.
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
     if skill == SKILL__LEVEL and newLevel == 500 then
         doCreatureSetStorage(cid, 2000, 1)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got some storage.")
     end
     return true
end

In login.lua you can add something that should happen when someone logs in and use addEvent to execute something after a certain time.
The function works like this.
Code:
addEvent(function name, time, parameters)
So it executes a function after a certain time.
So you can write a function that sets the skull (you can choose any name that is not used yet). Also check if cid is a player there incase the player logs out before the function is executed.
Code:
function doAddSkull(cid)
     if isPlayer(cid) then
          doCreatureSetSkullType(cid, SKULL_RED)
     end
end

So addEvent will look like this.
Code:
addEvent(doAddSkull, 5 * 1000, cid)

To check if storage is 1 you can use getCreatureStorage.
Code:
if getCreatureStorage(cid, 2000) == 1 then
Under that the addEvent line, since that should happen if the storagevalue of 2000 is 1.
And if statements need to be closed with end so write that under it.

You can find the Lua functions of your server in doc/LUA_FUNCTIONS and in luascript.cpp.
what about the NPC!
 
Back
Top