TalkAction "Eat" fire mushrooms, restore HP and Mana instantly.

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,040
Best answers
3
Reaction score
597
Location
Canada
Hey guys, me again. Decided to share another of my scripts that I made for my own pleasure. It's really quite basic, but as per usual, I've added notes to help newbie scripters :)

So basically this script makes it possible to say !mush (It is case-sensative, so don't use any capital letters) and it "eats"* a fire mushroom from your backpack or arrows slot or hand or anywhere in your inventory then adds 2500 hitpoints and mana points to your character. Obviously it's easy to change the words to something else, you can change the item used, and you can change the health and mana gained. You could even add soul points with the
Code:
doPlayerAddSoul(cid, soul)
function.
So in talkactions.xml, put
Code:
	<talkaction words="!mush" script="mush.lua"/>
This is where you can change the words from !mush to whatever you want.

Now in the scripts folder, make a file called "mush.lua" and paste this:
Code:
--Script with NewbieNotes made by RazorBlade--
function onSay(cid, words, param) --The function being used
	if getPlayerItemCount(cid,2795) >= 1 then --Checks for  1 or more fire mushrooms
		doPlayerRemoveItem(cid,2795,1) --Removes 1 fire mushroom from the player's total amount
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Yummy!") --Sends the message "Yummy!" to the player in green text.
		doCreatureAddHealth(cid, 2500) --Adds 2500 hitpoints to the player
		doPlayerAddMana(cid, 2500) --Adds 2500 mana points to the player
	else --If the system checks for something and doesn't get the set answer, it moves to the line following the word "else" and the function of the script may not occur.
		doPlayerSendCancel(cid, "You don't have any fire mushrooms.") --Sends a cancel message to the player.
	end --Ends the last function
end --Ends the second-last script
Any questions or concerns can be directed at meee.
*By "eats" I don't mean it actually eats the mushroom. It only seems like it. So don't use this to easily eat food ;) Won't help you :p
 

Taurus

Texass
Joined
Jan 11, 2009
Messages
615
Best answers
2
Reaction score
30
Location
United States
anyone know how to make this with like, an exhaust sort of feature

I would like this except they can use it as many as they have, it would be cool to set it where they can only use the item like this once every... 45 seconds, that way its no use in a pvp fight, but they can use to refill their drained mana.
 

QuaS

Cykotitan Pwned =/
Joined
Sep 11, 2008
Messages
833
Best answers
0
Reaction score
26
Location
Poland/ Wroclaw
is not easier to make onUse instead Talkaction?

@up Exhaust can be made by storage Value, since there is no exhaust type for talking (excluding mute)
 
OP
RazorBlade

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,040
Best answers
3
Reaction score
597
Location
Canada
is not easier to make onUse instead Talkaction?

@up Exhaust can be made by storage Value, since there is no exhaust type for talking (excluding mute)
If it was onUse, you wouldn't be able to eat it anymore. I want it to be normal food still. :3

anyone know how to make this with like, an exhaust sort of feature
Well it doesn't really have to be a fire mushroom. It could be an item you choose. Something more rare. That way they wouldn't be able to have like 1000. Maybe only 10, or 5.
 

Grehy

Killroy
Joined
Nov 21, 2008
Messages
2,628
Best answers
0
Reaction score
30
Location
United States
If it was onUse, you wouldn't be able to eat it anymore. I want it to be normal food still. :3
Wha-Wh - What? Just have it do the same thing it does normally within the script, so you can use it instead of having an unnecessary talkaction players won't know or remember
 
OP
RazorBlade

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,040
Best answers
3
Reaction score
597
Location
Canada
Wha-Wh - What? Just have it do the same thing it does normally within the script, so you can use it instead of having an unnecessary talkaction players won't know or remember
Well perhaps I like it like this. :eek: If you choose to make it like that, so be it. I made it the way I wanted it o:
 

Taurus

Texass
Joined
Jan 11, 2009
Messages
615
Best answers
2
Reaction score
30
Location
United States
Well, now i wasn't trying to incite trouble :p

I spose ur right about the rarity of an item, but still if they have 10 they could easily win a fight within a few seconds.

thanks anyway.
 

Syntax

Developer
Joined
Oct 10, 2007
Messages
2,838
Best answers
0
Reaction score
194
Location
Texas
Lua:
function onSay(cid, words, param)
	if doPlayerRemoveItem(cid,2795,1) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Yummy!")
		doCreatureAddHealth(cid, 2500)
		doPlayerAddMana(cid, 2500)
	else
		doPlayerSendCancel(cid, "You don't have any fire mushrooms.")
	end
end
shortened slightly.
 

tosuxo

Member
Joined
Jun 14, 2007
Messages
1,252
Best answers
0
Reaction score
21
this SHOULD add exhaust to the system:

Code:
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.


--Script with NewbieNotes made by RazorBlade--
function onSay(cid, words, param) --The function being used

if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 then

	if getPlayerItemCount(cid,2795) >= 1 then --Checks for  1 or more fire mushrooms
		doPlayerRemoveItem(cid,2795,1) --Removes 1 fire mushroom from the player's total amount
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Yummy!") --Sends the message "Yummy!" to the player in green text.
		doCreatureAddHealth(cid, 2500) --Adds 2500 hitpoints to the player
		doPlayerAddMana(cid, 2500) --Adds 2500 mana points to the player
	else --If the system checks for something and doesn't get the set answer, it moves to the line following the word "else" and the function of the script may not occur.
		doPlayerSendCancel(cid, "You don't have any fire mushrooms.") --Sends a cancel message to the player.
	end --Ends the last function
else
     doPlayerSendCancel(cid, "You cannot eat yet.")
end

-- Exhaustion system (Made by Alreth, bugfix by me)
-- DO NOT EDIT!
function exhaust(cid, STORE_VALUE, EXHAUST_TIME)
    
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, STORE_VALUE)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (EXHAUST_TIME == nil or EXHAUST_TIME < 0) then
        EXHAUST_TIME = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= EXHAUST_TIME) then
        setPlayerStorageValue(cid, STORE_VALUE, newExhaust) 
        return 1
    else
        return 0
    end
end
if there's any bugs please tell me and i'll check through it again

Edit: fixed a small silly bug, added too many ends ;)
 
OP
RazorBlade

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,040
Best answers
3
Reaction score
597
Location
Canada
this SHOULD add exhaust to the system:

Code:
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.


--Script with NewbieNotes made by RazorBlade--
function onSay(cid, words, param) --The function being used

if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 then

	if getPlayerItemCount(cid,2795) >= 1 then --Checks for  1 or more fire mushrooms
		doPlayerRemoveItem(cid,2795,1) --Removes 1 fire mushroom from the player's total amount
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Yummy!") --Sends the message "Yummy!" to the player in green text.
		doCreatureAddHealth(cid, 2500) --Adds 2500 hitpoints to the player
		doPlayerAddMana(cid, 2500) --Adds 2500 mana points to the player
	else --If the system checks for something and doesn't get the set answer, it moves to the line following the word "else" and the function of the script may not occur.
		doPlayerSendCancel(cid, "You don't have any fire mushrooms.") --Sends a cancel message to the player.
	end --Ends the last function
else
     doPlayerSendCancel(cid, "You cannot eat yet.")
end

-- Exhaustion system (Made by Alreth, bugfix by me)
-- DO NOT EDIT!
function exhaust(cid, STORE_VALUE, EXHAUST_TIME)
    
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, STORE_VALUE)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (EXHAUST_TIME == nil or EXHAUST_TIME < 0) then
        EXHAUST_TIME = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= EXHAUST_TIME) then
        setPlayerStorageValue(cid, STORE_VALUE, newExhaust) 
        return 1
    else
        return 0
    end
end
if there's any bugs please tell me and i'll check through it again

Edit: fixed a small silly bug, added too many ends ;)
I'll think about it. xD
 

tosuxo

Member
Joined
Jun 14, 2007
Messages
1,252
Best answers
0
Reaction score
21
i think there should be another end in there actually... after:
Code:
     doPlayerSendCancel(cid, "You cannot eat yet.")
end
so

Code:
     doPlayerSendCancel(cid, "You cannot eat yet.")
end
end
 
OP
RazorBlade

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,040
Best answers
3
Reaction score
597
Location
Canada
i think there should be another end in there actually... after:
Code:
     doPlayerSendCancel(cid, "You cannot eat yet.")
end
so

Code:
     doPlayerSendCancel(cid, "You cannot eat yet.")
end
end
You should consider testing it before handing it out to the public in my script o:
 

Matti96

Abyss
Joined
Apr 17, 2009
Messages
254
Best answers
0
Reaction score
45
Location
Poland/Germany
simple to make a script as this...
It really would be better if you change it to onUse
 

tosuxo

Member
Joined
Jun 14, 2007
Messages
1,252
Best answers
0
Reaction score
21
You should consider testing it before handing it out to the public in my script o:
does it look like i was using this script on my server? i was simply adding a bit extra to it to add exhaust.
 
OP
RazorBlade

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,040
Best answers
3
Reaction score
597
Location
Canada
simple to make a script as this...
It really would be better if you change it to onUse
Then make it onUse. I like it this way.

does it look like i was using this script on my server? i was simply adding a bit extra to it to add exhaust.
At which point did I say you were using it on your own server? I said you should test it before you release it to the public in my script. :/
 

tosuxo

Member
Joined
Jun 14, 2007
Messages
1,252
Best answers
0
Reaction score
21
well i didn't release it, i only said "here's how you can add exhaustion" :p
 
Top