What's new

Quest System

Status
Not open for further replies.

Pearl

Active User
Joined
May 18, 2008
Messages
71
Reaction score
6
M?j system polega na tym, ?e wpisujemy do tabeli item UID (skrzynki),
wybieramy ilo?? w tabeli count,
od kt?rego poziomu mo?na wzi?? nagrod? level,
ID itemu (nagrody) w tabeli itemid,
EXP w nagrode tabela expierence
oraz storage co do storage mo?na zrobi? np. 3 skrzynki i jeden storage!

Pami?taj ?adna tabela nie mo?e by? pusta!
Jak dodawa? przyk?ady do tabeli?
Do ostatniej linijki dodajemy "," (przecinek)
i wklejamy [1000] = 1
1000 - Unique ID Skrzynki,
1 - w zale?no?ci od tabeli :
Count - Ilo?? Przedmiot?w (nagroda)
Level - Od kt?rego poziomu mo?na bra? nagrod?
Itemid - ID Itemu (nagrody)
StorageId - Storage Value (moze byc kilka tych samych lecz mo?na wzi?? jedna nagrod?!)
Expierence - PKT Expa w nagrod?.

Przyk?ady :
Code:
local count = {
[1000] = 25,
[1001] = 10
}
local level = {
[1000] = 8,
[1001] = 10
}
local itemid = {
[1000] = 2160,
[1001] = 2152
}
local storageid = {
[1000] = 10001,
[1001] = 10002 
}
local expierence = {
[1000] = 100,
[1001] = 75
}

Skrypt :

W Actions/Scripts/Quests/ tworzymy plik pearl_system.lua

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local count = {
[1000] = 1
}
local level = {
[1000] = 8
}
local itemid = {
[1000] = 10001
}
local storageid = {
[1000] = 10001
}
local expierence = {
[1000] = 100
}

local exp = expierence[item.uid]
local storage = storageid[item.uid]
local queststatus = getPlayerStorageValue(cid, storage)
local itemid = itemid[item.uid]
local count = count[item.uid]
local itemname = getItemNameById(itemid)
local needlvl = level[item.uid]
local need = "You must have ".. needlvl .." level to get reward."
local found_one = "You have found ".. itemname .."."
local found_more = "You have found ".. count .." of ".. itemname .."."
local empty = "This ".. getItemNameById(item.itemid) .." is empty."
	if queststatus == -1 and getPlayerLevel(cid) >= needlvl and count == 1 then
			doPlayerSetStorageValue(cid, storage, 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, found_one)
			doPlayerAddItem(cid, itemid, count)
			doPlayerAddExp(cid, exp)
			doSendAnimatedText(getCreaturePosition(cid), exp, TEXTCOLOR_WHITE)
			return TRUE
	elseif queststatus == -1 and getPlayerLevel(cid) >= needlvl and count > 1 then
			doPlayerSetStorageValue(cid, storage, 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, found_more)
			doPlayerAddItem(cid, itemid, count)
			doPlayerAddExp(cid, exp)
			doSendAnimatedText(getCreaturePosition(cid), exp, TEXTCOLOR_WHITE)
			return TRUE
	elseif getPlayerLevel(cid) < needlvl then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, need)
	elseif queststatus > 0 then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, empty)
end
		return TRUE
end

W actions.xml

Code:
<action actionid="1000" script="quests/pearl_system.lua" />

Jak dodawa? questy na mape?
Robimy np. skrzynke, nadajemy mu AID (action id) 1000 oraz UID (unique id) JAKIE CHCEMY!
Oraz dodajemy do tabeli :)


@ Wersja 2 (Skr?cona)
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local quest = {
[5908] = {3, 2160, 1000, 1000} --count, itemid, storageid, experience
}

local storage = quest[item.uid][4]
local queststatus = getPlayerStorageValue(cid, storage)
if queststatus > 0 then
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This ".. getItemNameById(item.itemid) .." is empty.")
	end
	
local storage = quest[item.uid][3]
local queststatus = getPlayerStorageValue(cid, storage)
local exp = quest[item.uid][4]
local itemid = quest[item.uid][2]
local count = quest[item.uid][1]
local itemname = getItemNameById(itemid)
if queststatus == -1 and count == 1 then
	doPlayerSetStorageValue(cid, storage, 1)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found ".. itemname ..".")
	doPlayerAddItem(cid, itemid, count)
	doPlayerAddExp(cid, exp)
	doSendAnimatedText(getCreaturePosition(cid), exp, TEXTCOLOR_WHITE)
elseif queststatus == -1 and count > 1 then
	doPlayerSetStorageValue(cid, storage, 1)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found ".. count .." of ".. itemname ..".")
	doPlayerAddItem(cid, itemid, count)
	doPlayerAddExp(cid, exp)
	doSendAnimatedText(getCreaturePosition(cid), exp, TEXTCOLOR_WHITE)
	end
return TRUE
end
Wszystkie b??dy zg?asza?!
 

Damain1996

Active User
Joined
Jun 7, 2009
Messages
118
Reaction score
9
Odp: Quest System

( Pierwszy:rolleyes: ) Noo widz? ?e skrypt bardzo fajny! Na pewno mi si? przyda :) Leci reput, i ocena tematu 5/5 ;)
Pozdrawiam, Damian.
 
T

Tairens

