• 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!

Lua How i can do this?

renancs

New Member
Joined
Jul 8, 2008
Messages
252
Reaction score
3
Well, i create this script and i want to put this script to work:
when player use this spell, he go loss shield, gain speed and change your vocation for gain attack speed, how can i put,
to when the time end, the vocation back to vocation "2", without the attack speed, the shield, and speed, leave normaly,
only the vocation i have problem, someone can help me?

Lua:
local time = 20 * 1000 -- 120 * 1000 = 2 min
local addShielding = -50 -- how much shielding should be added
 
local wolf = {lookType = 318, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
 
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, time)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, addShielding)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat, condition)
 
local speed = createConditionObject(CONDITION_HASTE)
setConditionParam(speed, CONDITION_PARAM_TICKS, time)
setConditionFormula(speed, 0.3, -24, 0.3, -24)
setCombatCondition(combat, speed)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, time)
addOutfitCondition(outfit, wolf)
setCombatCondition(combat, outfit)
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 3)
setCombatCondition(combat, exhaust)
 
function onCastSpell(cid, var)
	doPlayerSetVocation(cid, 15)
	setConditionParam(condition, CONDITION_PARAM_TICKS, time)
	return doCombat(cid, combat, var)
end
 
you need 2 things, an addEvent so that it changes your vocation back and a onLogout incase the player logs out, since he's offline the addEvent wont happen, so he'll permanently get that vocation

I'm at Univ. right now so i dont have the time to write the complete code, but if no one helps you till I get home(which is like 6 hours from now), if I remember I'll write the code you need
 
right, thanks alot for your time scarlet...

i try use the addevent of one script of u (invisible spell), but i don't have sucess


[edit]
scarlet, don't is better i use this:
http://otland.net/f35/edit-player-attack-speed-58265/

and i put to the script ''add extra attack speed'', cuz i think, if i put to change vocations,
add event... is every thing if i can only change one source...
or this source don't work for this?

thanks
 
Last edited:
that code wont work because it affects everyone, also its defined on config.lua so you cant change it after the server started.

you'll need something like:
forgive me for any syntax errors, I no longer have a server to test them or to check the function names :)

your spell.lua
Code:
function onCast(cid, combat, var)
    setPlayerVocation(cid, getPlayerVocation(cid)+8)
    registerCreatureEvent(cid, "logoutAttackSpeedFix")
    addEvent(attackSpeedFix,30000,cid)
    return true
end

function attackSpeedFix(cid)
    setPlayerVocation(cid, getPlayerVocation(cid)-8)
    return true
end
logoutAttackSpeedFix.lua
Code:
function onLogout(cid)
    setPlayerVocation(cid, getPlayerVocation(cid)-8)
    return true
end
dont forget to add it to the creatureevents.xml and to give it the same name as it is on registerCreatureEvent in the onCast function
 
Lua:
event oncastspell not found <data/spells/scripts/support/spelltext.lua>
event oncast not found <data/creaturescripts/scripts/logoutAttackSpeedFix.lua>
 
Back
Top