MoveEvent Advanced Training Tile

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Best answers
0
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...
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:

Xeikh

詠春 ☯
Joined
Oct 23, 2009
Messages
728
Best answers
0
Reaction score
17
Why no one cant say "Thanks" ??

Thanks, it looks good, i going test it ;)
 
OP
watkins577

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Best answers
0
Reaction score
0
Thanks for testing it :), I have tested it, but there could be some bugs that may not be there.

--Watkins577
 
OP
watkins577

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Best answers
0
Reaction score
0
Im guessing people dont like it. Also if anyone would like a script done for them, pm me, and Ill try and get it done asap.
 
OP
watkins577

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Best answers
0
Reaction score
0
B.U.M.P -- I have now added an advanced anti-bot system to stop botters completely (no fixed codes, or stepping on and off tiles). It is in the first post :D

--Watkins577
 
OP
watkins577

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Best answers
0
Reaction score
0
Bump again, it took me ages to make the anti-bot part and it seems noone likes it.
 
OP
watkins577

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Best answers
0
Reaction score
0
Bump <short>
 

Zeeh1997

New Member
Joined
Jan 1, 2010
Messages
29
Best answers
0
Reaction score
0
Thanks, very useful.
I'will put on my server.
REP++
 

wiccan

New Member
Joined
Oct 11, 2009
Messages
26
Best answers
0
Reaction score
0
do not let the variables space consuming ram.
use loops and tables.
 
OP
watkins577

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Best answers
0
Reaction score
0
do not let the variables space consuming ram.
use loops and tables.
For what exactly, its not really full of variables, since there are like 5 proper ones.
 

Shinmaru

エロルアー Scripter!
Joined
Aug 20, 2007
Messages
1,988
Best answers
0
Reaction score
87
Location
Puerto Rico
Nice at least the server won't suffer major lag due to many players botting or players force logging off the client when the battle icon is on.
EDIT:
I got this error, I'm using CryingDamson TFS 3.5 please verify and thanks.
Code:
[23/02/2010 20:48:40] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/other/train.lua)
[23/02/2010 20:48:40] data/movements/scripts/other/train.lua:60: ')' expected near 'then'
[23/02/2010 20:48:40] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/other/train.lua)
[23/02/2010 20:48:40] data/movements/scripts/other/train.lua:60: ')' expected near 'then'
 
Last edited:

Dantarrix

Member
Joined
Aug 27, 2010
Messages
546
Best answers
0
Reaction score
18
Location
Stgo, Chile
Cinuslca... your error is because you try it with a god or other group id that is not considered player xD or it is all the time in ghost mode so the script didnt found it hope i help......
Sorry for revive this theme
 
Top