#1 2009-01-29 19:19:12

Roki Alth

Moderator

Zarejestrowany: 2009-01-29
Posty: 11
Punktów :   

Pokeballs!

Na pocz±tku dodajemy do folderu:
data/action/script/pokeball.lua

Spoiler:

local notAllowed = {"czego nie mozna lapac np. Slime", "czego nie mozna lapac np. Demon"}
local storage = {
    status = 25650,
    pokeName = 25651
}
local actionid_used = 7510

function onUse(cid, item, fromPos, item2, toPos)
    local pokeballStatus = getPlayerStorageValue(cid, storage.status)
    local pokeName = getPlayerStorageString(cid, storage.pokeName)
    pos = getPlayerPosition(cid) pos.stackpos = 0
    if getTilePzInfo(toPos) == 0 and getTilePzInfo(pos) == 0 then
        if pokeballStatus == -1 then
            toPos.stackpos = 253
            local pokeThing = getThingfromPos(toPos)
            if isCreature(pokeThing.uid) == TRUE then
                if isPlayer(pokeThing.uid) == FALSE then
                    local pokename_ = getCreatureName(pokeThing.uid)
                    if item.actionid ~= actionid_used then
                    --    local maxHealth = 400
                    --    local creatureHealth = getCreatureHealth(pokeThing.uid)
                    --    local divNum = (string.len(maxHealth)-1)^2
                    --    local result = math.floor((creatureHealth/divNum)/10)
                    --    local chance = math.random(1, math.random(4, math.random(7, math.max(result, 7))))
                    --    if chance == result then
                            if isInTable(notAllowed, pokename_) == TRUE then
                                doPlayerSendCancel(cid, "Nie mozesz tego lapac!")
                            else
                                setPlayerStorageString(cid, storage.pokeName, pokename_)
                                doRemoveCreature(pokeThing.uid)
                                doSendDistanceShoot(fromPos, toPos, 37)
                                setPlayerStorageValue(cid, storage.status, 1)
                                doSetItemSpecialDescription(item.uid, "To zawiera " .. pokename_ .. ".")
                                doSetItemActionId(item.uid, actionid_used)
                            end
                    --    else
                    --        doSendMagicEffect(fromPos, 2)
                    --        doPlayerSendCancel(cid, "Pokemon wolny!")
                    --    end
                    elseif item.actionid == actionid_used and pokename_  == pokeName then
                        doPlayerSay(cid, pokeName .. " WRACAJ!", TALKTYPE_SAY)
                        doRemoveCreature(pokeThing.uid)
                        doSetItemSpecialDescription(item.uid, "To zawiera " .. pokename_ .. ".")
                        setPlayerStorageValue(cid, storage.status, 1)
                        doSendDistanceShoot(fromPos, toPos, 37)
                    else
                        doSendMagicEffect(fromPos, 2)
                        doPlayerSendCancel(cid, "Ten pokeball jest uzywany!")
                    end
                else
                    doPlayerSendCancel(cid, "Nie mozesz tego lapac!")
                end
            else
                doPlayerSendCancel(cid, "Nie ma takiego potwora!")
            end
        elseif pokeballStatus == 1 then
            summons = getCreatureSummons(cid)
        --    if #summons >= 2 then
        --        doPlayerSendCancel(cid, "Nie mozesz przyzwac wiecej pokemonow")
        --    else
                doConvinceSummon(cid, pokeName, 0, toPos)
                doSendDistanceShoot(fromPos, toPos, 37)
                doPlayerSay(cid, pokeName .. " IDZ!", TALKTYPE_SAY)
                setPlayerStorageValue(cid, storage.status, -1)
                doSetItemSpecialDescription(item.uid, "Jest pusty.")
        --    end
        end
    else
        doPlayerSendCancel(cid, "Nie mozesz tego uzyc w PZ.")
    end
    return 1
end

function isInTable(t, val)
    for _, v in pairs(t) do
        if v == val then
            return TRUE
        end
    end
    return LUA_ERROR
end

Nastêpnie do folderu:
data/action/actions.xml dodajemy:

Spoiler:

<action itemid="ID Pokeball'a" script="pokeball.lua" allowfaruse="1" blockwalls="1" />

Ale pamietaj!Pokeball musi byc rzecza ktora mozna uzyc "with crosshair"!
Np.2152-Talon


Aha...

Dodaj do global.lua:

Kod:

function getPlayerStorageString(cid, key)
    if key > _warpzone / _maxlength then
        error("Storage string key is too large (" .. key .. ")")
    end
    key = _warpzone + key * _maxlength
 
    local wordcount = 0
    local str = ""
    while true do
        if wordcount >= _maxlength then
            break
        end
        local word = getPlayerStorageInteger(cid, key + wordcount)
        if word == -1 then
            -- end of string
            break
        else 
            byte = bit.band(word, 255)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 65280), 8)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 16711680), 16)
            if byte == 0 then break else str = str .. string.char(byte) end
        end
        wordcount = wordcount + 1
    end
    return str
end  



function doConvinceSummon(cid, creature, amount, pos)
summonplayerpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)


    if(summonplayer ~= nil and summonplayer.itemid > 0) then    
        doPlayerSendCancel(cid,"There is not enough room to summon here.")
        ret = 0
    else
        convince = doSummonCreature(creature, pos)
        doConvinceCreature(cid, convince)
        ret = 1
end

        return ret
end

Offline

 

#2 2009-01-30 04:57:35

Xardass92

Administrator

SkÄ…d: Wolbrom /k.Krakowa
Zarejestrowany: 2008-04-12
Posty: 31
Punktów :   
WWW

Re: Pokeballs!

Mowiac "use with crosshair" myslisz o hotkeyu czy o "use with"??
Ja robie grafike do tego
Edit: mam juz grafike

http://img516.imageshack.us/img516/347/pokeballif2.png lub http://img217.imageshack.us/img217/1741/pokeball2bq4.png


http://signatures.otservlist.org/715666_4.png http://ots-list.org/signature/50373/1

http://img261.imageshack.us/img261/971/bannerll5.png

Offline

 

#3 2009-01-30 07:38:31

Xardass92

Administrator

SkÄ…d: Wolbrom /k.Krakowa
Zarejestrowany: 2008-04-12
Posty: 31
Punktów :   
WWW

Re: Pokeballs!

Nie wiem czy chodzilo ci o to:

http://img142.imageshack.us/img142/4493/beztytuujq4.png


Jesli tak to mam problem bo jak daje "use with..." i na potworka to w konsoli wywala mi cos takiego:

http://img299.imageshack.us/img299/3500/beztytuu1wk1.png


http://signatures.otservlist.org/715666_4.png http://ots-list.org/signature/50373/1

http://img261.imageshack.us/img261/971/bannerll5.png

Offline

 

#4 2009-01-30 11:58:02

Roki Alth

Moderator

Zarejestrowany: 2009-01-29
Posty: 11
Punktów :   

Re: Pokeballs!

Chodzi³o mi o "use with", a b³±d wywala bo nie masz takiej funkcji

Zaraz j± dam:

Dodaj do global.lua:

Kod:

function getPlayerStorageString(cid, key)
    if key > _warpzone / _maxlength then
        error("Storage string key is too large (" .. key .. ")")
    end
    key = _warpzone + key * _maxlength
 
    local wordcount = 0
    local str = ""
    while true do
        if wordcount >= _maxlength then
            break
        end
        local word = getPlayerStorageInteger(cid, key + wordcount)
        if word == -1 then
            -- end of string
            break
        else 
            byte = bit.band(word, 255)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 65280), 8)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 16711680), 16)
            if byte == 0 then break else str = str .. string.char(byte) end
        end
        wordcount = wordcount + 1
    end
    return str
end  



function doConvinceSummon(cid, creature, amount, pos)
summonplayerpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)


    if(summonplayer ~= nil and summonplayer.itemid > 0) then    
        doPlayerSendCancel(cid,"There is not enough room to summon here.")
        ret = 0
    else
        convince = doSummonCreature(creature, pos)
        doConvinceCreature(cid, convince)
        ret = 1
end

        return ret
end

Offline

 

#5 2009-01-30 12:02:58

Xardass92

Administrator

SkÄ…d: Wolbrom /k.Krakowa
Zarejestrowany: 2008-04-12
Posty: 31
Punktów :   
WWW

Re: Pokeballs!

ok, dzieki zaraz wstawie w otsa

Edit: teraz wywala cos takiego:
http://img217.imageshack.us/img217/8969/beztytuugg6.png

"_warpzone" wywala mi w kazdym miejscu ;(


http://signatures.otservlist.org/715666_4.png http://ots-list.org/signature/50373/1

http://img261.imageshack.us/img261/971/bannerll5.png

Offline

 

#6 2009-01-30 12:18:36

Roki Alth

Moderator

Zarejestrowany: 2009-01-29
Posty: 11
Punktów :   

Re: Pokeballs!

A teraz, zamieñ to stare w global.lua na to:

Kod:

function getPlayerStorageString(cid, key)
    if key > warpzone / maxlength then
        error("Storage string key is too large (" .. key .. ")")
    end
    key = warpzone + key * maxlength
 
    local wordcount = 0
    local str = ""
    while true do
        if wordcount >= maxlength then
            break
        end
        local word = getPlayerStorageInteger(cid, key + wordcount)
        if word == -1 then
            break
        else 
            byte = bit.band(word, 255)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 65280), 8)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 16711680), 16)
            if byte == 0 then break else str = str .. string.char(byte) end
        end
        wordcount = wordcount + 1
    end
    return str
end  



function doConvinceSummon(cid, creature, amount, pos)
summonplayerpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)


    if(summonplayer ~= nil and summonplayer.itemid > 0) then    
        doPlayerSendCancel(cid,"There is not enough room to summon here.")
        ret = 0
    else
        convince = doSummonCreature(creature, pos)
        doConvinceCreature(cid, convince)
        ret = 1
end

        return ret
end

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi

[ Generated in 0.024 seconds, 8 queries executed ]


Darmowe Forum | Ciekawe Fora | Darmowe Fora
www.polish-elite-clan.pun.pl www.promotyle.pun.pl www.wms4.pun.pl www.drakenmag.pun.pl www.narutoxgierka.pun.pl