- Joined
- Nov 17, 2010
- Messages
- 6,756
- Solutions
- 578
- Reaction score
- 5,305
Does your server have the Multiple onEquip bug?
You want to put a fancy script into your server but your onEquip function is executing 2,3,4,5, even 6 times?
Have you asked your buddy what to do, to fix the issue?
You try using storage values, or your os.time to compensate?
You've tried checking the uniquid of each item, or the itemid, before equipping the item?
You've tried checking the position of these items?
You've realized that each of these options have a flaw? The same flaw?
Well look no further! maybe..
Here is the default function almost all of us are using.
It's the "hey this has been working since 2008, so let's continue using it" copy-paste script from god who knows where
If you use this function, your in the same boat as I was.
Well, I am here to fix your issue.
Start using this.
For whatever reason we've all forgotten about boolean and his accomplishments, but never fear..
He's been hiding in the shadows, waiting for his return..
Now is his time to shine!
Jokes aside,
When you equip your item, boolean returns true, multiple times until it's checked through everything your source wants to check, then will return false the final time and equip your item.
You can test it yourself using these two quick examples.
Using above code will get you these results in console, when equipping your armor.
I haven't found any issue while using this method, and we have nearly 400 items in our server using some form of onEquip function.
Hope I helped someone with this unusual problem that has been plaguing us all for.. 8-9 years?
Cheers,
Xikini
You want to put a fancy script into your server but your onEquip function is executing 2,3,4,5, even 6 times?
Have you asked your buddy what to do, to fix the issue?
You try using storage values, or your os.time to compensate?
You've tried checking the uniquid of each item, or the itemid, before equipping the item?
You've tried checking the position of these items?
You've realized that each of these options have a flaw? The same flaw?
Well look no further! maybe..
Here is the default function almost all of us are using.
It's the "hey this has been working since 2008, so let's continue using it" copy-paste script from god who knows where
Lua:
function onEquip(cid, item, slot)
-- script here
return callFunction(cid, item.uid, slot, boolean)
end
If you use this function, your in the same boat as I was.
Well, I am here to fix your issue.
Start using this.
Lua:
function onEquip(cid, item, slot, boolean)
if boolean == false then
-- script here
end
return callFunction(cid, item.uid, slot, boolean)
end
For whatever reason we've all forgotten about boolean and his accomplishments, but never fear..
He's been hiding in the shadows, waiting for his return..
Now is his time to shine!
Jokes aside,
When you equip your item, boolean returns true, multiple times until it's checked through everything your source wants to check, then will return false the final time and equip your item.
You can test it yourself using these two quick examples.
Lua:
function onEquip(cid, item, slot, boolean)
print(boolean)
print("Script working.")
return callFunction(cid, item.uid, slot, boolean)
end
Lua:
function onEquip(cid, item, slot, boolean)
print(boolean)
if boolean == false then
print("Script working.")
end
return callFunction(cid, item.uid, slot, boolean)
end
Code:
true
Script working.
true
Script working.
false
Script working.
Code:
true
true
false
Script working.
I haven't found any issue while using this method, and we have nearly 400 items in our server using some form of onEquip function.
Hope I helped someone with this unusual problem that has been plaguing us all for.. 8-9 years?
Cheers,
Xikini