• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Liczenie graczy na jednej kratce ?

TracerS

New Member
Joined
Jan 18, 2010
Messages
20
Reaction score
0
Elo, jest moze jaks funkcja, ktora umozliwia policzenie graczy ktory stoja na jednej kratce ? wiem jak zrobic zeby liczylo ale jesli stoi 2 graczy na jednej kratce liczy go jako jednego..
 
function getDupy(pos)
for i=1,255(?) do
pos.stackpos = i
dupa = getThingfromPos(pos)
if isPlayer(dupa) then
cipy++
end
return cipy
end

pos = {x=666,y=69,z=7,stackpos=1}
ile = getDupy(pos)
Nie wiem na ile to działa, możliwe, że nawet ci to otsa rozjebie, ale ryzyk fizyk xd.
 
Dzieki za pomysl :P

Dzialajaca funkcja:
LUA:
function getPlayerCount(pos)
local playerCount = 0
for i=1,100 do
local pos2 = {x=pos.x, y=pos.y, z=pos.z,stackpos = i}
local thing = getThingfromPos(pos2)
    if isPlayer(thing.uid) == TRUE then
        playerCount = playerCount+1
    end   
end
return playerCount
end
 
Eee?

Code:
 //getTileInfo(pos)
        PositionEx pos;
        popPosition(L, pos);
        if(Tile* tile = g_game.getMap()->getTile(pos))
        {
                ScriptEnviroment* env = getEnv();
                pushThing(L, tile->ground, env->addThing(tile->ground));

                setFieldBool(L, "protection", tile->hasFlag(TILESTATE_PROTECTIONZONE));
                setFieldBool(L, "optional", tile->hasFlag(TILESTATE_OPTIONALZONE));
                setFieldBool(L, "nologout", tile->hasFlag(TILESTATE_NOLOGOUT));
                setFieldBool(L, "hardcore", tile->hasFlag(TILESTATE_HARDCOREZONE));
                setFieldBool(L, "refresh", tile->hasFlag(TILESTATE_REFRESH));
                setFieldBool(L, "trashed", tile->hasFlag(TILESTATE_TRASHED));
                setFieldBool(L, "house", tile->hasFlag(TILESTATE_HOUSE));
                setFieldBool(L, "bed", tile->hasFlag(TILESTATE_BED));
                setFieldBool(L, "depot", tile->hasFlag(TILESTATE_DEPOT));

                setField(L, "things", tile->getThingCount());
                [B]setField(L, "creatures", tile->getCreatureCount());[/B]
                setField(L, "items", tile->getItemCount());
                setField(L, "topItems", tile->getTopItemCount());
                setField(L, "downItems", tile->getDownItemCount());
        }
getTileInfo.creatures
 
na 0.3.5_SVN tego nie ma, ale dodalem tylko te linijki i dziala :>

setField(L, "things", tile->getThingCount());
setField(L, "creatures", tile->getCreatureCount());
setField(L, "items", tile->getItemCount());
setField(L, "topItems", tile->getTopItemCount());
setField(L, "downItems", tile->getDownItemCount());

// mam nadzieje ze crasha to nie spowoduje.
 
Back
Top