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

Stats-Attackspeed

Sherice

Sky&Wind
Joined
Jan 20, 2012
Messages
183
Reaction score
7
Location
Sweden
Hihello, wanna know if I can somehow change the attackspeed without using a weapon with extra attackspeed.
I guess I need to do C++ :p Well if anyone can tell me how, i'd be grateful.


Thanks in advance, Sherice.
 
try this action script

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray({2433,7438,2390,2400,2408,2446}, itemEx.itemid) then
			doItemSetAttribute(itemEx.uid, "description", " +50% attack speed.")
			doItemSetAttribute(itemEx.uid, "attackspeed", 500)
			doSendMagicEffect(toPosition,30)
			doRemoveItem(item.uid)
	else
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end
return true
end
 
try this action script

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isInArray({2433,7438,2390,2400,2408,2446}, itemEx.itemid) then
            doItemSetAttribute(itemEx.uid, "description", " +50% attack speed.")
            doItemSetAttribute(itemEx.uid, "attackspeed", 500)
            doSendMagicEffect(toPosition,30)
            doRemoveItem(item.uid)
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
    end
return true
end

Hmm what's the array for? What does the script do?
 
modify isInArray line and put id of items which u wana add speedattack to it
ofc it would be weapons that is all

modify the Bold number too to make it faster or slower
Lua:
doItemSetAttribute(itemEx.uid, "attackspeed", [B]500[/B])
 
You can change the attack speed in vocations.xml?

As I said I want to change it whenever I want, not just one time for each vocation.

I guess I didn't make myself clear, I want to change the attackspeed without using any weapons, let's say you have a bar showing you how much total attackspeed you have, and I want to it change it without using any weapons, like a buff. Guess it won't work :p
 
if you don't want to make additional vocations for every vocation, you can add

don't like the solution? edit player.cpp
[cpp]uint32_t Player::getAttackSpeed()
{
Item* weapon = getWeapon();
if(weapon && weapon->getAttackSpeed() != 0)
return weapon->getAttackSpeed();

if(attackSpeed)
return attackSpeed;

return vocation->getAttackSpeed();
}[/cpp]
player.h
[cpp]
void setAttackSpeed(const uint32_t newSpeed) {attackSpeed = newSpeed;}[/cpp]
and
Code:
//
		uint32_t attackSpeed;
luascript.cpp
[cpp]//
//doPlayerSetAttackSpeed(cid, newSpeed)
lua_register(m_luaState, "doPlayerSetAttackSpeed", LuaScriptInterface::luaDoPlayerSetAttackSpeed);[/cpp]
and
[cpp]
int32_t LuaScriptInterface::luaDoPlayerSetAttackSpeed(lua_State* L)
{
//doPlayerSetAttackSpeed(cid, newSpeed)
uint32_t newSpeed = popNumber(L);

ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
{
player->attackSpeed = newSpeed;
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}[/cpp]
luascript.h
[cpp]//
static int32_t luaDoPlayerSetAttackSpeed(lua_State* L);[/cpp]
 
with a lua function or something.
2.jpg
3.jpg
6.jpg
wanhuan1-2.jpg
 
if you don't want to make additional vocations for every vocation, you can add

don't like the solution? edit player.cpp
[cpp]uint32_t Player::getAttackSpeed()
{
Item* weapon = getWeapon();
if(weapon && weapon->getAttackSpeed() != 0)
return weapon->getAttackSpeed();

if(attackSpeed)
return attackSpeed;

return vocation->getAttackSpeed();
}[/cpp]
player.h
[cpp]
void setAttackSpeed(const uint32_t newSpeed) {attackSpeed = newSpeed;}[/cpp]
and
Code:
//
        uint32_t attackSpeed;
luascript.cpp
[cpp]//
//doPlayerSetAttackSpeed(cid, newSpeed)
lua_register(m_luaState, "doPlayerSetAttackSpeed", LuaScriptInterface::luaDoPlayerSetAttackSpeed);[/cpp]
and
[cpp]
int32_t LuaScriptInterface::luaDoPlayerSetAttackSpeed(lua_State* L)
{
//doPlayerSetAttackSpeed(cid, newSpeed)
uint32_t newSpeed = popNumber(L);

ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
{
player->attackSpeed = newSpeed;
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}[/cpp]
luascript.h
[cpp]//
static int32_t luaDoPlayerSetAttackSpeed(lua_State* L);[/cpp]

I tried to put them in but then I get this error:

Code:
1>..\player.cpp(4498): error C2660: 'Player::getWeapon' : function does not take 0 arguments
1>..\luascript.cpp(1519): error C2653: 'LuaScriptInterface' : is not a class or namespace name
1>..\luascript.cpp(1519): error C2065: 'luaDoPlayerSetAttackSpeed' : undeclared identifier
1>..\luascript.cpp(3993): error C2653: 'LuaScriptInterface' : is not a class or namespace name
1>..\luascript.cpp(3996): error C3861: 'popNumber': identifier not found
1>..\luascript.cpp(3998): error C3861: 'getEnv': identifier not found
1>..\luascript.cpp(3999): error C3861: 'popNumber': identifier not found
1>..\luascript.cpp(4001): error C2248: 'Player::attackSpeed' : cannot access private member declared in class 'Player'
1>          c:\users\username\blablal\blablalba\blax1000\player.h(897) : see declaration of 'Player::attackSpeed'
1>          c:\users\username\blabalba\blalba\blax100\player.h(130) : see declaration of 'Player'
1>..\luascript.cpp(4006): error C3861: 'error': identifier not found
1>..\luascript.cpp(4006): error C3861: 'getError': identifier not found

Maybe I just put them in the wrong location, I don't know C++ that good :p
 
i think these ways are working perfectly
i dont know why u want it in source code

you can change attackspeed in items.xml

Lua:
 <attribute key="attackspeed" value="800"/>



also in vocations.xml find an
Lua:
 attackspeed="2000"

i think it is better to avoid source code

try this action script

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray({2433,7438,2390,2400,2408,2446}, itemEx.itemid) then
			doItemSetAttribute(itemEx.uid, "description", " +50% attack speed.")
			doItemSetAttribute(itemEx.uid, "attackspeed", 500)
			doSendMagicEffect(toPosition,30)
			doRemoveItem(item.uid)
	else
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end
return true
end
 
0.4? LuaScriptInterface -> LuaInterface, and don't replace whole Player::getAttackSpeed, only add 2 of my lines
 
Yup, I have 0.4.

I didn't replace it, I only added this:
Code:
{
    Item* weapon = getWeapon();
    if(weapon && weapon->getAttackSpeed() != 0)
        return weapon->getAttackSpeed();
 
    if(attackSpeed)
        return attackSpeed;
 
    return vocation->getAttackSpeed();
}

I've changed it to LuaInterface now, and it worked :D
Still get this error though:
Code:
1>..\player.cpp(4498): error C2660: 'Player::getWeapon' : function does not take 0 arguments
 
Last edited:
Back
Top