Hello everyone!!
I'm using the script by John992 that allows players to use 2 weapons
The script works like this:
on player.cpp change:
to
on weapons.h below:
add:
on weapons.cpp change:
to:
and it is working great...
But I need someone to make this script useable ony for knights...
I tried but I couldn't do it...
I made this:
on creaturescripts I made this script:
on login.lua I added:
and on creaturescripts.xml I added:
But, still any vocation can use two swords... I got no errors on console or on the server, the script just doesn't work..
BTW, I don't like to use attribute key="dualwield" because still every voc will be able to use 2 weapons, and I want every weapon on server "dual wieldable" but I don't wanna make them all to knights only...
Using TFS 0.4
Thanks already for the help everyone!!!!
--- EDIT
There is an error on the console:
I'm using the script by John992 that allows players to use 2 weapons
The script works like this:
on player.cpp change:
Code:
ret = RET_CANONLYUSEONEWEAPON;
Code:
ret = RET_NOERROR;
on weapons.h below:
Code:
const Weapon* getWeapon(const Item* item) const;
Code:
static int32_t getAttackLeft;
static int32_t getAttackRigth;
static int32_t getLeftExtraAttack;
static int32_t getRigthExtraAttack;
on weapons.cpp change:
Code:
int32_t WeaponMelee::getWeaponDamage(const Player* player, const Creature* target, const Item* item, bool maxDamage /*= false*/) const
{
int32_t attackSkill = player->getWeaponSkill(item);
int32_t attackValue = std::max((int32_t)0, (int32_t(item->getAttack() + item->getExtraAttack()) - elementDamage));
float attackFactor = player->getAttackFactor();
to:
Code:
int32_t WeaponMelee::getWeaponDamage(const Player* player, const Creature* target, const Item* item, bool maxDamage /*= false*/) const
{
int32_t getAttackLeft;
int32_t getAttackRigth;
int32_t getLeftExtraAttack;
int32_t getRigthExtraAttack;
getAttackLeft = 0;
getAttackRigth = 0;
getLeftExtraAttack = 0;
getRigthExtraAttack = 0;
if (getAttackLeft == 0)
{
if (player->getInventoryItem(SLOT_LEFT) != NULL)
{
getAttackLeft = player->getInventoryItem(SLOT_LEFT)->getAttack();
getLeftExtraAttack = player->getInventoryItem(SLOT_LEFT)->getExtraAttack();
}
else if (player->getInventoryItem(SLOT_LEFT) == NULL)
{
getAttackLeft = 0;
getLeftExtraAttack = 0;
}
}
if (getAttackRigth == 0)
{
if (player->getInventoryItem(SLOT_RIGHT) != NULL)
{
getAttackRigth = player->getInventoryItem(SLOT_RIGHT)->getAttack();
getRigthExtraAttack = player->getInventoryItem(SLOT_RIGHT)->getExtraAttack();
}
else if (player->getInventoryItem(SLOT_RIGHT) == NULL)
{
getAttackRigth = 0;
getRigthExtraAttack = 0;
}
}
int32_t attackValue = std::max((int32_t)0, (int32_t)((getAttackLeft + getLeftExtraAttack + getAttackRigth + getRigthExtraAttack) - elementDamage));
int32_t attackSkill = player->getWeaponSkill(item);
float attackFactor = player->getAttackFactor();
and it is working great...
But I need someone to make this script useable ony for knights...
I tried but I couldn't do it...
I made this:
on creaturescripts I made this script:
Code:
function isWeapon(uid) -- Function by Mock the bear.
uid = uid or 0
local f = getItemWeaponType(uid)
if f == 1 or f == 2 or f == 3 then
return TRUE
end
return FALSE
end
function onThink(cid, interval)
local item = getPlayerSlotItem(cid, 6)
if isPlayer(cid) == TRUE and isWeapon(item.uid) and isWeapon(item2.uid) and getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6 or getPlayerVocation(cid) == 7 then
bag = getPlayerSlotItem(cid, 8)
doRemoveItem(item.uid,item.type)
doAddContainerItem(bag.uid,item.itemid,item.type)
doPlayerSendCancel(cid, "You must be an oger to use two weapons.")
end
return true
end
on login.lua I added:
Code:
registerCreatureEvent(cid, "KnightOnly")
and on creaturescripts.xml I added:
Code:
<event type="think" name="KnightOnly" event="script" value="2swordeschecker.lua"/>
But, still any vocation can use two swords... I got no errors on console or on the server, the script just doesn't work..
BTW, I don't like to use attribute key="dualwield" because still every voc will be able to use 2 weapons, and I want every weapon on server "dual wieldable" but I don't wanna make them all to knights only...
Using TFS 0.4
Thanks already for the help everyone!!!!
--- EDIT
There is an error on the console:
Code:
[ERROR - CreatureScript Interface]
data/creaturescripts/scripts/2swordeschecker.lua:onThink
Description:
<luaGetThing> Thing not found
Last edited: