Strona Główna Belxena 8.4 RPG

Forum poświęcone powstawaniu Belxena OTS


#1 2009-05-02 12:31:33

Macgates

Administrator

419634
Skąd: Rio de Fabrico
Zarejestrowany: 2009-05-01
Posty: 50
Punktów :   

[8.4] Działający System Anty BOT

Jest to anty bot system, który polega na wpisaniu KODU przez użytkownika po czasie X.
Jeśli osoba ta nie wpiszę kodu podanego przez skrypt, teleportuje go(w Twoje wybrane miejsce)



http://img225.imageshack.us/img225/721/howtotrainersvm2.jpg



--------------------------------------------------------------------------------------------------------------------------------------------------------------------

http://img140.imageshack.us/img140/74/train1bi6.jpg



W functions.lua (na końcu dodać)



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, '(TrainMod): If you want still train you need to write !train
"'.. code ..'. You have 20 seconds to write it.')
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 * 60, cid)
addEvent(isItEndOfTraining, (TRAIN_TIME * 1000 * 60) + 20000, cid)
end

Stwórz nowy plik data/actions/scripts/training.lua



--------CONFIG--------
local fromActionId = 20000 -- 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..', and you have to pay '.. TRAIN_PRICE ..' gp to continue this training'
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): Room is full.')
doSendMagicEffect(getCreaturePosition(cid), 2)
else
if playerStartTraining(cid) == TRUE then
doTeleportThing(cid, arenaPos, FALSE)
doSendMagicEffect(getThingPos(item.uid), 21)
end
end
else
doPlayerEndTraining(cid)
end
end
return TRUE
end

Teraz dodaj gdziekolwiek w data\actions\actions.xml



<!-- Training by slawkens -->
<action fromaid="20000" toaid="20003" script="training.lua"/>

Stwórz nowy plik data/talkactions/scripts/training.lua



function onSay(cid, words, param)
if isPlayerTraining(cid) == TRUE then
if getPlayerStorageValue(cid, STORAGEVALUE_TRAIN_CODE) ~= 1 then
if tonumber(param) == getPlayerStorageValue(cid, STORAGEVALUE_TRAIN_CODE) then
if TRAIN_PRICE > 0 then
if doPlayerRemoveMoney(cid, TRAIN_PRICE) == FALSE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(TrainMod): Sorry, training
cost '.. TRAIN_PRICE ..' gp for every '.. getMinExtend(TRAIN_TIME) ..'.')
doPlayerEndTraining(cid)
return FALSE
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(TrainMod): Training extended. Next code
after: '.. getMinExtend(TRAIN_TIME) ..'.')
setPlayerStorageValue(cid, STORAGEVALUE_TRAIN_CODE, 1)
doPlayerExtendTraining(cid)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(TrainMod): Code is wrong!')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '(TrainMod): Code is no need now...')
end
end
return FALSE
end

Teraz dodaj gdziekolwiek w data/talkactions/talkactions.xml



<talkaction words="!train" script="training.lua"/>

Teraz w global.lua (na końcu gdzieś)



STORAGEVALUE_TRAINING = 9011
STORAGEVALUE_TRAIN_CODE = 9012
-- how often player will be asked for CODE ( in MINUTES )
TRAIN_TIME = 15 --in minutes
-- POSITION where player will be teleported after LEAVING room
TRAIN_EXIT_POS = {x=167, y=53, z=7}
TRAIN_PRICE = 500

Czerwony Kolor: Tutaj ustawiasz pozycje gdzie ma teleportować po nie wpisaniu kodu.


http://img257.imageshack.us/img257/8138/neverendstm0qr1md8ep0.gif

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora
www.cll.pun.pl www.eurotrucksite.pun.pl www.hubiofmaster.pun.pl www.highriskboys.pun.pl www.online-menager.pun.pl