What's new

Actions Random Present Bag.

Status
Not open for further replies.

Qermo

Advanced User
Joined
Aug 22, 2009
Messages
227
Reaction score
34
Witam chcia?bym prosi? kogo? ogarni?tego o taki w?a?nie scrypt.
Osoba kt?ra kliknie na bag o ID 10503 mo?e wylosowa? dany item.
 

Kikimora24

Advanced User
Joined
Mar 18, 2013
Messages
246
Reaction score
29
Odp: Random Present Bag.

Kod
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local items = {id, id, id}
	doPlayerAddItem(cid, items[math.random(1,#items)], 1)
	doRemoveItem(10503, 1)
return true
end
 

Qermo

Advanced User
Joined
Aug 22, 2009
Messages
227
Reaction score
34
Odp: Random Present Bag.

Hehe , dzi?ki ale to mi za wiele nie m?wi. Wiem jestem ........................
 

Kikimora24

Advanced User
Joined
Mar 18, 2013
Messages
246
Reaction score
29
Odp: Random Present Bag.

Do actions.xml w folderze actions dajesz ta linijke:
<action itemid="10503" event="script" value="random.lua"/>

Kod ktory podalem wczesniej wklejasz do pliku random.lua w folderze actions/scripts/
Na serwerze reload actions lub restart serwera i dziala.

Generalnie skrypty zaleznie od funkcji wklejasz do actions jesli czegos uzywasz, movements jesli cos ruszasz, zakladasz lub na cos wchodzisz, talkaction jesli uzywasz komendy, creaturescripts jesli cos dotyczy konkretnej kreatury lub globalevents jesli jest ogolnie wykonywane na serwerze...
Wszedzie ta sama zasada. Linijka ktora deklaruje skrypt w pliku xml, a w folderze scripts plik ze skryptem.
 

Qermo

Advanced User
Joined
Aug 22, 2009
Messages
227
Reaction score
34
Odp: Random Present Bag.

Dzi?ki Kikimora.
Ale mam jeszcze jeden problem ot?? po klikni?ciu na bag , item sie pojawia ale bag ju? nie znika i mo?na klika? na niego do usranej ?mierci..
 

Kikimora24

Advanced User
Joined
Mar 18, 2013
Messages
246
Reaction score
29
Odp: Random Present Bag.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local items = {id, id, id}
	if(item.itemid == 10503) then
	doPlayerAddItem(cid, items[math.random(1,#items)], 1)
	doRemoveItem(item.uid, 1)
end
return true
end
 

Qermo

Advanced User
Joined
Aug 22, 2009
Messages
227
Reaction score
34
Odp: Random Present Bag.

Bag dalej sypie itemami.. ;/

---Aktualizacja---

Okey zrobione. Wielkie dzi?ki Kiki.. ;)
 
Z

Zbizu

Guest
Odp: Random Present Bag.

surprisebag.lua z TFSa(u mnie dzia?a):

<action fromid="6570" toid="6571" event="script" value="other/surprisebag.lua"/>

Code:
local PRESENT_BLUE = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
local PRESENT_RED = {2152, 2152, 2152, 2153, 5944, 2112, 6568, 6566, 2492, 2520, 2195, 2114, 2114, 2114, 6394, 6394, 6576, 6576, 6578, 6578, 6574, 6574}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local count = 1
    if(item.itemid == 6570) then
        local randomChance = math.random(1, #PRESENT_BLUE)
        if(randomChance == 1) then
            count = 10
        elseif(randomChance == 2) then
            count = 3
        end
        doPlayerAddItem(cid, PRESENT_BLUE[randomChance], count)
    elseif(item.itemid == 6571) then
        local randomChance = math.random(1, #PRESENT_RED)
        if randomChance > 0 and randomChance < 4 then
            count = 10
        end
        doPlayerAddItem(cid, PRESENT_RED[randomChance], count)
    end

    doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
    doRemoveItem(item.uid, 1)
    return true
end
 
Status
Not open for further replies.
Top