_Aion_
Nothing Else
Hello, in my server i have one npc that change attribute points for mana or health, works perfectly, but have one problem...
how i put for player say "hi, energy all" or "hi, vitality all" and distribute all?
Because my players say "hi, vitality" and remove 200000 points, it's hard for distribute many times.
My script
Sorry for my bad english, i'm brazilian.
how i put for player say "hi, energy all" or "hi, vitality all" and distribute all?
Because my players say "hi, vitality" and remove 200000 points, it's hard for distribute many times.
My script
local focuses = {}
local function isFocused(cid)
for i, v in pairs(focuses) do
if(v == cid) then
return true
end
end
return false
end
local function addFocus(cid)
if(not isFocused(cid)) then
table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
if(v == cid) then
table.remove(focuses, i)
break
end
end
end
local function lookAtFocus()
for i, v in pairs(focuses) do
if(isPlayer(v) == TRUE) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
removeFocus(cid)
if(isPlayer(cid) == TRUE) then --Be sure he's online
closeShopWindow(cid)
end
end
end
function onCreatureSay(cid, type, msg)
local Vitality =
{ [1] = {name = 'Sorcerer', cost = 100000, amount = 100000}, ---[1] = Vocation, Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxHp Added
[2] = {name = 'Druid', cost = 100000, amount = 100000},
[3] = {name = 'Paladin', cost = 100000, amount = 200000},
[4] = {name = 'Knight', cost = 100000, amount = 200000},
[5] = {name = 'Master Sorcerer', cost = 100000, amount = 100000},
[6] = {name = 'Elder Druid', cost = 100000, amount = 100000},
[7] = {name = 'Royal Paladin', cost = 100000, amount = 200000},
[8] = {name = 'Elite Knight', cost = 100000, amount = 200000},
[9] = {name = 'Illusionist Mage', cost = 100000, amount = 200000},
[10] = {name = 'Elemental Master', cost = 100000, amount = 200000},
[11] = {name = 'Sniper', cost = 100000, amount = 300000},
[12] = {name = 'Blade Master', cost = 100000, amount = 300000},
}
local Energy =
{ [1] = {name = 'Sorcerer', cost = 100000, amount = 200000}, ---[1] = Vocation, Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxMana Added
[2] = {name = 'Druid', cost = 100000, amount = 200000},
[3] = {name = 'Paladin', cost = 100000, amount = 200000},
[4] = {name = 'Knight', cost = 100000, amount = 100000},
[5] = {name = 'Master Sorcerer', cost = 100000, amount = 200000},
[6] = {name = 'Elder Druid', cost = 100000, amount = 200000},
[7] = {name = 'Royal Paladin', cost = 100000, amount = 200000},
[8] = {name = 'Elite Knight', cost = 100000, amount = 100000},
[9] = {name = 'Illusionist Mage', cost = 100000, amount = 300000},
[10] = {name = 'Elemental Master', cost = 100000, amount = 300000},
[11] = {name = 'Sniper', cost = 100000, amount = 200000},
[12] = {name = 'Blade Master', cost = 100000, amount = 200000},
}
if((msg == "hi") and not (isFocused(cid))) then
selfSay("Ola "..getCreatureName(cid)..", Quer aprender sobre {Attribute Points}? Voce possui "..doPlayerCheckAttributePoint(cid).." attribute points.", cid)
addFocus(cid)
talk_state = 1
elseif((isFocused(cid)) and (msg == "Attribute Points" or msg == "attribute points" or msg == "help" or msg == "job" or msg == "attribute point" or msg == "attribute points")) and talk_state == 1 then
selfSay("Quando voce ganha levels, voce ganha attribute points. Voce pode gastar seus pontos em {vitality} ou {energy} para melhorar seu char.", cid)
elseif((isFocused(cid)) and (msg == "energy")) and talk_state == 1 then
selfSay("Como um "..(Energy[getPlayerVocation(cid)].name).." voce pode aumentar sua {energy} em "..(Energy[getPlayerVocation(cid)].amount)..". Vai custar "..(Energy[getPlayerVocation(cid)].cost).." attribute points.", cid)
selfSay("Voce quer gastar seus attribute points em energy?", cid)
talk_state = 2
elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 2 then
if doPlayerCheckAttributePoint(cid) >= Energy[getPlayerVocation(cid)].amount then
local maxmana = getCreatureMaxMana(cid)
setCreatureMaxMana(cid, (maxmana+Energy[getPlayerVocation(cid)].amount))
local mana = (getCreatureMaxMana(cid)-getCreatureMana(cid))
doCreatureAddMana(cid, mana)
doPlayerAddAttributePoint(cid, (Energy[getPlayerVocation(cid)].cost))
selfSay("Sua energy foi aumentada em "..(Energy[getPlayerVocation(cid)].amount).."!", cid)
selfSay("Ate mais, volte sempre!", cid)
talk_state = 0
removeFocus(cid)
else
selfSay("Voce nao tem attribute points suficientes!", cid)
selfSay("Vai upar e volte depois.", cid)
talk_state = 0
removeFocus(cid)
end
elseif((isFocused(cid)) and (msg == "vitality")) and talk_state == 1 then
selfSay("Como um "..(Vitality[getPlayerVocation(cid)].name).." voce pode aumentar sua {vitality} em "..(Vitality[getPlayerVocation(cid)].amount)..". Vai custar "..(Vitality[getPlayerVocation(cid)].cost).." attribute points.", cid)
selfSay("Voce quer gastar seus pontos em vitality?", cid)
talk_state = 3
elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 3 then
if doPlayerCheckAttributePoint(cid) >= Vitality[getPlayerVocation(cid)].cost then
local maxhp = getCreatureMaxHealth(cid)
setCreatureMaxHealth(cid, (maxhp+Vitality[getPlayerVocation(cid)].amount))
local health = (getCreatureMaxHealth(cid)-getCreatureHealth(cid))
doCreatureAddHealth(cid, health)
doPlayerAddAttributePoint(cid, (Vitality[getPlayerVocation(cid)].cost))
selfSay("Sua vitality foi aumentada em "..(Vitality[getPlayerVocation(cid)].amount).."!", cid)
selfSay("Ate mais, volte sempre!", cid)
talk_state = 0
removeFocus(cid)
else
selfSay("Voce nao tem attribute points suficientes!", cid)
selfSay("Vai upar e volte depois.", cid)
talk_state = 0
removeFocus(cid)
end
elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
selfSay("Ate mais!", cid, TRUE)
closeShopWindow(cid)
removeFocus(cid)
end
end
function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
selfSay("Afff!")
closeShopWindow(cid)
removeFocus(cid)
end
end
function onPlayerEndTrade(cid)
selfSay("Foi um prazer fazer negocios com voce.", cid)
end
local function isFocused(cid)
for i, v in pairs(focuses) do
if(v == cid) then
return true
end
end
return false
end
local function addFocus(cid)
if(not isFocused(cid)) then
table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
if(v == cid) then
table.remove(focuses, i)
break
end
end
end
local function lookAtFocus()
for i, v in pairs(focuses) do
if(isPlayer(v) == TRUE) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
removeFocus(cid)
if(isPlayer(cid) == TRUE) then --Be sure he's online
closeShopWindow(cid)
end
end
end
function onCreatureSay(cid, type, msg)
local Vitality =
{ [1] = {name = 'Sorcerer', cost = 100000, amount = 100000}, ---[1] = Vocation, Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxHp Added
[2] = {name = 'Druid', cost = 100000, amount = 100000},
[3] = {name = 'Paladin', cost = 100000, amount = 200000},
[4] = {name = 'Knight', cost = 100000, amount = 200000},
[5] = {name = 'Master Sorcerer', cost = 100000, amount = 100000},
[6] = {name = 'Elder Druid', cost = 100000, amount = 100000},
[7] = {name = 'Royal Paladin', cost = 100000, amount = 200000},
[8] = {name = 'Elite Knight', cost = 100000, amount = 200000},
[9] = {name = 'Illusionist Mage', cost = 100000, amount = 200000},
[10] = {name = 'Elemental Master', cost = 100000, amount = 200000},
[11] = {name = 'Sniper', cost = 100000, amount = 300000},
[12] = {name = 'Blade Master', cost = 100000, amount = 300000},
}
local Energy =
{ [1] = {name = 'Sorcerer', cost = 100000, amount = 200000}, ---[1] = Vocation, Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxMana Added
[2] = {name = 'Druid', cost = 100000, amount = 200000},
[3] = {name = 'Paladin', cost = 100000, amount = 200000},
[4] = {name = 'Knight', cost = 100000, amount = 100000},
[5] = {name = 'Master Sorcerer', cost = 100000, amount = 200000},
[6] = {name = 'Elder Druid', cost = 100000, amount = 200000},
[7] = {name = 'Royal Paladin', cost = 100000, amount = 200000},
[8] = {name = 'Elite Knight', cost = 100000, amount = 100000},
[9] = {name = 'Illusionist Mage', cost = 100000, amount = 300000},
[10] = {name = 'Elemental Master', cost = 100000, amount = 300000},
[11] = {name = 'Sniper', cost = 100000, amount = 200000},
[12] = {name = 'Blade Master', cost = 100000, amount = 200000},
}
if((msg == "hi") and not (isFocused(cid))) then
selfSay("Ola "..getCreatureName(cid)..", Quer aprender sobre {Attribute Points}? Voce possui "..doPlayerCheckAttributePoint(cid).." attribute points.", cid)
addFocus(cid)
talk_state = 1
elseif((isFocused(cid)) and (msg == "Attribute Points" or msg == "attribute points" or msg == "help" or msg == "job" or msg == "attribute point" or msg == "attribute points")) and talk_state == 1 then
selfSay("Quando voce ganha levels, voce ganha attribute points. Voce pode gastar seus pontos em {vitality} ou {energy} para melhorar seu char.", cid)
elseif((isFocused(cid)) and (msg == "energy")) and talk_state == 1 then
selfSay("Como um "..(Energy[getPlayerVocation(cid)].name).." voce pode aumentar sua {energy} em "..(Energy[getPlayerVocation(cid)].amount)..". Vai custar "..(Energy[getPlayerVocation(cid)].cost).." attribute points.", cid)
selfSay("Voce quer gastar seus attribute points em energy?", cid)
talk_state = 2
elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 2 then
if doPlayerCheckAttributePoint(cid) >= Energy[getPlayerVocation(cid)].amount then
local maxmana = getCreatureMaxMana(cid)
setCreatureMaxMana(cid, (maxmana+Energy[getPlayerVocation(cid)].amount))
local mana = (getCreatureMaxMana(cid)-getCreatureMana(cid))
doCreatureAddMana(cid, mana)
doPlayerAddAttributePoint(cid, (Energy[getPlayerVocation(cid)].cost))
selfSay("Sua energy foi aumentada em "..(Energy[getPlayerVocation(cid)].amount).."!", cid)
selfSay("Ate mais, volte sempre!", cid)
talk_state = 0
removeFocus(cid)
else
selfSay("Voce nao tem attribute points suficientes!", cid)
selfSay("Vai upar e volte depois.", cid)
talk_state = 0
removeFocus(cid)
end
elseif((isFocused(cid)) and (msg == "vitality")) and talk_state == 1 then
selfSay("Como um "..(Vitality[getPlayerVocation(cid)].name).." voce pode aumentar sua {vitality} em "..(Vitality[getPlayerVocation(cid)].amount)..". Vai custar "..(Vitality[getPlayerVocation(cid)].cost).." attribute points.", cid)
selfSay("Voce quer gastar seus pontos em vitality?", cid)
talk_state = 3
elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 3 then
if doPlayerCheckAttributePoint(cid) >= Vitality[getPlayerVocation(cid)].cost then
local maxhp = getCreatureMaxHealth(cid)
setCreatureMaxHealth(cid, (maxhp+Vitality[getPlayerVocation(cid)].amount))
local health = (getCreatureMaxHealth(cid)-getCreatureHealth(cid))
doCreatureAddHealth(cid, health)
doPlayerAddAttributePoint(cid, (Vitality[getPlayerVocation(cid)].cost))
selfSay("Sua vitality foi aumentada em "..(Vitality[getPlayerVocation(cid)].amount).."!", cid)
selfSay("Ate mais, volte sempre!", cid)
talk_state = 0
removeFocus(cid)
else
selfSay("Voce nao tem attribute points suficientes!", cid)
selfSay("Vai upar e volte depois.", cid)
talk_state = 0
removeFocus(cid)
end
elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
selfSay("Ate mais!", cid, TRUE)
closeShopWindow(cid)
removeFocus(cid)
end
end
function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
selfSay("Afff!")
closeShopWindow(cid)
removeFocus(cid)
end
end
function onPlayerEndTrade(cid)
selfSay("Foi um prazer fazer negocios com voce.", cid)
end
Sorry for my bad english, i'm brazilian.