local config = {
costPerHour = 500000, --// COST PER TRAINING HOUR
minLevel = 50, --// MIN LEVEL TO TRAIN
maxHours = 12, --// MAX HOURS ALOWED TO TRAIN AT ONE TIME
skillTryesPerHour = 1800, --// SKILLTRYES PER HOUR
teleportPlayers = no, --// IF YOU WANT TO SEND THE PLAYER TO ANY PLACE SET IT TO YES AND PUT THE POS BELOW
teleportToPos = 0,0,0 --// POSITION WHERE THE PLAYER WILL BE TELEPORTED TO WHEN HE GET TRAIN SKILL TIME
}
function onSay(cid, words, param, channel)
if(getPlayerLevel(cid) < config.minLevel) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot train skills on this level. Only players above level " .. config.minLevel .. " are alowed to train.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return TRUE
end
if(not param) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Type \"!train help\" to get help about this command.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return TRUE
elseif(string.lower(param) == "help") then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can improve your skills fast using this command.\nYou can train the following skills:\nAxe, Club, Sword, Distance and Shielding.\nIt's simple to use, type:\n!train [skill], [hours]\ne.g.:\n!train sword, 5\nCost per training hour: " .. config.costPerHour .. " gold coins.")
return TRUE
end
local cmd = string.split(param, ", ")
local skill = cmd[1]
local time = cmd[2]
local skills = {
club,
sword,
axe,
distance,
shielding,
21,
22,
23,
24,
25
}
if(skill ~= "" and isInArray(skills, string.lower(skill))) then
if(time ~= "" and time <= config.maxHours) then
for i = 1, 5 do
if(string.lower(skill) == skills) then
if(doPlayerRemoveMoney(cid, config.costPerHour * time)) then
if(config.teleportPlayers == "yes") then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doTeleportThing(cid, config.teleportToPos, TRUE)
end
doPlayerAddSkillTry(cid, skills[i+5], config.skillTryesPerHour * time)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "OK! IT'S DONE! YOU MESSAGE HERE.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enough money. " .. time .. " training skill hour" .. (time == 1 and "" or "s") .. " cost " .. config.costPerHour * time .. ".")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return TRUE
end
end
return TRUE
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must specify how much hours you wish to train.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return TRUE
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must specify the skill that you wish to train.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return TRUE
end
return TRUE
end