- Joined
- Feb 14, 2015
- Messages
- 5,640
- Solutions
- 559
- Reaction score
- 3,916
player.h
above
add
replace getAttackSpeed() with this
add this above getAttackSpeed()
luascript.h
below
add
luascript.cpp
below
add
below
add
note: if you're using 1.2 and you don't want the player to be interrupted while using items/walking you need to add this code: Fix #1319 by Mkalo · Pull Request #2109 · otland/forgottenserver · GitHub
above
C++:
uint32_t inventoryWeight;
C++:
uint32_t attackSpeed = 0;
replace getAttackSpeed() with this
C++:
uint32_t getAttackSpeed() const {
if (attackSpeed > 0) {
return attackSpeed;
}
return vocation->getAttackSpeed();
}
add this above getAttackSpeed()
C++:
void setAttackSpeed(uint32_t speed) {
attackSpeed = speed;
}
luascript.h
below
C++:
static int luaPlayerGetFightMode(lua_State* L);
C++:
static int luaPlayerSetAttackSpeed(lua_State* L);
static int luaPlayerGetAttackSpeed(lua_State* L);
luascript.cpp
below
C++:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode);
C++:
registerMethod("Player", "getAttackSpeed", LuaScriptInterface::luaPlayerGetAttackSpeed);
registerMethod("Player", "setAttackSpeed", LuaScriptInterface::luaPlayerSetAttackSpeed);
below
C++:
int LuaScriptInterface::luaPlayerHasSecureMode(lua_State* L)
{
// player:hasSecureMode()
Player* player = getUserdata<Player>(L, 1);
if (player) {
pushBoolean(L, player->secureMode);
} else {
lua_pushnil(L);
}
return 1;
}
C++:
int LuaScriptInterface::luaPlayerSetAttackSpeed(lua_State* L)
{
// player:setAttackSpeed(ms)
Player* player = getUserdata<Player>(L, 1);
uint32_t ms = getNumber<uint32_t>(L, 2);
if (player) {
player->setAttackSpeed(ms);
pushBoolean(L, true);
} else {
lua_pushnil(L);
}
return 1;
}
int LuaScriptInterface::luaPlayerGetAttackSpeed(lua_State* L)
{
// player:getAttackSpeed()
Player* player = getUserdata<Player>(L, 1);
if (player) {
lua_pushnumber(L, player->getAttackSpeed());
} else {
lua_pushnil(L);
}
return 1;
}
note: if you're using 1.2 and you don't want the player to be interrupted while using items/walking you need to add this code: Fix #1319 by Mkalo · Pull Request #2109 · otland/forgottenserver · GitHub
Last edited by a moderator: