Skrypty & Kody Przerobienie skryptu. na winde

Status
Zamknięty.

mial123

Advanced User
Zarejestrowany
Dołączył
Kwiecień 2, 2009
Posty
307
Liczba reakcji
24
Witam, szukam skryptu na winde, jednak nie znalaz?em takiego jakiego bym chcia?, mam skrypt kt?ry chcia?bym poprawi? ?eby w?a?nie dzia?a? jak winda, powinien: zabiera? wszystkich ludzi z pozycji XYZ x XYZ(danego obszaru) po naduszeniu przycisku, tp po kolei na pietra, wy?wietla? komunikat kt?re to pi?tro(+je?eli to mo?liwe, mo?liwo?? wyj?cia na danym pietrze[nie wymagane]), za pomoc oczywi?cie Rep+ :d
[LUA]local config =
{
positions =
{
[1] = {x = 932, y = 1066, z = 7},
[2] = {x = 932, y = 1065, z = 8},
[3] = {x = 932, y = 1065, z = 9},
[4] = {x = 933, y = 1067, z = 7}
},
timeToTeleport = 5,
freezAfterTeleport = false
}

local function teleportAfterTime(cid, i)
if(i == 0) then
if(config.freezAfterTeleport == true) then
doCreatureSetNoMove(cid, false)
end
return true
end
if(config.freezAfterTeleport == true) then
doCreatureSetNoMove(cid, true)
end
doTeleportThing(cid, config.positions)
addEvent(teleportAfterTime, config.timeToTeleport * 1000, cid, i-1)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(isPlayer(itemEx.uid) == false or getCreatureName(cid) ~= getCreatureName(itemEx.uid)) then
return false
end
teleportAfterTime(cid, #config.positions)
return true
end
[/LUA]
 
Odp: Przerobienie skryptu. na winde

Pisa?em dawno temu tak? funkcj?:
[lua]function getFreeTile(pos, rangeX, rangeY, ignoreCreature)
local tablePositions = {}
for x = -rangeX, rangeX do
for y = -rangeY, rangeY do
local position = {x = pos.x + x, y = pos.y + y, z = pos.z}
if isWalkable(position, ignoreCreature, true) then
tablePositions[#tablePositions+1] = position
end
end
end
return #tablePositions > 0 and tablePositions
end

function doTeleportMassThings(leftTopCorner, rightBottomCorner, newPos, minPlayerCount, toSamenewPos, typeOfObjects)
local rangeX, rangeY = math.abs(rightBottomCorner.x - leftTopCorner.x)/2, math.abs(rightBottomCorner.y - leftTopCorner.y)/2
local center, player = {x=leftTopCorner.x+rangeX,y=rightBottomCorner.y-rangeY}, {}
for z = math.min(leftTopCorner.z, rightBottomCorner.z), math.max(leftTopCorner.z, rightBottomCorner.z) do
center.z = z
if getSpectators(center, rangeX, rangeY) then
for _, cid in pairs(getSpectators(center, rangeX, rangeY)) do
table.insert(player, cid)
end
end
end
if #player >= minPlayerCount then
for _, cid in pairs(player) do
local newPosSpectators = getFreeTile(newPos, 5, 5, true)
local newPos = (toSamenewPos and newPos or newPosSpectators[math.random(#newPosSpectators)])
if newPos and typeOfObjects(cid) then
doTeleportThing(cid, newPos, true, true)
else
print('ERROR: [newPos value is false or some object is not a creature].')
end
end
end
return true
end[/lua]
 
Ostatnia edycja:
Odp: Przerobienie skryptu. na winde

No ale gdzie ja mam to wklei?? Movevent? Jak tu nie ma "function onStepIn" wi?c jak to ma dzia?a?.
 
Odp: Przerobienie skryptu. na winde

najlepiej do lib/050-functions.lua
i funkcj? wywo?ujesz poprzez
doTeleportMassThings(leftTopCorner, rightBottomCorner, newPos, minPlayerCount, toSamenewPos, typeOfObjects)
oczywi?cie odpowiednio wype?niaj?c info w nawiasie.
 
Status
Zamknięty.
Back
Do góry