What's new

Actions Random Present Bag (Vestia.pl)

Status
Not open for further replies.

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Witam,
Postanowi?em zrobic Random Present Bag, bardzo podobny do tego z Vestia.pl

a wi?c.

Items.xml
Znajdz item o ID:
Code:
7393

zamie? ca?y na :
Code:
    <item id="7393" article="a" name="Random Present Bag">
        <attribute key="weight" value="500" />
    </item>

Stw?rz plik RandomPresent.lua w actions/scripts/other
Code:
local RandomPresent = { 8925, 5907, 6433, 9776, 9932, 9777 }
function onUse(cid, item, frompos, item2, topos)
		local Random = math.random(#RandomPresent) 
		doPlayerSendTextMessage(cid,22,"Otrzyma?e? 'Random Present'. Gratuluje.")
		doRemoveItem(item.uid, 1)
		doPlayerAddItem(cid, RandomPresent[Random])
end

w Actions.xml:
Code:
	<action itemid="7393" event="script" value="other/RandomPresent.lua"/>
 

Xevis

Senior User
Joined
May 28, 2008
Messages
836
Reaction score
54
Odp: Random Present Bag (Vestia.pl)

s?abo, co jak nie b?dzie mia? capa lub miejsca?
Powinny wy?wietli? si? odpowiednie komunikaty, + tak prezentowana tabela jest s?abo czytelna i ci??ko operowalna.
ciekawym dodatkiem byloby wprowadzenie szans na dostanie itemu.
 

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Odp: Random Present Bag (Vestia.pl)

Xevis, przemy?le to i mo?e zrobi? v2. A i tak w ogole to zajebista jest Vastoria :D Gram od wczoraj.

---------- Tre?? dodana o 21:59 ----------

Nie testowa?em lecz je?li chodzi o cap to wydaje mi si? ?e tak ma byc :
Code:
local RandomPresent = { 8925, 5907, 6433, 9776, 9932, 9777 }

function onUse(cid, item, frompos, item2, topos)
	local v = db.getResult("SELECT `cap` FROM `players` WHERE `id` = "..getPlayerGUID(cid)..";")
	local cap = v:getDataInt("cap", getPlayerGUID(cid))
	doCreatureSetStorage(cid, Capacityx, cap)
		local Random = math.random(#RandomPresent) 
		if getCreatureStorage(cid, Capacityx) >= 120 then
			doPlayerSendTextMessage(cid,22,"Otrzyma?e? 'Random Present'. Gratuluje.")
			doRemoveItem(item.uid, 1)
			doPlayerAddItem(cid, RandomPresent[Random])
		else 
			doPlayerSendTextMessage(cid,22,"Potrzebujesz wi?cej Capa.")
		end
end
 

Xevis

Senior User
Joined
May 28, 2008
Messages
836
Reaction score
54
Odp: Random Present Bag (Vestia.pl)

Nie testuje, ale wierze ?e wiesz co piszesz, teraz przebuduj tablice, chocia?by graficznie, aby mo?na da? komentarz, no i ilo??, np 5 cc.
Oraz miejsce w bp, bo jak nie ma miejsca to te? upu?ci na ziemie pewnie item.
Jak to zrobisz to skrypt b?dzie pe?ny.
 

Dantez

Moim sekretem jest ciasto
Joined
May 22, 2008
Messages
1,206
Reaction score
202
Odp: Random Present Bag (Vestia.pl)

[LUA]local v = db.getResult("SELECT `cap` FROM `players` WHERE `id` = "..getPlayerGUID(cid)..";")
local cap = v:getDataInt("cap", getPlayerGUID(cid))
doCreatureSetStorage(cid, Capacityx, cap)[/LUA]
I jak to ma dzia?a?? Pomijaj?c, ?e nie zdefiniowa?e? Capacityx.

[LUA]if getCreatureStorage(cid, Capacityx) >= 120 then[/LUA]
Czyli ka?dy item zajmuje 120+ capa?

[LUA]getPlayerFreeCap(cid)[/LUA]
Nada si?? :)
 

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Odp: Random Present Bag (Vestia.pl)

Dantez, getPlayerFreeCap(cid) - Nie wiedzia?em ?e jest :D Ucz? si? dopiero funkcji lua kt?re s? u?ywane w Tibi. a co do 120, to powinno byc 110. zamiast robic kod z pe?no if wystarczy 1 bo wtedy sprawdza najwi?ksz? wage. Mo?na zrobic na kilka if?w ?eby by?a dok?adna waga.

---------- Tre?? dodana o 23:47 ----------

Dobra ju? zrobi?em z dok?ad? wag?:
Code:
local RandomPresent = 
{ 
	8925 --[[= 110]], 
	5907 --[[= 12]], 
	6433 --[[= 32]], 
	9776 --[[= 70]], 
	9932 --[[= 10]], 
	9777 --[[= 65]],
	2160 --[[= 10]] 
}

local Amount = 50

function onUse(cid, item, frompos, item2, topos)
	
		local Random = math.random(#RandomPresent) 
		if getPlayerFreeCap(cid) >= getItemWeightById(RandomPresent[Random]) then
			doPlayerSendTextMessage(cid,22,"Otrzyma?e? "..getItemNameById(RandomPresent[Random])..". Gratuluje.")
			doRemoveItem(item.uid, 1)
			if RandomPresent[Random] == 2160 then
				doPlayerAddItem(cid, 2160, Amount)
			else 
				doPlayerAddItem(cid, RandomPresent[Random])
			end
		else 
			doPlayerSendTextMessage(cid,22,"Potrzebujesz wi?cej Capa.")
		end
end

to z BP zrobie jutro.
 
Last edited:

Placek

Blue Waffle
Joined
Sep 30, 2008
Messages
6,793
Reaction score
672
Age
9
Odp: Random Present Bag (Vestia.pl)

Slabawo troche. Ale przynajmniej masz jakis pomysl na robienie czegos(skrypty z vestii), no i jak widac z rad troche korzystasz. Moze ogarniesz pare rzeczy konkretnych i bedziesz sensownie pisac w koncu za jakis czas :D
 

misztrz440

Banned
Joined
Dec 15, 2012
Messages
1,032
Reaction score
39
Odp: Random Present Bag (Vestia.pl)

Jak nie b?dzie mia? capa to do depo itemy niech lec?.
 

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Odp: Random Present Bag (Vestia.pl)

Nie mia?em okazji przetestowac je?li chodzi o te Depo i BP ale macie kod:
[lua]local RandomPresent =
{
8925 --[[= 110]],
5907 --[[= 12]],
6433 --[[= 32]],
9776 --[[= 70]],
9932 --[[= 10]],
9777 --[[= 65]],
2160 --[[= 10]]
}

local Amount = 50

function doPlayerAddDepotItems(pid, item, count) --By magus and edited by vodkart
local item,count = {item},{(count or 1)}
for k,v in ipairs(item) do
local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1")
return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls:getDataInt("sid")+1)..", 101, "..v..", "..count[k]..", '')") or false
end
end

function getContainerSlotsFree(container) -- by vodka
return getContainerCap(container)-getContainerSize(container)
end

function getAllContainerFree(container) -- by vodka
local containers,soma = {},0
for i = 0, getContainerSize(container)-1 do
local item = getContainerItem(container, i)
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
end
for _, check in pairs(containers) do
soma = soma + getContainerSlotsFree(check)
end
return (soma + getContainerSlotsFree(container))
end

function onUse(cid, item, frompos, item2, topos)

local Random = math.random(#RandomPresent)
local FreeSlots = getAllContainerFree(getPlayerSlotItem(cid, 3).uid)
if FreeSlots == 0 or getPlayerFreeCap(cid) < getItemWeightById(RandomPresent[Random]) then
doPlayerSendTextMessage(cid,22,"Nie mia?e? wystarczaj?co Capa/miejsca w BP. Tw?j "..getItemNameById(RandomPresent[Random]).." zosta? dodany do depo.")
doRemoveItem(item.uid, 1)
doPlayerAddDepotItems(pid, RandomPresent[Random], 1)
end
if RandomPresent[Random] == 2160 then
doPlayerAddItem(cid, 2160, Amount)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid,22,"Gratulacje. Tw?j prezent z 'Random Present Bag' to "..getItemNameById(RandomPresent[Random])..".")
else
doPlayerAddItem(cid, RandomPresent[Random])
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid,22,"Gratulacje. Tw?j prezent z 'Random Present Bag' to "..getItemNameById(RandomPresent[Random])..".")
end
end
[/lua]
 

DanJ93

ElfBot Helper
Joined
Jan 18, 2009
Messages
2,631
Reaction score
200
Odp: Random Present Bag (Vestia.pl)

Jak nie b?dzie mia? capa to do depo itemy niech lec?.
Zero logiki.
Sk?d te itemy mia?y by si? wzi?? w depo, skoro prezent mamy przy sobie. Po 2. go?? si? b?dzie zastanawia? gdzie jego itemy z prezentu.

Prosz? bardzo:
[lua]local RandomPresent = {8925, 5907, 6433, 9776, 9932, 9777, 2160}
function onUse(cid, item, frompos, item2, topos)
local Random = math.random(#RandomPresent)
if RandomPresent[Random] == 2160 then
local ilosc = 50
else
local ilosc = 0
end
if doPlayerAddItem(cid, RandomPresent[Random], 1, false)
doPlayerSendTextMessage(cid,22,"Otrzyma?e? "..getItemNameById(RandomPresent[Random])..". Gratuluje.")
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid,22,"Potrzebujesz wi?cej capa/miejsca.")
end
end[/lua]
 
Last edited:

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Odp: Random Present Bag (Vestia.pl)

DanJ93, [lua]doPlayerSendTextMessage(cid,22,"Nie mia?e? wystarczaj?co Capa/miejsca w BP. Tw?j "..getItemNameById(RandomPresent[Random]).." zosta? dodany do depo.")[/lua]
Tw?j skrypt to praktycznie to samo co da?em wcze?niej :) Nie wiem po co wklei?e?.
[lua]local RandomPresent =
{
8925 --[[= 110]],
5907 --[[= 12]],
6433 --[[= 32]],
9776 --[[= 70]],
9932 --[[= 10]],
9777 --[[= 65]],
2160 --[[= 10]]
}

local Amount = 50

function onUse(cid, item, frompos, item2, topos)

local Random = math.random(#RandomPresent)
if getPlayerFreeCap(cid) >= getItemWeightById(RandomPresent[Random]) then
doPlayerSendTextMessage(cid,22,"Otrzyma?e? "..getItemNameById(RandomPresent[Random])..". Gratuluje.")
doRemoveItem(item.uid, 1)
if RandomPresent[Random] == 2160 then
doPlayerAddItem(cid, 2160, Amount)
else
doPlayerAddItem(cid, RandomPresent[Random])
end
else
doPlayerSendTextMessage(cid,22,"Potrzebujesz wi?cej Capa.")
end
end[/lua]
 

DanJ93

ElfBot Helper
Joined
Jan 18, 2009
Messages
2,631
Reaction score
200
Odp: Random Present Bag (Vestia.pl)

Nie zawsze ka?d? wiadomo?? zauwa?ysz. 0 logiki.

Kr?tszy, lepszy, u Ciebie sprawdza tylko capa
 

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Odp: Random Present Bag (Vestia.pl)

DanJ93, kr?tszy o 3 linijki :D Bo te 11 to przez tablice :D

---------- Tre?? dodana o 20:12 ----------

+ u ciebie Capa nie sprawdza wi?c jest tam ju? plus. W tym moim ostatnim skrypcie sprawdza Capa + miejsce w bp i dodaje do Depo je?li nie ma miejsca lub capa nie ma.
 

mial123

Advanced User
Joined
Apr 2, 2009
Messages
307
Reaction score
24
Odp: Random Present Bag (Vestia.pl)

DanJ93 przy twoim mam b?ad(linia: if RandomPresent[Random] == 2160 then), fajny skrypt, napewno si? przyda :D Da?o by rade doda? do skryptu: ?e dana profesja ma wieksze szanse na zdobycie danego przedmiotu?
 
Last edited:

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Odp: Random Present Bag (Vestia.pl)

Mial123, oczywi?cie. Podaj jaki przedmiot i ju? zrobie :)

---------- Tre?? dodana o 21:56 ----------

I jaka profesja.
 

mial123

Advanced User
Joined
Apr 2, 2009
Messages
307
Reaction score
24
Odp: Random Present Bag (Vestia.pl)

Skibi184 w tym przypadku nie mam na razie id, ale w przysz?o?ci by mi si? to przyda?o, wi?c daj oboj?tne :D Przyk?adowe: 2640 - ED/ MS, 9933 - RP, 2646 - EK
 
Last edited:

DanJ93

ElfBot Helper
Joined
Jan 18, 2009
Messages
2,631
Reaction score
200
Odp: Random Present Bag (Vestia.pl)

DanJ93, [...] u ciebie Capa nie sprawdza wi?c jest tam ju? plus.
A sprawdza?e? chocia??
Tu si? mylisz, bo sprawdza capa i czy masz miejsce w r?ce/bp
 

mial123

Advanced User
Joined
Apr 2, 2009
Messages
307
Reaction score
24
Odp: Random Present Bag (Vestia.pl)

Skibi184 i jak tam skrypt :D? Do wykonania?
 

Skibi184

Active User
Joined
Jan 16, 2014
Messages
96
Reaction score
1
Odp: Random Present Bag (Vestia.pl)

Mial123, tak pracuje nad tym. Zrobi?em ju? ale ten kod jest za d?ugi. Kombinuje jak skr?cic kod.
 

kuba1418

Banned
Joined
Apr 12, 2008
Messages
178
Reaction score
17
Odp: Random Present Bag (Vestia.pl)

@DanJ93
[LUA] local RandomPresent = {8925, 5907, 6433, 9776, 9932, 9777, 2160}
function onUse(cid, item, frompos, item2, topos)
local Random = math.random(#RandomPresent)
if RandomPresent[Random] == 2160 then
local ilosc = 50
else
local ilosc = 0
end
if doPlayerAddItem(cid, RandomPresent[Random], 1, false)
doPlayerSendTextMessage(cid,22,"Otrzyma?e? "..getItemNameById(RandomPresent[Random])..". Gratuluje.")
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid,22,"Potrzebujesz wi?cej capa/miejsca.")
end
end[/LUA]

Ty natomiast zdefiniowale? ilo??
if RandomPresent[Random] == 2160 then
local ilosc = 50
else
local ilosc = 0
end
tylko tego nie wykorzysta?e?.

if doPlayerAddItem(cid, RandomPresent[Random], 1, false)
oraz brakuje

Wydaje mi si? ?e mia?e? co? takiego na my?li chod? mog? si? myli? [LUA] local RandomPresent = {8925, 5907, 6433, 9776, 9932, 9777, 2160}
function onUse(cid, item, frompos, item2, topos)
local Random = math.random(#RandomPresent)
if RandomPresent[Random] == 2160 then
local ilosc = 50
else
local ilosc = 1
end
if doPlayerAddItem(cid, RandomPresent[Random], ilosc, false) then
doPlayerSendTextMessage(cid,22,"Otrzyma?e? "..getItemNameById(RandomPresent[Random])..". Gratuluje.")
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid,22,"Potrzebujesz wi?cej capa/miejsca.")
end
return true
end[/LUA]
 
Last edited:
Status
Not open for further replies.
Top