Skrypty & Kody Hunting arena problem

Status
Zamknięty.

maxassasin

User
Zarejestrowany
Dołączył
Kwiecień 15, 2012
Posty
33
Liczba reakcji
1
Witam chcia? bym poprosi? o wasz? pomoc ot?? mam skrypt na hunting arene i chcia? bym do niego doda? aby liczy? czas tzn. je?li kto? jest ju? w roomie i nastepna osoba wchodzi w teleport to wyskakuje komunikat np. "Kto? jest ju? w roomie poczekaj 500 sekund,499 sekund 488 sekund i tak dalej ? Pomo?ecie a oto i skrypt :
function onStepIn(cid, item, pos, fromPosition)
local storage_global = 16565
if getGlobalStorageValue(storage_global) == -1 then
doPlayerSendTextMessage(cid, 25, 'Wszedles na 10 minut do pomieszczenia')
setGlobalStorageValue(storage_global, 1)
doTeleportThing(cid, {x=1122, y=1020, z=7})
return addEvent(function()
if isPlayer(cid) and getGlobalStorageValue(storage_global) == 1 then
doTeleportThing(cid, {x=1124, y=1026, z=7})
doPlayerSendTextMessage(cid, 25, 'Czas minal')
return setGlobalStorageValue(storage_global, -1)
end end,
10 * 60 * 1000,
cid, storage_global)
else
doTeleportThing(cid, fromPosition)
return doPlayerSendTextMessage(cid, 25, 'Ktos juz sie znajduje w roomie')
end
return true
end
 
Odp: Hunting arena problem

Kod:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="HuntArea System" version="Tested only on 0.4" author="Hugq" contact="hugq16@gmail.com" enabled="yes">
<config name="HuntAreaFunctions"><![CDATA[
config = {
    -- Teleport AID = v[1], v[2], v[3], v[4], v[5], v[6], v[7] ;]
    [10001] = {{x = 1018, y = 1020, z = 7}, {x = 1019, y = 1018, z = 7}, {x = 1019, y = 1023, z = 7}, 10, 8, 2, 2},
    [10002] = {{x = 1026, y = 1020, z = 7}, {x = 1027, y = 1018, z = 7}, {x = 1027, y = 1023, z = 7}, 10, 8, 2, 2}
}
monsters = {
    -- Tile AID = b[1], b[2] ;]
    [10201] = {"Dragon Lord", {x = 1021, y = 1020, z = 7}},
    [10202] = {"Frost Dragon", {x = 1029, y = 1020, z = 7}}
}
function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers, showSummons)
    local creaturesList = {}
    for x = -radiusx, radiusx do
        for y = -radiusy, radiusy do
            if not (x == 0 and y == 0) then
                local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
                if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
                    table.insert(creaturesList, creature.uid)
                end
            end
        end
    end
    local creature = getTopCreature(position)
    if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
        if not(table.find(creaturesList, creature.uid)) then
            table.insert(creaturesList, creature.uid)
        end
    end
        return creaturesList
