
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:
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
endOffline
Chodziło mi o "use with", a błąd wywala bo nie masz takiej funkcji
Zaraz ją dam:
Dodaj do global.lua:
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
endOffline
A teraz, zamień to stare w global.lua na to:
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
endOffline