Guest
Odp: Quest System

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local quest = 
{
[1000] = {1, 8, 10001, 10001, 100} --count, level, itemid, storageid, experience
}
local exp = quest[item.uid][5]
local itemid = quest[item.uid][3]
local needlvl = quest[item.uid][2]
	if (getPlayerLevel(cid) < needlvl) then
		local need = "You must have ".. needlvl .." level to get reward."
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, need)
		return true
	end
	local storage = quest[item.uid][4]
	local queststatus = getPlayerStorageValue(cid, storage)
	if (queststatus > 0) then
		local empty = "This ".. getItemNameById(item.itemid) .." is empty."
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, empty)
		return true
	end
	local count = quest[item.uid][1]
	local itemname = getItemNameById(itemid)
	if (count <= 1) then
		local found_one = "You have found ".. itemname .."."
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, found_one)
	elseif (count > 1) then
		local found_more = "You have found ".. count .." of ".. itemname .."."
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, found_more)
	end
	doSendAnimatedText(getCreaturePosition(cid), ''..exp..'', TEXTCOLOR_WHITE)
	setPlayerStorageValue(cid, storage, 1)
	doPlayerAddItem(cid, itemid, count)
return true
end

Zrobi?e? konkretny syf w kodzie. Do tego pi?? tablic, to naprawd? sporo...
Niepotrzebne instrukcje, sprawdzasz a? trzy razy czy level jest ok i czy quest status
si? zgadza, nazwa?bym to piramidaln? g?upot?.
 
Last edited:

Pearl

Active User
Joined
May 18, 2008
Messages
71
Reaction score
6
@UP
Mo?e troche zapl?ta?em ale to twoje "cudo" nie dzia?a :)

Code:
system.lua:6: attempt to index global 'expierence' (a nil value)
Code:
local exp = expierence[item.uid][5]
Gdzie masz tabele Expierence?

/edit

Po wszystkich "ifach" i "else" nie dawaj
Code:
doSendAnimatedText(getCreaturePosition(cid), ''..exp..'', TEXTCOLOR_WHITE)
Poniewa? ca?y czas po naci?ni?ciu skrzynki b?dzie ci si? to wy?wietla?!

/edit2

Gdzie da?e? funkcje odpowiedzialn? za dodawanie EXPa bo nie widz??

@topic

Skr?cona wersja (by me :))
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local quest = {
[5908] = {3, 2160, 1000, 1000} --count, itemid, storageid, experience
}

local storage = quest[item.uid][4]
local queststatus = getPlayerStorageValue(cid, storage)
if queststatus > 0 then
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This ".. getItemNameById(item.itemid) .." is empty.")
    end
    
local storage = quest[item.uid][3]
local queststatus = getPlayerStorageValue(cid, storage)
local exp = quest[item.uid][4]
local itemid = quest[item.uid][2]
local count = quest[item.uid][1]
local itemname = getItemNameById(itemid)
if queststatus == -1 and count == 1 then
    doPlayerSetStorageValue(cid, storage, 1)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found ".. itemname ..".")
    doPlayerAddItem(cid, itemid, count)
    doPlayerAddExp(cid, exp)
    doSendAnimatedText(getCreaturePosition(cid), exp, TEXTCOLOR_WHITE)
elseif queststatus == -1 and count > 1 then
    doPlayerSetStorageValue(cid, storage, 1)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found ".. count .." of ".. itemname ..".")
    doPlayerAddItem(cid, itemid, count)
    doPlayerAddExp(cid, exp)
    doSendAnimatedText(getCreaturePosition(cid), exp, TEXTCOLOR_WHITE)
    end
return TRUE
end
Lecz w niej na razie nie ma opcji level :(

@Down
Thanks: )
Moja wersja (2) i tak dzia?a :p

Notka moderatorska:
Edytuj posty ;>
 
Last edited by a moderator:
R

Rahim

Guest
Odp: Quest System

Mo?e to?
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local quest = 
    {
        [1000] = {1, 8, 10001, 10001, 100} --count, level, itemid, storageid, experience
    }
    local tbl = quest[item.uid]
    if(not tbl) then
        return false
    end
    if(getPlayerLevel(cid) < tbl[2]) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have too low level! Come back if you recive " .. tbl[2] .. " level.")
        return true
    end
    if(getPlayerStorageValue(cid, tbl[4]) == 1) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This is empty!")
        return true
    end
    local item = doPlayerAddItem(cid, tbl[3], tbl[1])
    local text = "You have found " .. tbl[1] == 1 and getArticle(item.itemid) or tbl[1] .. " " .. getItemName(item.itemid)
    if(tbl[5]) then
        doPlayerAddExperience(cid, tbl[5])
        doSendAnimatedText(fromPosition, tbl[5], TEXTCOLOR_WHITE)
        text = " and you have recive " .. tbl[5] .. " experience points"
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text .. ".")
    setPlayerStorageValue(cid, tbl[4], 1)
    return true
end
 

ChaosVego

User
Joined
Jul 14, 2009
Messages
36
Reaction score
3
Age
29
Odp: Quest System

Dzieki fajny i przydatny Skrypcik musia?e? sie nad nim duzo napracowac bo naprawde jest fajny:)
 

misza0007

New User
Joined
Aug 19, 2009
Messages
8
Reaction score
0
Odp: Quest System

Dzieki wielki wlasnie tego mi brakowalo w moim ots przyda sie napewno.:D
 
Status
Not open for further replies.
Top