watkins577
As3, lua, xml scripter
- Joined
- Sep 20, 2008
- Messages
- 130
- Reaction score
- 0
Ok I know loads of people have released scripts like this, but I decided to release my own, as it is a bit more advanced than other ones.
This will increase skills if the use is using that type of weapon, if it is a fist weapon or not a weapon it trains fist (As would normally happen), and increases the mana spent if using a rod or wand.
EDIT:: Now has anti-bot protection!
EDIT2:: Sorry, think I removed a )
Okay first file train.lua...
In movements.xml put...
Make a new file called traintalk.lua and put this in it
And finally place this in talkactions...
In the map place tiles with actionid of 5000.
Please post any bugs or requests to add for this.
Known bugs::
None
How to use::
Step on the training tile.
Say !train to start training.
After 15 minutes you have to enter the code you were given.
Thanks
--Watkins577
This will increase skills if the use is using that type of weapon, if it is a fist weapon or not a weapon it trains fist (As would normally happen), and increases the mana spent if using a rod or wand.
EDIT:: Now has anti-bot protection!
EDIT2:: Sorry, think I removed a )
Okay first file train.lua...
PHP:
local config = {
timing = 2*1000, -- Time between trains
storage = 5000, -- Storage used
starttime = 10 -- Time before starting to train
}
function kick(cid)
if (getPlayerStorageValue(cid, config.storage+1) == 0) then
return false
end
doTeleportThing(cid, getPlayerMasterPos(cid))
setPlayerStorageValue(cid, config.storage, 0)
setPlayerStorageValue(cid, config.storage+1, 0)
end
function train(cid)
local count = 0
param = {cid = cid, count = count}
train2(param)
end
function train2(param)
local cid = param.cid
local count = param.count
if (isPlayer(cid) and getPlayerStorageValue(cid, config.storage) >= 1 and getPlayerStorageValue(cid, config.storage+2) == 1) then
count = 0
mana = 30
leftwep = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
rightwep = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
if (leftwep.itemid ~= 0) then
leftwep = getItemWeaponType(leftwep.uid) == 8 and 0 or getItemWeaponType(leftwep.uid)
else
leftwep = 0
end
if (rightwep.itemid ~= 0) then
rightwep = getItemWeaponType(rightwep.uid) == 8 and 0 or getItemWeaponType(rightwep.uid)
else
rightwep = 0
end
if (rightwep == 1 or leftwep == 1) then
doPlayerAddSkillTry(cid, 2, 1)
elseif (rightwep == 2 or leftwep == 2) then
doPlayerAddSkillTry(cid, 1, 1)
elseif (rightwep == 3 or leftwep == 3) then
doPlayerAddSkillTry(cid, 3, 1)
elseif (rightwep == 5 or leftwep == 5) then
doPlayerAddSkillTry(cid, 4, 1)
elseif (rightwep == 6 or leftwep == 6) then
mana = mana + 30
elseif (rightwep == 0 or leftwep == 0) then
doPlayerAddSkillTry(cid, 0, 1)
end
if (rightwep == 4 or leftwep == 4) then
doPlayerAddSkillTry(cid, 5, 1)
end
doPlayerAddSpentMana(cid, mana)
param = {cid = cid, count = count}
addEvent(train2, config.timing, param)
doSendMagicEffect(getCreaturePos(cid), CONST_ME_MAGIC_GREEN)
elseif not(isPlayer(cid)) then
return true
else
count = count + 1
if (count == 6) then
kick(cid)
return TRUE
end
param = {cid = cid, count = count}
addEvent(train2, config.starttime*1000, param)
end
return TRUE
end
function onStepIn(cid, item, pos, fromPos)
setPlayerStorageValue(cid, config.storage, 0)
setPlayerStorageValue(cid, config.storage+1, 1)
setPlayerStorageValue(cid, config.storage+2, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Say !train to start training. You have " .. config.starttime*6 .. " seconds to do this.")
addEvent(train, config.starttime*1000, cid)
end
function onStepOut(cid, item, pos, fromPos)
setPlayerStorageValue(cid, config.storage, 0)
setPlayerStorageValue(cid, config.storage+1, 0)
setPlayerStorageValue(cid, config.storage+2, 0)
end
In movements.xml put...
PHP:
<movevent type="StepIn" actionid="5000" event="script" value="other/train.lua"/>
<movevent type="StepOut" actionid="5000" event="script" value="other/train.lua"/>
Make a new file called traintalk.lua and put this in it
PHP:
local config = {
storage = 5000,
timebet = 15
}
function newcode(cid)
return math.random(1, 9999)
end
function inputcode(cid)
setPlayerStorageValue(cid, config.storage+1, 2)
setPlayerStorageValue(cid, config.storage+2, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have one minute to enter you code! Do so now or get kicked from this room')
end
function onSay(cid, words, param, channel)
if (getPlayerStorageValue(cid, config.storage+1) == 1) then
setPlayerStorageValue(cid, config.storage+1, 3)
setPlayerStorageValue(cid, config.storage+2, 1)
setPlayerStorageValue(cid, config.storage, newcode(cid))
doPlayerPopupFYI(cid, 'Your code for this ' .. config.timebet .. ' mins is ' .. getPlayerStorageValue(cid, config.storage) .. '. In ' .. config.timebet .. ' minutes you will be asked for this code.\nSay !train ' .. getPlayerStorageValue(cid, config.storage) .. ' to carry on training.')
addEvent(inputcode, config.timebet*60*1000, cid)
return true
elseif (getPlayerStorageValue(cid, config.storage+1) == 2) then
param = tonumber(param)
if (param == getPlayerStorageValue(cid, config.storage)) then
setPlayerStorageValue(cid, config.storage+1, 3)
setPlayerStorageValue(cid, config.storage+2, 1)
setPlayerStorageValue(cid, config.storage, newcode(cid))
doPlayerPopupFYI(cid, 'Your code is correct, and ' .. config.timebet .. ' minutes have been added. Your new code is ' .. getPlayerStorageValue(cid, config.storage) .. '.')
addEvent(inputcode, config.timebet*60*1000, cid)
return true
else
doPlayerPopupFYI(cid, 'Your code is incorrect.')
return false
end
elseif (getPlayerStorageValue(cid, config.storage+1) == 3) then
doPlayerPopupFYI(cid, 'Your code is too early. Please try again when you get the notification to input your code')
return true
end
return false
end
And finally place this in talkactions...
PHP:
<talkaction words="!train" event="script" value="traintalk.lua"/>
In the map place tiles with actionid of 5000.
Please post any bugs or requests to add for this.
Known bugs::
None
How to use::
Step on the training tile.
Say !train to start training.
After 15 minutes you have to enter the code you were given.
Thanks
--Watkins577
Last edited: