- Dołączył
- Czerwiec 29, 2011
- Posty
- 59
- Liczba reakcji
- 2
- Wiek
- 35
Witam prosz? o pomoc poniewa? tego sam nie potrafi? naprawi? .. B??d ukarze w formie zdj?cia .. Versia Silnika Tfs 3777
..Dzi?kuje
Na pro?b? HulaHops podam
actions/Training.lua
Kod:
function getNextPosFromDir(fromPos, dir, size)
local newPos =
{
[0]={x=fromPos.x, y=fromPos.y-size, z=fromPos.z},
[1]={x=fromPos.x+size, y=fromPos.y, z=fromPos.z},
[2]={x=fromPos.x, y=fromPos.y+size, z=fromPos.z},
[3]={x=fromPos.x-size, y=fromPos.y, z=fromPos.z}
}
return newPos[dir]
end
function isPlayerTraining(cid)
return getPlayerStorageValue(cid, STORAGEVALUE_TRAINING)
end
function getMinExtend(time)
min = 'minutes'
if time == 1 then
min = 'minute'
end
return time..' '..min
end
function doPlayerEndTraining(cid)
if isPlayerTraining(cid) == TRUE then
doTeleportThing(cid, TRAIN_EXIT_POS, FALSE)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
if getPlayerStorageValue(cid, STORAGEVALUE_TRAIN_CODE) > 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(TrainMod): You didnt wrote code...')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(TrainMod): Its end of your training.')
end
setPlayerStorageValue(cid, STORAGEVALUE_TRAINING, 0)
setPlayerStorageValue(cid, STORAGEVALUE_TRAIN_CODE, 0)
end
end
function setPlayerTrainCode(cid)
if isPlayerTraining(cid) == TRUE then
code = math.random(1000, 9999)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(bot): Je?li chcesz trenowac dalej wpisz !bot
"'.. code ..'. Masz 20 sekund, aby wpisac !bot.')
setPlayerStorageValue(cid, STORAGEVALUE_TRAIN_CODE, code)
end
end
function isItEndOfTraining(cid)
if getPlayerStorageValue(cid, STORAGEVALUE_TRAIN_CODE) ~= 1 then
doPlayerEndTraining(cid)
end
end
function doPlayerExtendTraining(cid)
addEvent(setPlayerTrainCode, TRAIN_TIME * 1000 * 30, cid)
addEvent(isItEndOfTraining, (TRAIN_TIME * 1000 * 30) + 5000, cid)
end
Kod:
local fromActionId = 5000 -- actions id used. (default: 20000). If you change it, you also need change in actions.xml
local function playerStartTraining(cid)
local text = '(TrainMod): Your training started. After '.. getMinExtend(TRAIN_TIME) ..' you\'ll need to write code to extend
training'
if TRAIN_PRICE > 0 then
text = text..', Musisz zaplacic '.. TRAIN_PRICE ..' gp aby dalej trenowac'
end
text = text..'.'
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, text)
setPlayerStorageValue(cid, STORAGEVALUE_TRAINING, 1)
doPlayerExtendTraining(cid)
return TRUE
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.actionid >= fromActionId and item.actionid <= (fromActionId + 3) then
dir = item.actionid - fromActionId
arenaPos = getNextPosFromDir(fromPosition, (item.actionid - fromActionId), 1)
arenaPos.stackpos = STACKPOS_TOP_CREATURE
if isPlayerTraining(cid) ~= TRUE then
if getThingfromPos(arenaPos).uid ~= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(TrainMod): Pokoj Pelny.')
doSendMagicEffect(getCreaturePosition(cid), 2)
else
if playerStartTraining(cid) == TRUE then
doTeleportThing(cid, arenaPos, FALSE)
doTurnCreature(cid, dir)
doSendMagicEffect(getThingPos(item.uid), 21)
end
end
else
doPlayerEndTraining(cid)
end
end
return TRUE
end