Oioioi!
Here's a health/mana potion system (You use charges).
Information:
You have one mana potion in your backpack.
You buy 500 charges by typing: /charges 500
Now you can use your only mana potion and you will lose charges but the mana potion will stay.
If you don't have any charges left, you can't use the mana potion(ofcourse)
Each time you use a potion, it will send a message in the default channel: "You have 42 charges left"
When you're out of charges, it will say: "You don't have any charges left. To buy more charges type /charges |amount|"
First of all you have to delete your old mana/health potion scripts from your actions.xml.
Here we go...
actions/scripts/charges/mp
actions/scripts/charges/smp
actions/scripts/charges/gmp
actions/scripts/charges/hp
actions/scripts/charges/shp
actions/scripts/charges/ghp
actions/scripts/charges/uhp
actions/scripts/charges/gsp
data/talkactions/scripts/charges.lua
actions/actions.xml
talkactions/talkactions.xml
Here's a health/mana potion system (You use charges).
Information:
You have one mana potion in your backpack.
You buy 500 charges by typing: /charges 500
Now you can use your only mana potion and you will lose charges but the mana potion will stay.
If you don't have any charges left, you can't use the mana potion(ofcourse)
Each time you use a potion, it will send a message in the default channel: "You have 42 charges left"
When you're out of charges, it will say: "You don't have any charges left. To buy more charges type /charges |amount|"
First of all you have to delete your old mana/health potion scripts from your actions.xml.
Here we go...
actions/scripts/charges/mp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerStorageValue(cid, 19732) >= 1 then
doCreatureAddMana(item2.uid, math.random(130, 160))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
actions/scripts/charges/smp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6 or getPlayerVocation(cid) == 7 then
if getPlayerStorageValue(cid, 19732) >= 1 and getPlayerLevel(cid) >= 50 then
doCreatureAddMana(item2.uid, math.random(210, 390))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
actions/scripts/charges/gmp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6 then
if getPlayerStorageValue(cid, 19732) >= 1 and getPlayerLevel(cid) >= 80 then
doCreatureAddMana(item2.uid, math.random(600, 700))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
actions/scripts/charges/hp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerStorageValue(cid, 19732) >= 1 then
doCreatureAddHealth(item2.uid, math.random(100, 200))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
actions/scripts/charges/shp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 7 or getPlayerVocation(cid) == 8 then
if getPlayerStorageValue(cid, 19732) >= 1 and getPlayerLevel(cid) >= 50 then
doCreatureAddHealth(item2.uid, math.random(200, 400))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
actions/scripts/charges/ghp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
if getPlayerStorageValue(cid, 19732) >= 1 and getPlayerLevel(cid) >= 80 then
doCreatureAddHealth(item2.uid, math.random(500, 600))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
actions/scripts/charges/uhp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
if getPlayerStorageValue(cid, 19732) >= 1 and getPlayerLevel(cid) >= 130 then
doCreatureAddHealth(item2.uid, math.random(800, 900))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
actions/scripts/charges/gsp
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, frompos, item2, topos)
if(not isPlayer(item2.uid)) then
return false
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
if getPlayerStorageValue(cid, 19732) >= 1 and getPlayerLevel(cid) >= 80 then
doCreatureAddHealth(item2.uid, math.random(300, 400))
doCreatureAddMana(item2.uid, math.random(300, 400))
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)-1)
doPlayerSendTextMessage(cid, 19, "You have "..getPlayerStorageValue(cid, 19732).." charges left.")
doCreatureSay(item2.uid, "Aaaah...", TALKTYPE_ORANGE_1)
doAddCondition(cid, exhaust)
end
end
if getPlayerStorageValue(cid, 19732) <= 0 then
doPlayerSendTextMessage(cid, 19, "You don't have any charges left.")
doPlayerSendTextMessage(cid, 19, "Buy more charges by typing: /charges |amount|.")
end
end
data/talkactions/scripts/charges.lua
Lua:
function onSay(cid, words, param)
local maxcharges = 3000;
if param > 0 and getPlayerStorageValue(cid, 19732)+param <= maxcharges then
if getPlayerMoney(cid) >= param*100 then
if doPlayerRemoveMoney(cid, param*100) == TRUE then
doPlayerSendTextMessage(cid, 22, 'You bought '.. param ..' charges for '.. param*100 ..' gold!')
setPlayerStorageValue(cid, 19732, getPlayerStorageValue(cid, 19732)+param)
end
else
doPlayerSendTextMessage(cid, 22, 'You don\'t have enough money.')
end
else
doPlayerSendTextMessage(cid, 22, 'You can\'t have more than 3000 charges.')
end
return true
end
actions/actions.xml
PHP:
<action itemid="7620" event="script" value="charges/mp.lua" allowfaruse="1"/>
<action itemid="7589" event="script" value="charges/smp.lua" allowfaruse="1"/>
<action itemid="7590" event="script" value="charges/gmp.lua" allowfaruse="1"/>
<action itemid="7618" event="script" value="charges/hp.lua" allowfaruse="1"/>
<action itemid="7588" event="script" value="charges/shp.lua" allowfaruse="1"/>
<action itemid="7591" event="script" value="charges/ghp.lua" allowfaruse="1"/>
<action itemid="8473" event="script" value="charges/uhp.lua" allowfaruse="1"/>
<action itemid="8472" event="script" value="charges/gsp.lua" allowfaruse="1"/>
talkactions/talkactions.xml
PHP:
<talkaction words="/charges" script="charges.lua"/>
Last edited: