What's new

-Tibia 7.60 [7.6] BuyContainer System

Status
Not open for further replies.

Thorge D

Advanced User
Joined
Jul 24, 2014
Messages
300
Reaction score
29
1. Autor: Crea
2. Link do oryginalnego tematu:
3. Opis: Kod pozwala na tworzenie NPC, kt?ry sprzedaje ca?e plecaki przedmiot?w.

4. Kod:

Do npc.cpp dodaj na samym dole lub mi?dzy innymi funkcjami:
[CPP]int NpcScript::luaBuyCont(lua_State *L)
{
int bpid = (int)lua_tonumber(L, -1);
int cost = (int)lua_tonumber(L, -2);
int count = (int)lua_tonumber(L, -3);
int itemid = (int)lua_tonumber(L, -4);
int cid = (int)lua_tonumber(L, -5);
lua_pop(L,6);
Npc* mynpc = getNpc(L);
Creature* creatore = mynpc->game->getCreatureByID(cid);
Player *player = dynamic_cast<Player*>(creatore);
if (player){
if (player->getCoins(cost)){
if (player->removeCoins(cost)){ // double check

//Start of Container Stuff
Container *backpack = dynamic_cast<Container*>(Item::CreateItem(bpid));
if(backpack)
{
for(int i = 0; i < backpack->capacity(); ++i){
backpack->addItem(Item::CreateItem(itemid, count));
}
player->addItem(backpack);
}
//End
mynpc->doSay("Here you go mate!");
}
else{
mynpc->doSay("Sorry, you do not have enough gold.");
}
}
else{
mynpc->doSay("Sorry, you do not have enough gold.");
}
}
return 1;
}[/CPP]
Po linijce:
[CPP]lua_register(luaState, "pay", NpcScript::luaPayMoney); [/cpp]
Dodaj:
[CPP]lua_register(luaState, "BuyContainer", NpcScript::luaBuyCont); [/CPP]
Teraz w npc.h po linijce:
[CPP]static int luaPayMoney(lua_State *L); [/CPP]
Dodaj:
[CPP]static int luaBuyCont(lua_State *L); [/CPP]
I skompiluj projekt.

Teraz wystarczy doda? t? funkcje do NPC.
Je?li masz standardowego NPC od run wejd? do npc/scripts/runes.lua lub je?li masz swojego dodaj poni?szy kod swojego:
[LUA]---------- Backpack of Runes --------------

elseif msgcontains(msg, 'bpuh') and focus == cid then
BuyContainer(cid,2273,100,20000,1988)
talk_start = os.clock()

elseif msgcontains(msg, 'bpmanarune') and focus == cid then
BuyContainer(cid,2314,33,2000000,1988)
talk_start = os.clock()

elseif msgcontains(msg, 'bpsd') and focus == cid then
BuyContainer(cid,2268,100,100000,1988)
talk_start = os.clock()

elseif msgcontains(msg, 'bpgfb') and focus == cid then
BuyContainer(cid,2304,100,20000,1988)
talk_start = os.clock()

elseif msgcontains(msg, 'bpexplo') and focus == cid then
BuyContainer(cid,2313,100,20000,1988)
talk_start = os.clock()

elseif msgcontains(msg, 'bpmwall') and focus == cid then
BuyContainer(cid,2293,100,20000,1988)
talk_start = os.clock()

elseif msgcontains(msg, 'bphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,1988)
talk_start = os.clock()

elseif msgcontains(msg, 'bpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,1988)
talk_start = os.clock()

---------- Green Backpack of Runes --------------

elseif msgcontains(msg, 'greenbpuh') and focus == cid then
BuyContainer(cid,2273,100,20000,1998)
talk_start = os.clock()

elseif msgcontains(msg, 'greenbpmanarune') and focus == cid then
BuyContainer(cid,2314,33,2000000,1998)
talk_start = os.clock()

elseif msgcontains(msg, 'greenbpsd') and focus == cid then
BuyContainer(cid,2268,100,100000,1998)
talk_start = os.clock()

elseif msgcontains(msg, 'greenbpgfb') and focus == cid then
BuyContainer(cid,2304,100,20000,1998)
talk_start = os.clock()

elseif msgcontains(msg, 'greenbpexplo') and focus == cid then
BuyContainer(cid,2313,100,20000,1998)
talk_start = os.clock()

elseif msgcontains(msg, 'greenbpmwall') and focus == cid then
BuyContainer(cid,2293,100,20000,1998)
talk_start = os.clock()

elseif msgcontains(msg, 'greenbphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,1998)
talk_start = os.clock()

elseif msgcontains(msg, 'greenbpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,1998)
talk_start = os.clock()

---------- Olive Backpack of Runes --------------

elseif msgcontains(msg, 'olivebpuh') and focus == cid then
BuyContainer(cid,2273,100,20000,1999)
talk_start = os.clock()

elseif msgcontains(msg, 'olivebpmanarune') and focus == cid then
BuyContainer(cid,2314,33,2000000,1999)
talk_start = os.clock()

elseif msgcontains(msg, 'olivebpsd') and focus == cid then
BuyContainer(cid,2268,100,100000,1999)
talk_start = os.clock()

elseif msgcontains(msg, 'olivebpgfb') and focus == cid then
BuyContainer(cid,2304,100,20000,1999)
talk_start = os.clock()

elseif msgcontains(msg, 'olivebpexplo') and focus == cid then
BuyContainer(cid,2313,100,20000,1999)
talk_start = os.clock()

elseif msgcontains(msg, 'olivebpmwall') and focus == cid then
BuyContainer(cid,2293,100,20000,1999)
talk_start = os.clock()

elseif msgcontains(msg, 'olivebphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,1999)
talk_start = os.clock()

elseif msgcontains(msg, 'olivebpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,1999)
talk_start = os.clock()

---------- Red Backpack of Runes --------------

elseif msgcontains(msg, 'redbpuh') and focus == cid then
BuyContainer(cid,2273,100,20000,2000)
talk_start = os.clock()

elseif msgcontains(msg, 'redbpmanarune') and focus == cid then
BuyContainer(cid,2314,33,2000000,2000)
talk_start = os.clock()

elseif msgcontains(msg, 'redbpsd') and focus == cid then
BuyContainer(cid,2268,100,100000,2000)
talk_start = os.clock()

elseif msgcontains(msg, 'redbpgfb') and focus == cid then
BuyContainer(cid,2304,100,20000,2000)
talk_start = os.clock()

elseif msgcontains(msg, 'redbpexplo') and focus == cid then
BuyContainer(cid,2313,100,20000,2000)
talk_start = os.clock()

elseif msgcontains(msg, 'redbpmwall') and focus == cid then
BuyContainer(cid,2293,100,20000,2000)
talk_start = os.clock()

elseif msgcontains(msg, 'redbphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,2000)
talk_start = os.clock()

elseif msgcontains(msg, 'redbpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,2000)
talk_start = os.clock()

---------- Violet Backpack of Runes --------------

elseif msgcontains(msg, 'violetbpuh') and focus == cid then
BuyContainer(cid,2273,100,20000,2001)
talk_start = os.clock()

elseif msgcontains(msg, 'violetbpmanarune') and focus == cid then
BuyContainer(cid,2314,33,2000000,2001)
talk_start = os.clock()

elseif msgcontains(msg, 'violetbpsd') and focus == cid then
BuyContainer(cid,2268,100,100000,2001)
talk_start = os.clock()

elseif msgcontains(msg, 'violetbpgfb') and focus == cid then
BuyContainer(cid,2304,100,20000,2001)
talk_start = os.clock()

elseif msgcontains(msg, 'violetbpexplo') and focus == cid then
BuyContainer(cid,2313,100,20000,2001)
talk_start = os.clock()

elseif msgcontains(msg, 'violetbpmwall') and focus == cid then
BuyContainer(cid,2293,100,20000,2001)
talk_start = os.clock()

elseif msgcontains(msg, 'violetbphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,2001)
talk_start = os.clock()

elseif msgcontains(msg, 'violetbpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,2001)
talk_start = os.clock()

---------- Grey Backpack of Runes --------------

elseif msgcontains(msg, 'greybpuh') and focus == cid then
BuyContainer(cid,2273,100,20000,2003)
talk_start = os.clock()

elseif msgcontains(msg, 'greybpmanarune') and focus == cid then
BuyContainer(cid,2314,33,2000000,2003)
talk_start = os.clock()

elseif msgcontains(msg, 'greybpsd') and focus == cid then
BuyContainer(cid,2268,100,100000,2003)
talk_start = os.clock()

elseif msgcontains(msg, 'greybpgfb') and focus == cid then
BuyContainer(cid,2304,100,20000,2003)
talk_start = os.clock()

elseif msgcontains(msg, 'greybpexplo') and focus == cid then
BuyContainer(cid,2313,100,20000,2003)
talk_start = os.clock()

elseif msgcontains(msg, 'greybpmwall') and focus == cid then
BuyContainer(cid,2293,100,20000,2003)
talk_start = os.clock()

elseif msgcontains(msg, 'greybphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,2003)
talk_start = os.clock()

elseif msgcontains(msg, 'greybpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,2003)
talk_start = os.clock()

---------- Gold Backpack of Runes --------------

elseif msgcontains(msg, 'goldbpuh') and focus == cid then
BuyContainer(cid,2273,100,20000,2004)
talk_start = os.clock()

elseif msgcontains(msg, 'goldbpmanarune') and focus == cid then
BuyContainer(cid,2314,33,2000000,2004)
talk_start = os.clock()

elseif msgcontains(msg, 'goldbpsd') and focus == cid then
BuyContainer(cid,2268,100,100000,2004)
talk_start = os.clock()

elseif msgcontains(msg, 'goldbpgfb') and focus == cid then
BuyContainer(cid,2304,100,20000,2004)
talk_start = os.clock()

elseif msgcontains(msg, 'goldbpexplo') and focus == cid then
BuyContainer(cid,2313,100,20000,2004)
talk_start = os.clock()

elseif msgcontains(msg, 'goldbpmwall') and focus == cid then
BuyContainer(cid,2293,100,20000,2004)
talk_start = os.clock()

elseif msgcontains(msg, 'goldbphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,2004)
talk_start = os.clock()

elseif msgcontains(msg, 'goldbpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,2004)
talk_start = os.clock() [/LUA]

Od teraz kupuj?c Uh'y czy inne runy mo?esz wybiera? rodzaj bp'aka z takich jak poni?ej:
- bp
- greenbp
- olivebp
- redbp
- violetbp
- greybp
- goldbp

Mo?ecie r?wnie? doda? linijk? z workami, big backpackami itd je?li chcecie, wystarczy skopiowa? t? linijk?:
[LUA]elseif msgcontains(msg, 'goldbpblank') and focus == cid then
BuyContainer(cid,2260,1,10000,2004)
talk_start = os.clock() [/LUA]
i zmieni? w niej ostatni? liczb? czyli 2004 na 3940 (bbp)

Dla niekumatych szybkie obja?nienie:
[LUA]elseif msgcontains(msg, 'goldbphmm') and focus == cid then
BuyContainer(cid,2311,100,20000,2004)
talk_start = os.clock() [/LUA]

2311 - ID runy
100 - Liczba u?y? runy
20000 - Cena w GP
2004 - ID backpacka/worka/parcela lub czegokolwiek w co mo?emy co? wk?ada?
 
L

luksky

Guest
Odp: [7.6] BuyContainer System

A nie lepiej sobie po prostu lua dopisa???
modules.lua, dopisa? doPlayerBuyItemContainer w global.lua i z g?owy
Code:
shopModule:addBuyableItemContainer
 

God Keno

Banned
Joined
Jul 17, 2014
Messages
260
Reaction score
9
Odp: [7.6] BuyContainer System

Tylko ze to jest 7.6 i tam nie ma takich plik?w.
 
L

luksky

Guest
Odp: [7.6] BuyContainer System

Tylko ze to jest 7.6 i tam nie ma takich plik?w.
W czym problem? To lua, mo?esz przecie? u?y? dofile, a funkcje w lua zadeklarowa? nowe.
No i druga sprawa, nie ma sensu u?ywa? starych dziurawych dystrybucji.
Chwile po?wi?ci? i zrobi? downgrade tfs do 7.6.
 
Last edited:

#NOOB

Senior User
Joined
May 25, 2014
Messages
901
Reaction score
89
Odp: [7.6] BuyContainer System

Wrzuc jeszcze auto reborn system ;p

Co do kodu to przydatny, jednak przydala by sie tez opcja ze mozemy kupowac np kilka bp na raz (przykladowo: hi, 10 bp sd, bye), nwm czy taka opcja jest tutaj.

#up
No kentana 3.2 raczej taka stara nie jest. Chociaz... co ja tam wiem ; /
 
Status
Not open for further replies.
Top