MoveEvent Training Square

Osmose

hunf hunf
Joined
May 15, 2009
Messages
28
Best answers
0
Reaction score
0
I made this from a discution on this thread

-- Square Skill Trainer made by Arthur aka artofwork
Pretty much by me since i modified the entire script but he got the ideia first...

i tried to make it support fist skill as well but i got a infinite loop that crash my server...
cant figure out how to solve this problem...

for information proposes, tested on TFS 0.3.4pl2! :)

data/movements/scripts/sqtrainer.lua
PHP:
-- Config --
local skillTries = 10 -- Number of tries per skill
local t = 2 * 1000 -- Set the time before try is added to skills
local lock = 10 -- Time to wait before start again in seconds

-- Weapon Types --
local weaponTypes = {
	{ 1, 2 }, -- Sword
	{ 2, 1 }, -- Club
	{ 3, 3 }, -- Axe
	{ 4, 5 }, -- Shield
	{ 5, 4 } -- Distance
}

function onStepIn(cid, item, pos, fromPos)
	local p = {cid = cid, item = item, pos = pos}
	if getPlayerStorageValue(p.cid, 18010) == 2 then
		doTeleportThing(p.cid, fromPos, TRUE)
		doPlayerSendTextMessage(p.cid,22,"You must wait "..lock.." seconds before you start again")
		return false
	end
	setPlayerStorageValue(p.cid, 18010, 1)
	if isPlayer(p.cid) and p.item.actionid == 900 then
		doPlayerSendTextMessage(p.cid,22,"Your training session will now begin")
		addEvent(trainMe, t, p)
	end
	return true
end
function onStepOut(cid, item)
	if getPlayerStorageValue(cid, 18010) == 2 then
		return false
	end
	setPlayerStorageValue(cid, 18010, 2)
	addEvent(trainLock, lock * 1000, cid)
	doPlayerSendTextMessage(cid,22,"Your training session has now ended")
	return true
end
function trainLock (cid)
	if isPlayer(cid) then
		setPlayerStorageValue(cid, 18010, 0)
	end
end
function trainMe(p)
	if isPlayer(p.cid) and getPlayerStorageValue(p.cid, 18010) == 1 and p.item.actionid == 900 then
		local weaponLeft = getPlayerSlotItem(p.cid, CONST_SLOT_LEFT)
		local weaponRight = getPlayerSlotItem(p.cid, CONST_SLOT_RIGHT)
		if weaponLeft.itemid ~= 0 then
			weaponLeft = getItemWeaponType(weaponLeft.uid)
		end
		if weaponRight.itemid ~= 0 then
			weaponRight = getItemWeaponType(weaponRight.uid)
		end
		for _, t in pairs(weaponTypes) do
			if t[1] == weaponLeft or t[1] == weaponRight then			
				doPlayerAddSkillTry(p.cid, t[2], skillTries)
			end
		end
		manaspent = getPlayerMana(p.cid)
		doPlayerAddSpentMana(p.cid, manaspent)
		doTargetCombatMana(0, p.cid, -manaspent, -manaspent, CONST_ME_NONE)

		doSendMagicEffect(getPlayerPosition(p.cid),34)
	
		addEvent(trainMe, t, p)
	end
	return true
end
movements.xml
PHP:
	<!-- Trainer Square -->
	<movevent type="StepIn" actionid="900" script="sqtrainer.lua"/>
	<movevent type="StepOut" actionid="900" script="sqtrainer.lua"/>
data/creaturescrips/scripts/login.lua add this
PHP:
setPlayerStorageValue(cid, 18010, 0)
in case player logout or server drop

Using map editor set Square you want as Trainer with ActionID 900.

im done...
improvements are welcome!!! thank you!
 
Last edited:
OP
Osmose

Osmose

hunf hunf
Joined
May 15, 2009
Messages
28
Best answers
0
Reaction score
0
But can use a spell to spent mana? is better and more pro ;p
why if you can do everything in the same place... just add some effects
this way you got a faster and clean code
 

Antagoreon

New Member
Joined
Jul 13, 2008
Messages
94
Best answers
0
Reaction score
0
Location
Inside Inferno
I test this script in my ot but not work with ml up =/ i spent mana but not ml up and when i reach distance 25 the distance skill rises very slowly :S could make mana spent only if the character has 100% of your mana and another thing beam that automatically increases the mana
 
Last edited:
OP
Osmose

Osmose

hunf hunf
Joined
May 15, 2009
Messages
28
Best answers
0
Reaction score
0
I test this script in my ot but not work with ml up =/ i spent mana but not ml up and when i reach distance 25 the distance skill rises very slowly :S could make mana spent only if the character has 100% of your mana and another thing beam that automatically increases the mana
yea

change
PHP:
doPlayerAddSpentMana(p.cid, manaspent)
doTargetCombatMana(0, p.cid, -manaspent, -manaspent, CONST_ME_NONE)
to
PHP:
if getPlayerMana(p.cid) == getPlayerMaxMana(p.cid) then
    doPlayerAddSpentMana(p.cid, manaspent)
    doTargetCombatMana(0, p.cid, -manaspent, -manaspent, CONST_ME_NONE)
end
 

Antagoreon

New Member
Joined
Jul 13, 2008
Messages
94
Best answers
0
Reaction score
0
Location
Inside Inferno
Well, but what i can do with the skills problem, because when i have 25 or more in distance left to climb or i advance in distance but ver very slowly
 
OP
Osmose

Osmose

