Joriku
Working in the mines, need something?
Hi,
so. I've been having a hard time to know what do use here..
Here comes a simple not done script that I am trying to write, I hope my notes tells enough.
So, this is what I am trying to do.
Here's the rebirth part. It rebirths the player, gives x1 point of the skillpoint into it's storage.
Here comes the npc.
I am trying to make it give 2% maxHealth onto the player if skillpoint is greater then 1 inside the storage. But I got a little stuck on what to use and how..
so. I've been having a hard time to know what do use here..
Here comes a simple not done script that I am trying to write, I hope my notes tells enough.
So, this is what I am trying to do.
Here's the rebirth part. It rebirths the player, gives x1 point of the skillpoint into it's storage.
Lua:
player:setStorageValue(85988, storage == -1 and 1 or storage + 1)
player:setStorageValue(23000, storage == -1 and 1 or storage + 1)
db.query('UPDATE players SET rebirths=rebirths+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
db.query('UPDATE players SET skillpoint=skillpoint+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
Here comes the npc.
I am trying to make it give 2% maxHealth onto the player if skillpoint is greater then 1 inside the storage. But I got a little stuck on what to use and how..
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local cost = 1 -- here we take the point
local config = {
["points"] = {storage = 23000, 1}, -- Storage for the added points, goes onto database as "skillpoint" under players
["health"] = {storage = 23001}, -- Storage for health, taking 1 point and adding 2% more max health
["mana"] = {storage = 23002}, -- Storage for mana, taking 1 point and adding 2% more max mana
["reset"] = {storage = 23003}, -- Storage for reset, this resets all bonuses and restores the users earned skill points
}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'health')) then
selfSay('When you rebirth, you can spend your skill points on rewards. One of them being more health.', cid)
selfSay('Are you sure you want to spend your point on 2% more maxHealth?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerStorageValue(cid, 23000) => 1 then
db.query('UPDATE players SET healthmax=healthmax+'.. 2 ..' WHERE id='..getPlayerGUID(cid)) -- Set player's maxhp with + 2%
doSendMagicEffect(getCreaturePosition(cid), 28) -- Send magiceffect ones it goes through
return true
end
else if getPlayerStorageValue(cid, 23000) < 1 then
selfSay('I am sorry bud, you got no skillpoints.', cid) -- cancel message
return true
end
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
npcHandler:addModule(FocusModule:new())
Last edited: