• Vote in May Mapping Competition to select a winner!
  • 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 Function doPlayerSetExtraAttackSpeed(cid, speed)

Joined
Apr 17, 2008
Messages
1,922
Best answers
0
Reaction score
182
Location
Venezuela
Function tested in TFS 0.3.5Pl1

player.cpp
Find:
Code:
lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = 0;
Replace with this:
Code:
lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = extraAttackSpeed = 0;
Find:
Code:
return vocation->getAttackSpeed()
And replace with this:
Code:
return vocation->getAttackSpeed() - getPlayer()->getExtraAttackSpeed();
At the end of the file paste this:
Code:
void Player::setPlayerExtraAttackSpeed(uint32_t speed)
{
	extraAttackSpeed = speed;
}
player.h
Below:
Code:
uint64_t getSpentMana() const {return manaSpent;}
Paste this:
Code:
uint32_t getExtraAttackSpeed() const {return extraAttackSpeed;}
void setPlayerExtraAttackSpeed(uint32_t speed);
Below:
Code:
uint32_t idleTime;
Paste this:
Code:
uint32_t extraAttackSpeed;
luascript.cpp
Below:
Code:
	//doPlayerAddSoul(cid, soul)
	lua_register(m_luaState, "doPlayerAddSoul", LuaInterface::luaDoPlayerAddSoul);
Add this:
Code:
	//doPlayerSetExtraAttackSpeed(cid, speed)
	lua_register(m_luaState, "doPlayerSetExtraAttackSpeed", LuaInterface::luaDoPlayerSetExtraAttackSpeed);
After:
Code:
int32_t LuaInterface::luaDoPlayerAddSoul(lua_State* L)
{
	//doPlayerAddSoul(cid, soul)
	int32_t soul = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Player* player = env->getPlayerByUID(popNumber(L)))
	{
		player->changeSoul(soul);
		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}
Paste this:
Code:
int32_t LuaInterface::luaDoPlayerSetExtraAttackSpeed(lua_State *L)
{    
    uint32_t speed = popNumber(L);           	
    ScriptEnviroment* env = getEnv();
       if(Player* player = env->getPlayerByUID(popNumber(L))){    
			player->setPlayerExtraAttackSpeed(speed);
            lua_pushnumber(L, true);
       }    
       else{       
           errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
           lua_pushnumber(L, false);
       }       
    return 1;
}
luacript.h
Below:
Code:
		static int32_t luaDoPlayerAddSoul(lua_State* L);
Add:
Code:
		static int32_t luaDoPlayerSetExtraAttackSpeed(lua_State* L);
How to use?
Lua:
doPlayerSetExtraAttackSpeed(cid, 2000) <- attack speed will be 2 seconds more faster
Now compile and enjoy :)
 
Last edited:

Hazen

Riariari dorgas mano
Joined
Jun 27, 2009
Messages
39
Best answers
0
Reaction score
0
awesome
now we can do many things that i don't imagined *---*


ctrl+D plax
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,587
Best answers
3
Reaction score
861
Location
Caribbean Sea
tested and fully working?
 

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Best answers
0
Reaction score
29
you can try make the speed like a condition... is usefull for making spells like fast attack with a limit time (players can abuse the fast attack system and is very easy option for rpg's :S)
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,587
Best answers
3
Reaction score
861
Location
Caribbean Sea
someone here is named richux?
 

Thuggeh

New Member
Joined
Jul 10, 2007
Messages
201
Best answers
0
Reaction score
0
Awesome, you did as I requested, I'm loving it. =)

Thanks.
 

spoofghost

New Member
Joined
May 11, 2008
Messages
35
Best answers
0
Reaction score
1
Hey, sorry to bother but this piece of code edit makes it possible to create a faster attack speed.
if i read it correct?

if so thanks in advance! :)
going to try it out.

yours spoof
 

Ferchox

Member
Joined
May 16, 2008
Messages
743
Best answers
0
Reaction score
19
Location
Sydney, Australia
Well yes, i believe because he talks about Attack speed in the instructions. im testing it! :p thanks
 

elf

Sing, sing blue silver
Joined
Dec 11, 2007
Messages
3,665
Best answers
1
Reaction score
116
Location
Cracow, Poland
you can try make the speed like a condition... is usefull for making spells like fast attack with a limit time (players can abuse the fast attack system and is very easy option for rpg's :S)
Easy :peace:
 

Icy

Active Member
Joined
Aug 4, 2009
Messages
881
Best answers
0
Reaction score
26
So I tried reverse-engineering this to work with 8.54+ and I honestly, for the life of me, can't figure out how to make it work.

Anyone have any idea..?
 
OP
Darkhaos
Joined
Apr 17, 2008
Messages
1,922
Best answers
0
Reaction score
182
Location
Venezuela
doPlayerSetExtraAttackSpeed(cid, 1000) <--- player will get 1 second faster
doPlayerSetExtraAttackSpeed(cid, 0) <--- attack speed returns to default.
 

Icy

Active Member
Joined
Aug 4, 2009
Messages
881
Best answers
0
Reaction score
26
doPlayerSetExtraAttackSpeed(cid, 1000) <--- player will get 1 second faster
doPlayerSetExtraAttackSpeed(cid, 0) <--- attack speed returns to default.
derp, read more carefully
 

foxkbt

Member
Joined
Sep 29, 2009
Messages
290
Best answers
0
Reaction score
7
Location
Salvador
sorry but it dosent work on 8.54~8.57
plx can u fixed it for me?
thx for advanced
 

Strack

Member
Joined
May 15, 2009
Messages
198
Best answers
0
Reaction score
14
runs perfect on tfs 0.3.6pl1 for tibia 8.54
the only thing u must change some things on sources 'cause it gives errors on compiling, but are easy things to be corrected

Thanks for sharing it darkhaos ^^
 
Top