• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Advanced] Training System with anti-bot protection !

Status
Not open for further replies.
I have problem
[26/09/2008 13:37:09] Warning: [Event::loadScript] Can not load script. data/actions/scripts/training.lua
[26/09/2008 13:37:09] data/actions/scripts/training.lua:5: unfinished string near '' you'll need to write code to extend '
[26/09/2008 13:37:10] Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/training.lua
[26/09/2008 13:37:10] data/talkactions/scripts/training.lua:7: unfinished string near ''(TrainMod): Sorry, training '
 
I have problem

try this:
talkactions/scripts/training.lua:
Code:
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

@topic
Script pwnz! Thanks, slawkens :D

@edit
wtf?!

Code:
[10/10/2008  14:05:15] Lua Script Error: [Action Interface] 
[10/10/2008  14:05:15] data/actions/scripts/tools/training.lua:onUse

[10/10/2008  14:05:15] data/actions/scripts/tools/training.lua:28: attempt to call global 'doTurnCreature' (a nil value)
[10/10/2008  14:05:15] stack traceback:
[10/10/2008  14:05:15] 	data/actions/scripts/tools/training.lua:28: in function <data/actions/scripts/tools/training.lua:16>
no idea how to fix this error.. someone?
 
Last edited:
Its not working on TFS 8.22 (0.2.14 patch 10) :|
Tags dont have functions.lua, then i added it to global.lua, and its not woring :S
 
try this:
talkactions/scripts/training.lua:
Code:
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

@topic
Script pwnz! Thanks, slawkens :D

@edit
wtf?!

Code:
[10/10/2008  14:05:15] Lua Script Error: [Action Interface] 
[10/10/2008  14:05:15] data/actions/scripts/tools/training.lua:onUse

[10/10/2008  14:05:15] data/actions/scripts/tools/training.lua:28: attempt to call global 'doTurnCreature' (a nil value)
[10/10/2008  14:05:15] stack traceback:
[10/10/2008  14:05:15] 	data/actions/scripts/tools/training.lua:28: in function <data/actions/scripts/tools/training.lua:16>
no idea how to fix this error.. someone?

Remove doTurnCreature(cid, dir) from training.lua... Since I cant seem to find this or any similiar function in TFS.
 
@up
okay ^^, now it seems to be clean from errors..
 
It IS working with this version. Maybe you have something wrong ?
 
For 0.3 beta 1 users:
Code:
function doGenerateCode()
	local chars = {}
	for i = 1, 8 do
		local tmp = math.random(1,3)
		if(tmp == 1) then
			table.insert(chars, math.random(65,90))
		elseif(tmp == 2) then
			table.insert(chars, math.random(97,122))
		else
			table.insert(chars, math.random(48,57))
		end
	end

	return string.format("%c%c%c%c%c%c%c%c", chars[1], chars[2], chars[3], chars[4], chars[5], chars[6], chars[7], chars[8])
end
Will generate codes like:
04:41 Bought time will pass within 60 seconds. If you still want to train, please validate with code: 0x2xHUFD
04:41 You have bought additional 10 minutes of training. You may train till 04:53:07.
04:41 Bought time will pass within 60 seconds. If you still want to train, please validate with code: PqmPle4h
04:42 You have bought additional 10 minutes of training. You may train till 04:53:28.
04:42 Bought time will pass within 60 seconds. If you still want to train, please validate with code: 4Cb3jEkA
 
Code:
21:45 [TrainMod]: If you want still train you need to write !train "9289. You have 20 seconds to write it.
21:45 [TrainMod]: Code is wrong!
21:45 CM XXX: !train "9289
I already removed doTurnCreature. There's no bugs in console... nothing :/ I use 0.3b1pl2.
 
It's not called global.lua on beta 1, it's called functions.lua.
 
Hi, i have an problem when i go into room with trainers, my console server say
[21/12/2008 11:55:17] Lua Script Error: [Action Interface]
[21/12/2008 11:55:17] data/actions/scripts/training.lua:onUse

[21/12/2008 11:55:17] data/actions/scripts/training.lua:28: attempt to call global 'doTurnCreature' (a nil value)
[21/12/2008 11:55:17] stack traceback:
[21/12/2008 11:55:17] data/actions/scripts/training.lua:28: in function <data/actions/scripts/training.lua:16>
 
Status
Not open for further replies.
Back
Top