-Skrypt lekka edycja skryptu

Status
Zamknięty.

orzelbot

Advanced User
Zarejestrowany
Dołączył
Listopad 11, 2008
Posty
189
Liczba reakcji
5
siema,
mam pewien problem ze skryptem, probowalem go edytowac lecz nie udalo mi sie
sprawa jest taka, ze do tego skryptu trzeba dodac sprawdzanie capa.

Jezeli ktos ma mniej capa niz 100 nie kupi mu itemka.
oto skrypt:

PHP:
  ----- Config -----
local config = {
        cost = 10000, -- Price
        item_id = 2274, -- Rune/Potion
        backpack_id = 2002 -- Backpack
}

local name = getItemNameById(2274) -- Same as item_id above
----- End Config -----
        if doPlayerRemoveMoney(cid, config.cost) == TRUE then
                local bp = doPlayerAddItem(cid, config.backpack_id, 1)
                        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
                        doSendAnimatedText(fromPosition, "Comprado", TEXTCOLOR_RED)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voc? comprou uma backpack de ".. name .."s por ".. config.cost .." gold.")
        for i=1,20 do
                        doAddContainerItem(bp, config.item_id, 50) -- You can edit this number, it will give shots per rune.
                end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voc? precisa de ".. config.cost .." gold para comprar uma backpack de ".. name .."s.")
                end
        return TRUE
end
 
Odp: lekka edycja skryptu

Witam!

PHP:
  ----- Config ----- 
local config = { 
        cost = 10000, -- Price 
        item_id = 2274, -- Rune/Potion 
        backpack_id = 2002 -- Backpack 
} 

local name = getItemNameById(2274) -- Same as item_id above 
----- End Config ----- 
        if doPlayerRemoveMoney(cid, config.cost) and getPlayerFreeCap(cid) >= (getItemWeightByID(config.item_id) * 20) then 
                local bp = doPlayerAddItem(cid, config.backpack_id, 1) 
                        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS) 
                        doSendAnimatedText(fromPosition, "Comprado", TEXTCOLOR_RED) 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voc? comprou uma backpack de ".. name .."s por ".. config.cost .." gold.") 
						for i=1,20 do 
                        doAddContainerItem(bp, config.item_id, 50) -- You can edit this number, it will give shots per rune. 
						end 
                else 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voc? precisa de ".. config.cost .." gold para comprar uma backpack de ".. name .."s.") 
                end 
        return TRUE 
end

function getItemWeightByID(itemid)
   local uid = doCreateItemEx(itemid)
   local ret = getItemWeight(uid)
   doRemoveItem(uid)
   return (ret)
end

Not tested, i hope it works ;]
 
Odp: lekka edycja skryptu

nie dziala,
wola?bym jak by ktos dodal do configa ilosc minimalnego capa,
potrzebuje dalej.
za pomoc rep
 
Odp: lekka edycja skryptu

Omg.
1. Co nie dzia?a? Jaki b??d?
2. Gdzie ty cz?owieku masz w tym skrypcie funkcje g??wn??? Je?eli to urywek kodu to podaj ca?y!
3. To b?dzie sztuczne ale jak chcesz to ok:
PHP:
  ----- Config -----  
local config = {  
        cost = 10000, -- Price  
        item_id = 2274, -- Rune/Potion  
        backpack_id = 2002 -- Backpack  
need_cap = 100
}  
local name = getItemNameById(2274) -- Same as item_id above  
----- End Config -----  
        if doPlayerRemoveMoney(cid, config.cost) and getPlayerFreeCap(cid) >= config.need_cap then  
                local bp = doPlayerAddItem(cid, config.backpack_id, 1)  
                        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)  
                        doSendAnimatedText(fromPosition, "Comprado", TEXTCOLOR_RED)  
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voc? comprou uma backpack de ".. name .."s por ".. config.cost .." gold.")  
                        for i=1,20 do  
                        doAddContainerItem(bp, config.item_id, 50) -- You can edit this number, it will give shots per rune.  
                        end  
                else  
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voc? precisa de ".. config.cost .." gold para comprar uma backpack de ".. name .."s.")  
                end  
        return TRUE  
end
 
Odp: lekka edycja skryptu

a to
Kod:
doPlayerRemoveMoney(cid, config.cost)
nie powinno sprawdza? czy jest TRUE?
 
Odp: lekka edycja skryptu

to jest caly skrypt, tam byl blad,
mozesz jeszcze raz przerobic?

PHP:
----- Config -----
local config = {
        cost = 10000, -- Price
        item_id = 2268, -- Rune/Potion
        backpack_id = 2003 -- Backpack
}

local name = getItemNameById(2268) -- Same as item_id above
----- End Config -----
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if doPlayerRemoveMoney(cid, config.cost) == TRUE then
                local bp = doPlayerAddItem(cid, config.backpack_id, 1)
                        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
                        doSendAnimatedText(fromPosition, "!SD!", TEXTCOLOR_RED)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voc? comprou uma backpack de ".. name .."s por ".. config.cost .." gold.")
        for i=1,20 do
                        doAddContainerItem(bp, config.item_id, 45) -- You can edit this number, it will give shots per rune.
                end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voc? precisa de ".. config.cost .." gold para comprar uma backpack de ".. name .."s.")
                end
        return TRUE
end
 
Odp: lekka edycja skryptu

Kod:
----- Config ----- 
local config = { 
        cost = 10000, -- Price 
        item_id = 2268, -- Rune/Potion 
        backpack_id = 2003, -- Backpack 
				need_cap = 100
} 
local name = getItemNameById(2268) -- Same as item_id above 
----- End Config ----- 
function onUse(cid, item, fromPosition, itemEx, toPosition) 
        if doPlayerRemoveMoney(cid, config.cost) == TRUE and getPlayerFreeCap(cid) >= config.need_cap then 
                local bp = doPlayerAddItem(cid, config.backpack_id, 1) 
                        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS) 
                        doSendAnimatedText(fromPosition, "!SD!", TEXTCOLOR_RED) 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voc? comprou uma backpack de ".. name .."s por ".. config.cost .." gold.") 
        for i=1,20 do 
                        doAddContainerItem(bp, config.item_id, 45) -- You can edit this number, it will give shots per rune. 
                end 
                else 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voc? precisa de ".. config.cost .." gold para comprar uma backpack de ".. name .."s.") 
                end 
        return TRUE 
end

?
 
Odp: lekka edycja skryptu

no fajnie nie kupuje jak ma sie zmniej capa niz 50,
ale pisze tak jak by nie bylo kasy oraz zabiera kase,
a powinno pisac ze nie ma sie capa.
 
Odp: lekka edycja skryptu

PHP:
----- Config ----- 
local config = { 
        cost = 10000, -- Price 
        item_id = 2268, -- Rune/Potion 
        backpack_id = 2003, -- Backpack 
				need_cap = 100
} 
local name = getItemNameById(2268) -- Same as item_id above 
----- End Config ----- 
function onUse(cid, item, fromPosition, itemEx, toPosition) 
        if getPlayerMoney(cid) >= config.cost and getPlayerFreeCap(cid) >= config.need_cap then 
                local bp = doPlayerAddItem(cid, config.backpack_id, 1) 
												doPlayerRemoveMoney(cid, config.cost)
                        doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS) 
                        doSendAnimatedText(fromPosition, "!SD!", TEXTCOLOR_RED) 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voc? comprou uma backpack de ".. name .."s por ".. config.cost .." gold.") 
        for i=1,20 do 
                        doAddContainerItem(bp, config.item_id, 45) -- You can edit this number, it will give shots per rune. 
                end 
                else 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voc? precisa de ".. config.cost .." gold para comprar uma backpack de ".. name .."s.") 
                end 
        return TRUE 
end
 
Odp: lekka edycja skryptu

a umialbys zrobic tak, ze jak ktos nie ma miejsca w bp to tez mu nie kupi?
 
Odp: lekka edycja skryptu

PHP:
----- Config -----
local cfg =
{
	cost = 10000,					-- cena
	item_id = 2268,  			-- id przedmiotu
	item_count = 45,			-- ilosc przedmiotu
	backpack_id = 2003,  	-- id placaka
	need_cap = 100				-- potrzebny cap
}
----- End Config -----

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerMoney(cid) >= cfg.cost then
		if getPlayerFreeCap(cid) >= cfg.need_cap then
			local bp = doPlayerAddItem(cid, cfg.backpack_id, 1)
			if bp and doAddContainerItem(bp, cfg.item_id, cfg.item_count) then
				doPlayerRemoveMoney(cid, cfg.cost)
				doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
				doSendAnimatedText(fromPosition, "!SD!", TEXTCOLOR_RED)
				local name = getItemNameById(cfg.item_id)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Otrzymales ".. name .."")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Zrob miejsce w plecaku.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Wymagane ".. cfg.need_cap .." cap.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Musisz miec co najmniej ".. cfg.cost .." gp.")
	end
return TRUE
end
 
Odp: lekka edycja skryptu

jest tak,
jezeli nie mam wolnego miejsca w bp to pisze ze kupiles bd of sd ale nie dostaje,
a chyba powinno byc: "Zrob miejsce w plecaku."
 
Odp: lekka edycja skryptu

Nie lepiej to:
PHP:
local config = {
	-- Mana potions
	[60001] = {id = 7590, count = 1, cost = 1800}, -- big 
	[60002] = {id = 7589, count = 1, cost = 1000}, -- medium
	[60003] = {id = 7620, count = 1, cost = 400}, -- small
	-- Health potions
	[60004] = {id = 7591, count = 1, cost = 3200}, -- big
	[60005] = {id = 7588, count = 1, cost = 1400}, -- medium
	[60006] = {id = 7618, count = 1, cost = 500}, -- small
	-- Runes
	[60007] = {id = 2268, count = 4, cost = 6000}, -- SD
	[60008] = {id = 2273, count = 3, cost = 4200}, -- UH
	[60009] = {id = 2313, count = 6, cost = 5000} -- EXPLO
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local items = config[item.uid]
    if isInArray({1740, 1747, 1749}, item.itemid) ~= TRUE then
        return TRUE
    end
	if(getPlayerMoney(cid) >= items.cost) then
		local container = doCreateItemEx(1988, 1)
		for i = 1, 20 do
			doAddContainerItem(container, items.id, items.count)
		end
		if(doPlayerAddItemEx(cid, container, false) ~= RETURNVALUE_NOERROR) then
			doPlayerSendTextMessage(cid, 25, 'You don\'t have free place in your backpack or you don\'t have capacity!')
		else
			doPlayerRemoveMoney(cid, items.cost)
			doPlayerSendTextMessage(cid, 25, "You bought backpack of ".. items.count .."x ".. getItemNameById(items.id) .."s!")
		end
	else
		doPlayerSendTextMessage(cid, 25, "You don't have enought money!")
	end
    return TRUE
end
PHP:
<action fromuid="60001" touid="60009" event="script" value="chestshop.lua"/>
 
Status
Zamknięty.
Back
Do góry