hunf hunf
Joined
May 15, 2009
Messages
28
Best answers
0
Reaction score
0
review your skill rate in config.lua
 

[email protected]

Fudera Otserver
Joined
Jul 10, 2007
Messages
212
Best answers
0
Reaction score
0
Location
Brasil
Can you explain step by step how to add this on my server.... your explanation don't easy to undertand, i'm a noob on scripts and otserv world...
 

Yakushi

New Member
Joined
Dec 30, 2008
Messages
110
Best answers
0
Reaction score
0
Location
Germany
I have a problem...
I added that in movements/scripts...

-- Config --
local skillTries = 10 -- Number of tries per skill
local t = 2 * 1000 -- Set the time before try is added to skills
local lock = 10 -- Time to wait before start again in seconds

-- Weapon Types --
local weaponTypes = {
{ 1, 2 }, -- Sword
{ 2, 1 }, -- Club
{ 3, 3 }, -- Axe
{ 4, 5 }, -- Shield
{ 5, 4 } -- Distance
}

function onStepIn(cid, item, pos, fromPos)
local p = {cid = cid, item = item, pos = pos}
if getPlayerStorageValue(p.cid, 18010) == 2 then
doTeleportThing(p.cid, fromPos, TRUE)
doPlayerSendTextMessage(p.cid,22,"You must wait "..lock.." seconds before you start again")
return false
end
setPlayerStorageValue(p.cid, 18010, 1)
if isPlayer(p.cid) and p.item.actionid == 900 then
doPlayerSendTextMessage(p.cid,22,"Your training session will now begin")
addEvent(trainMe, t, p)
end
return true
end
function onStepOut(cid, item)
if getPlayerStorageValue(cid, 18010) == 2 then
return false
end
setPlayerStorageValue(cid, 18010, 2)
addEvent(trainLock, lock * 1000, cid)
doPlayerSendTextMessage(cid,22,"Your training session has now ended")
return true
end
function trainLock (cid)
if isPlayer(cid) then
setPlayerStorageValue(cid, 18010, 0)
end
end
function trainMe(p)
if isPlayer(p.cid) and getPlayerStorageValue(p.cid, 18010) == 1 and p.item.actionid == 900 then
local weaponLeft = getPlayerSlotItem(p.cid, CONST_SLOT_LEFT)
local weaponRight = getPlayerSlotItem(p.cid, CONST_SLOT_RIGHT)
if weaponLeft.itemid ~= 0 then
weaponLeft = getItemWeaponType(weaponLeft.uid)
end
if weaponRight.itemid ~= 0 then
weaponRight = getItemWeaponType(weaponRight.uid)
end
for _, t in pairs(weaponTypes) do
if t[1] == weaponLeft or t[1] == weaponRight then
doPlayerAddSkillTry(p.cid, t[2], skillTries)
end
end
manaspent = getPlayerMana(p.cid)
doPlayerAddSpentMana(p.cid, manaspent)
doTargetCombatMana(0, p.cid, -manaspent, -manaspent, CONST_ME_NONE)

doSendMagicEffect(getPlayerPosition(p.cid),34)

addEvent(trainMe, t, p)
end
return true
end




Then i added that in movements.xml:

<movevent event="StepIn" actionid="900" script="sqtrainer.lua"/>
<movevent event="StepOut" actionid="900" script="sqtrainer.lua"/>

But when i go now on the Tile, I made with action id 900, Then there comes:
13:51 The tile seems to be protected against unwanted intruders.
in a green colour.

Why??

I use cryingdamson4pl2-gui 0.3.4 (client 8.42)
 
OP
Osmose

Osmose

hunf hunf
Joined
May 15, 2009
Messages
28
Best answers
0
Reaction score
0
@up
probably action 900 is conflicting with another custom script on your server
try change it to another value
 

artofwork

Well-Known Member
Joined
Dec 3, 2008
Messages
420
Best answers
0
Reaction score
58
I made this from a discution on this thread

-- Square Skill Trainer made by Arthur aka artofwork
Pretty much by me since i modified the entire script but he got the ideia first...

i tried to make it support fist skill as well but i got a infinite loop that crash my server...
cant figure out how to solve this problem...

in case player logout or server drop

Using map editor set Square you want as Trainer with ActionID 900.

im done...
improvements are welcome!!! thank you!

The reason you can't fix the problem with this script is because you didn't write it, I did!

As you can see "-- Square Skill Trainer made by Arthur aka artofwork"

Don't go stealing other people's scripts and calling them your own, give credit where credit is due.


@up
probably action 900 is conflicting with another custom script on your server
try change it to another value
Are you an idiot?
Do you even know what this code says?

I can fix your version of this, but i rather not because you wanna take all the credit.


To everyone else you can find the real script here on otfans.net:
Movement: Square Trainer (no longer will you need monks)
Code:
http://otfans.net/showthread.php?t=140837
 
Last edited:

JoSePh15_

Well-Known Member
Joined
Jan 28, 2010
Messages
1,768
Best answers
0
Reaction score
56
u copied it from someone i'm pretty sure...this script was released several times...:$
 

Yakushi

New Member
Joined
Dec 30, 2008
Messages
110
Best answers
0
Reaction score
0
Location
Germany
Man help pls.
I changed the action id 900 with an other action id, with multiple others.... But it doesn't work.
When I go onto the tile, there comes:
The Tile seems to be protected against unwanted intruders.
Please help!

I am using TFS.0.3.6pl1
 
Last edited:
Top