TalkAction Easy Donator Buying!

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
PHP:
<talkaction words="!buy" script="DonatorBuying.lua" />
That's what should be in Talkactions.xml ^

This one should be called "DonatorBuying.lua" V

PHP:
--[[

This script is made by Jesper_Kladden @ Tpforums, TibiaTek, Otf4ns or Otland.

Use this script only if you have experience in other scripts.

Thanks to Master-M, Evil Hero, and Colandus for helping.

]]--

-- Configuration --

local DonationValue = 666 -- The special storage value a Donator has (Can't be higher than 65.000(65k)).
local AOL = 2173 -- Amulet of loss
local BPH = 2365 -- BackPack of holding
local BOH = 2195 -- Boots of haste
local SBOOTS = 2640 -- Soft Boots
local AOLP = 20000 -- Price of AOL
local BPHP = 100000 -- Price of Backpack of holding
local BOHP = 50000 -- Price of BOH
local SBOOTSP = 1000000 -- Price of Soft Boots

-- End Configuration --

function onSay(cid, word, param)

setPlayerStorageValue(cid, DonationValue, 1) --<- I used this for testing if it works. Delete if you don't want to test

   if getPlayerStorageValue(cid, DonationValue) == 1 then
   
		if param == "aol" and doPlayerRemoveMoney(cid, AOLP) == TRUE then
			doPlayerAddItem(cid, AOL, 1)
			
		elseif param == "boh" and doPlayerRemoveMoney(cid, BOHP) == TRUE then
			doPlayerAddItem(cid, BOH, 1)
			
		elseif param == "bpholding" and doPlayerRemoveMoney(cid, BPHP) == TRUE then
			doPlayerAddItem(cid, BPH, 1)	
			
		elseif param == "softboots" and doPlayerRemoveMoney(cid, SBOOTSP) == TRUE then
			doPlayerAddItem(cid, SBOOTS, 1)
			
		elseif param == "prices" then
			doPlayerSendTextMessage(cid, 22,
			"Prices for Donation-Fast-Buyment:\n--------\n Boots of haste(boh) - 50k\n Amulet of loss(aol) - 20k\n Backpack of holding (bpholding) - 100k\n Soft Boots (softboots) - 1kk(1000k)\n--------\n Script created by 'Jesper_Kladden'")
			
		  else 
            doPlayerSendTextMessage(cid, 22, "Either a bad code or not enough money!") 
        end 
    else      
      doPlayerSendTextMessage(cid, 22, "You are not a donator!") 
    end 
		end
	end
end

The script works like this:

*You must be a donator and have a certain storagevalue
*You can write either - !buy "aol/boh/softboots/bpholding
*If you can't afford, the script will tell you that
*If you're not a donator, the script will tell you that.


Master Programs <-- Please take a visit.
 
Last edited:
OP
Jesper_Kladden

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
Can someone help me getting the IDs for:

*BoH
*BP of Holding
*Soft Boots.


Thanks
 
Last edited:

Pitufo™

InfinityOT.com
Joined
Feb 14, 2008
Messages
1,438
Best answers
0
Reaction score
7
Location
Mexico, Cuernavaca
Added some "elses" to the script you made:

PHP:
--[[

This script is made by Jesper_Kladden @ Tpforums, TibiaTek, Otf4ns or Otland.

Use this script only if you have experience in other scripts.

Thanks to Master-M, Evil Hero, and Colandus for helping.

]]--

-- Configuration --

local DonationValue = 666 -- The special storage value a Donator has (Can't be higher than 65.000(65k)).
local AOL = 2173 -- Amulet of loss
local BPH = 2365 -- BackPack of holding
local BOH = 2195 -- Boots of haste
local SBOOTS = 2640 -- Soft Boots
local AOLP = 20000 -- Price of AOL
local BPHP = 100000 -- Price of Backpack of holding
local BOHP = 50000 -- Price of BOH
local SBOOTSP = 1000000 -- Price of Soft Boots

-- End Configuration --

function onSay(cid, word, param)

setPlayerStorageValue(cid, DonationValue, 1) --<- I used this for testing if it works. Delete if you don't want to test

	if getPlayerStorageValue(cid, DonationValue) == 1 then
		if param == "aol" and doPlayerRemoveMoney(cid, AOLP) == TRUE then
            doPlayerAddItem(cid, AOL, 1)
		elseif param == "boh" and doPlayerRemoveMoney(cid, BOHP) == TRUE then
            doPlayerAddItem(cid, BOH, 1)
            
        elseif param == "bpholding" and doPlayerRemoveMoney(cid, BPHP) == TRUE then
            doPlayerAddItem(cid, BPH, 1)    
            
        elseif param == "softboots" and doPlayerRemoveMoney(cid, SBOOTSP) == TRUE then
            doPlayerAddItem(cid, SBOOTS, 1)
            
        elseif param == "prices" then
            doPlayerSendTextMessage(cid, 22,
            "Prices for Donation-Fast-Buyment:\n--------\n Boots of haste(boh) - 50k\n Amulet of loss(aol) - 20k\n Backpack of holding (bpholding) - 100k\n Soft Boots (softboots) - 1kk(1000k)\n--------\n Script created by 'Jesper_Kladden'")
            
        else
            doPlayerSendTextMessage(cid, 22, "Wrong param or not enough money!!")
        end
	else     
      doPlayerSendTextMessage(cid, 22, "You are not a donator!")
	end
end
Change:

This:
PHP:
else
            doPlayerSendTextMessage(cid, 22, "Wrong param or not enough money!!")
        end

To this:

PHP:
        else
            doPlayerSendTextMessage(cid, 22, "Wrong param or not enough money!!")
        end
	else     
      doPlayerSendTextMessage(cid, 22, "You are not a donator!")
	end
 

Mazen

Developer
Joined
Aug 20, 2007
Messages
612
Best answers
0
Reaction score
36
Location
Sweden
This is my (not tested) version of the script. You can add and remove items more easy....

Code:
local Test = "yes" -- Can be yes/no.
local DonationValue = 666 -- The special storage value a Donator has (Can't be higher than 65.000(65k)).
local Items = 
{
aol = {2173, 1, 20000}, -- Example of an item. "Itemid, count, price"
itemtwo = {2175, 1, 20000}, -- Example of an item. "Itemid, count, price"
anotheritem = {2176, 4, 20000}, -- Example of an item. "Itemid, count, price"
blablabla = {2177, 1, 20000} -- Example of an item. "Itemid, count, price"
}
function onSay(cid, word, param)
local paramitem = {param} -- Don't touch this!
	if Test == "yes" then
		setPlayerStorageValue(cid, DonationValue, 1)
	end

	if getPlayerStorageValue(cid, DonationValue) == 1 then
		if not(param == nil) then
			if param == Items.[paramitem] then
				if doPlayerRemoveMoney(cid, Items.[paramitem][3]) == TRUE then
					doPlayerAddItem(cid, Items.[paramitem][1], Items.[paramitem][2])
				else 
					doPlayerSendTextMessage(cid, 22, "You do not have enough money to buy this item!") 
				end
			else 
				doPlayerSendTextMessage(cid, 22, "You cannot buy that item!") 
			end
		else 
			doPlayerSendTextMessage(cid, 22, "Please write what item you want to buy!") 
		end 
	else      
		doPlayerSendTextMessage(cid, 22, "You are not a donator!") 
	end 
return TRUE
end
 

Zelvant

HaY LaRay LaRa
Joined
Jul 25, 2007
Messages
24
Best answers
0
Reaction score
0
Location
Mexico
thank you a lot for this one, i will use it on my server!
thanks again
 
OP
Jesper_Kladden

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Best answers
0
Reaction score
1
Location
Sweden
ha , yea. But ">= 1" is 1 or more and "== 1" is one. ? So It shouldn't be any difference O_O ?
 

Colandus

Advanced OT User
Joined
Jun 6, 2007
Messages
2,424
Best answers
18
Reaction score
165
Location
Sweden
he might have the value as 2 to show vip or smth xd

which means even if he changed it to "> 1" would make it work ^_^
 
Top