end
]]></config>
<movevent type="StepIn" actionid="10001-10002" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
local v = config[item.actionid]
function kickEvent(cid, item, position, fromPosition)
    if (getCreaturesInRange(v[2], v[6], v[7], FALSE, TRUE) ~= 0 and getCreatureStorage(cid, 654321) > 0) then
            doTeleportThing(cid, v[3])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
            doCreatureSetStorage(cid, 654321, -1)
        doCreatureSay(cid, "You have been kicked out from hunting room.", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
    end
end
    if getPlayerLevel(cid) >= v[5] then
        if(getPlayerItemCount(cid, 2157) > 0) then
        local players = getCreaturesInRange(v[2], v[6], v[7], FALSE, TRUE)
            if #players == 0 then
            local creatures = getCreaturesInRange(v[2], v[6], v[7], TRUE, FALSE)
                for i = 1, #creatures do
                    doRemoveCreature(creatures[i])
                end
                doSendMagicEffect(position, CONST_ME_TELEPORT)
                doTeleportThing(cid, v[1])
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doPlayerRemoveItem(cid, 2157, 1)
                doCreatureSay(cid, "Now you have " .. v[4] .. " minutes for hunting monsters, else you will be kicked out.", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
                pauseKick = addEvent(kickEvent, v[4] * 60 * 1000, cid)
                doCreatureSetStorage(cid, 654321, 1)
                return TRUE
            else
                doCreatureSay(cid, "There is someone else in the room.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
            end
        else
            doCreatureSay(cid, "You don't have enought golden nugget.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
        end
        else
            doCreatureSay(cid, "You must be at least level " .. v[5] .. " or higher to enter.", TALKTYPE_ORANGE_1, false, cid, fromPosition)
    end
    doTeleportThing(cid, fromPosition)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    return TRUE
end
]]></movevent>
<movevent type="StepIn" actionid="10101-10102" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            doCreatureSetStorage(cid, 654321, -1)
        stopEvent(pauseKick)
    end
end]]></movevent>
<movevent type="StepIn" actionid="10201-10202" event="script"><![CDATA[
    domodlib('HuntAreaFunctions')
function onStepIn(cid, item, position, fromPosition)
    local b = monsters[item.actionid]
    if(isPlayer(cid) and exhaustion.check(cid, item.actionid)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You should wait " .. exhaustion.get(cid, item.actionid) .. " seconds.")
    elseif (isPlayer(cid)) then
        exhaustion.set(cid, item.actionid, 10)
            doSummonCreature(b[1], b[2])
        doSendMagicEffect(b[2], CONST_ME_TELEPORT)
    end
end]]></movevent>
</mod>
Spr?buj tego.
 
Odp: Hunting arena problem

@up
ten skrypt ma wi?cej bug?w i niedor?bek ni? m?j pierwszy bot w c++... Poleca? bym raczej skrypt od Oskara albo jaki? p?atny
 
Odp: Hunting arena problem

Ja wol? jednak ten co mam teraz ale chcia? bym do niego doda? aby pokazywa?o czas jak kto? chce wej?? do roomu pomo?ecie ? co trzeba doda? do tego skryptu ?e by to chodzi?o prosz? o pomoc dam reputa
 
Odp: Hunting arena problem

@Dubler
niby ma ale kilka dni temu napisa?em na jego podstawie w?asny bez bug?w

@max~
je?li znasz podstawy lua prze?b sobie ten przyk?ad na swoje potrzeby, wej?cie do areny demodras.lua:
Kod:
local spawnboss = {x=66,y=490,z=8}
local spawnplayer = {x=68,y=483,z=8}
local NWcorner = {x=60,y=481,z=8, stackpos = 255}
local SEcorner = {x=76,y=494,z=8, stackpos = 255}
local deny = {x=311, y=403, z=12}

local storage = {65030,2} -- storage required to enter
local keyafter = -1 -- key that will be set to storage above when player enters arena
local boss = "demodras"
local fighttime = 10 * 60 * 1000 -- ten minutes
local delayglobal = 95001 -- enterance counter storage returning remaining time of current user

function getCreaturesInQuestArea(type, fromPos, toPos, get, countSummon)
 
    local types = 
    {
        [TYPE_PLAYER] = isPlayer,
        [TYPE_MONSTER] = isMonster,
        [TYPE_NPC] = isNpc,
        [TYPE_ALL] = isCreature
    }
 
    local tmp = {}
    local t = types[type]
    if not t then
        return print("[!] --> [Warning - Function::getCreaturesInQuestArea] Unknown type " .. (type or "(nil value)"))
    end
 
    local thing
    local pos
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                pos = {x = x, y = y, z = z}
                thing = getTopCreature(pos)
                if t(thing.uid) then
                    table.insert(tmp, thing.uid)
                    if not countSummon and isSummon(thing.uid) then
                        for i = 1, #tmp do
                            if tmp[i] == thing.uid then
                                table.remove(tmp, i)
                                break
                            end
                        end
                    end
                end
            end
        end
    end
    return (get == GET_COUNT and #tmp or get == GET_UID and tmp or print("[Warning - Function::getCreaturesInQuestArea] Unknown type to get " .. (get or "(nil value)")))
end

function kickEvent1(cid, item, position, fromPosition)
    if getCreaturesInQuestArea(TYPE_PLAYER, NWcorner, SEcorner, GET_COUNT) > 0 then
        doTeleportThing(cid, deny)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        doCreatureSay(cid, "Time up. Your chance is over.", TALKTYPE_ORANGE_1)
    end
end

function onStepIn(cid, item, pos)
    if getPlayerStorageValue (cid, storage[1]) == storage[2] then
        if getCreaturesInQuestArea(TYPE_PLAYER, NWcorner, SEcorner, GET_COUNT) > 0 then
            doTeleportThing(cid,deny)
            doCreatureSay(cid, 'Someone is still in this room. Please wait for your turn(max ' .. getGlobalStorageValue(delayglobal)-os.time() .. ' seconds left).', TALKTYPE_ORANGE_1)
            doSendMagicEffect(getThingPos(cid), CONST_ME_FIREAREA)
        else
            doTeleportThing(cid,spawnplayer)
            doSendMagicEffect(getCreaturePosition(cid),CONST_ME_FIREAREA)
            doSendMagicEffect(getCreaturePosition(cid),10)
            doCreatureSay(cid, 'You have ten minutes to slain your enemy, otherwise you will be kicked out.', TALKTYPE_ORANGE_1)
            setGlobalStorageValue(delayglobal, os.time() + (fighttime / 1000))
            setPlayerStorageValue(cid,storage[1],keyafter)
            doSummonCreature(boss, spawnboss)
            demodras = addEvent(kickEvent1, fighttime, cid)
        end
    else
        doTeleportThing(cid,deny)
        doCreatureSay(cid, 'You are not allowed to enter here!', TALKTYPE_ORANGE_1)
        doSendMagicEffect(getThingPos(cid), CONST_ME_FIREAREA)
    end
    doSendMagicEffect(getThingPos(item.uid), CONST_ME_PURPLEENERGY)
    return true
end

wyj?cie dla wszystkich aren exit.lua zatrzymuj?ce licznik:
Kod:
function onStepIn(cid, item, pos)

aid = {
            [17050] = {x=311, y=403, z=12, boss=demodras},
            [17051] = {x=311, y=399, z=12, boss=leviathan},
            [17052] = {x=313, y=401, z=12, boss=snapper},
            [17053] = {x=313, y=401, z=12, boss=hide},
            [17054] = {x=313, y=401, z=12, boss=bloodtusk},
            [17055] = {x=313, y=401, z=12, boss=shardhead},
            [17056] = {x=313, y=401, z=12, boss=thul},
            [17057] = {x=313, y=401, z=12, boss=esmeralda},
            [17058] = {x=311, y=403, z=12, boss=oldwidow},
            [17059] = {x=311, y=399, z=12, boss=themany},
            [17060] = {x=311, y=399, z=12, boss=stonecracker},
            [17061] = {x=311, y=399, z=12, boss=nox},
            [17062] = {x=311, y=399, z=12, boss=pirate},
            [17063] = {x=311, y=403, z=12, boss=fox},
            [17064] = {x=313, y=401, z=12, boss=necro}
        }
entry = aid[item.actionid]
pos1 = {x=entry.x, y=entry.y, z=entry.z}    

doTeleportThing(cid,pos1)
doCreatureSay(cid, 'You have left the arena. Now you may begin this task again.', TALKTYPE_ORANGE_1)
stopEvent(entry.boss)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
    return true
end
 
Ostatnia edycja:
Odp: Hunting arena problem

Pr?bowa?em i czas mi si? wy?wietla ale np. tak : 11:43 Someone is still in this room. Please wait for your turn(min -1367055813 seconds left). Co? jest nie tak z czasem bo idzie nawet do przodu zamiast si? zmniejsza? jak to poprawi? ?
 
Ostatnia edycja:
Odp: Hunting arena problem

musia?e? co? ?le podstawi?, teleport zrobi?e? postawiony w arenie albo nie doda?e? tego w momencie wpuszczenia gracza na aren?:
setGlobalStorageValue(delayglobal, os.time() + (fighttime / 1000))
 
Ostatnia edycja:
Odp: Hunting arena problem

Tak wygl?da m?j skrypt :
function onStepIn(cid, item, pos, fromPosition)
local storage_global = 16565
local center = {x=1124, y=1021, z=7} -- srodek hunting roomu
local inX = 3 -- ile kratek jest w prawo i w lewo musi byc tyle samo
local inY = 3 -- ile kratek jest w gore i w dol musi byc tyle samo
if getGlobalStorageValue(storage_global) == -1 then
if getSpectators(center, inX, inY) ~= nil then
for _, tid in ipairs(getSpectators(center, inX, inY)) do
doRemoveCreature(tid)
end
end
doPlayerSendTextMessage(cid, 25, 'Wszedles na 5 minut do pomieszczenia')
setGlobalStorageValue(storage_global, 1)
doTeleportThing(cid, {x=1122, y=1020, z=7})
return addEvent(function()
if isPlayer(cid) and getGlobalStorageValue(storage_global) == 1 then
doTeleportThing(cid, {x=1124, y=1026, z=7})
doPlayerSendTextMessage(cid, 25, 'Czas minal')
return setGlobalStorageValue(storage_global, -1)
end end,
5*60*1000,
cid, storage_global)
else
doTeleportThing(cid, fromPosition)
doPlayerSendTextMessage(cid,22,'Musisz poczkeac '..getStorage(storage1)-os.time()..' sekund.')
end
return true
end

gdzie jest b??d ?
 
Status
Zamknięty.
Back
Do góry