I noticed a bug with my magic weapons script and I'm not sure how to fix this.
Apperently, when your PC logs into the world, he "re-puts on" his/her clothing and weapons. This fires the "on-equip" script. Problem is, is if you never take them off, the "on-unequip" never fires.
The result?
As long as my PC wears his gloves of strength, every time the server re-starts the strength increase is permenant. I went from 79 str to 94 by simply loading UOx3 (for debug purposes) 14 times. I wasn't even logged into my PCs account.
Anyway I can fix this? This could be a terrible exploit for nearly all my magic weapon scripts.
[FIXED] OnEquip script fires on server re-start.
-
Grimson
- Developer
- Posts: 802
- Joined: Sat Jun 04, 2005 1:52 am
- Location: Germany
- Has thanked: 0
- Been thanked: 0
I guess this happens when the char is load on world loads, I'll have a look at this tomorrow.stranf wrote:Apperently, when your PC logs into the world, he "re-puts on" his/her clothing and weapons. This fires the "on-equip" script. Problem is, is if you never take them off, the "on-unequip" never fires.
You could eighter check the .online property, or check if the .socket property is not NULL, and only add the bonus when the player is online.stranf wrote:Anyway I can fix this? This could be a terrible exploit for nearly all my magic weapon scripts.
Thanks for checking into this.
The question is, is when does "dressing" the PC occur? If it occurs during worldstart, having a if "PC.online == true" check would bypass the entire issue.
If the "dressing" occurs when the PC logs in, then I'd have the same problem.
I could test this myself, and quickly write a "is online" check.
What is the correct syntax?
mChar.online = 1?
The question is, is when does "dressing" the PC occur? If it occurs during worldstart, having a if "PC.online == true" check would bypass the entire issue.
If the "dressing" occurs when the PC logs in, then I'd have the same problem.
I could test this myself, and quickly write a "is online" check.
What is the correct syntax?
mChar.online = 1?
-
Grimson
- Developer
- Posts: 802
- Joined: Sat Jun 04, 2005 1:52 am
- Location: Germany
- Has thanked: 0
- Been thanked: 0
After a quick look, it happens when the world get's loaded and not when the PC logs in. As the "dressing" is the same for PCs and NPCs, and NPCs will never log instranf wrote:Thanks for checking into this.
The question is, is when does "dressing" the PC occur? If it occurs during worldstart, having a if "PC.online == true" check would bypass the entire issue.
Edit: Forgot the second answer:
There are two ways, I prefer this at the beginning of the function:stranf wrote: I could test this myself, and quickly write a "is online" check.
What is the correct syntax?
mChar.online = 1?
Code: Select all
if( !mChar.online )
return;
You could also use
Code: Select all
if( mChar.online )
{
do some stuff only when the char is online
}
-
giwo
- Developer
- Posts: 1780
- Joined: Fri Jun 18, 2004 4:17 pm
- Location: California
- Has thanked: 0
- Been thanked: 0
Grimson, if this is happening at world load, it is probably happening when the item is created (and thus layer and container is set). Try adding a IsPostLoaded() check around the OnEquip call, this should fix the issue.
Also, just to note... that online check will mean that NPC's don't gain the benefit of the items.
Also, just to note... that online check will mean that NPC's don't gain the benefit of the items.
Scott
-
Grimson
- Developer
- Posts: 802
- Joined: Sat Jun 04, 2005 1:52 am
- Location: Germany
- Has thanked: 0
- Been thanked: 0
Will do it with my next commit.giwo wrote:Grimson, if this is happening at world load, it is probably happening when the item is created (and thus layer and container is set). Try adding a IsPostLoaded() check around the OnEquip call, this should fix the issue.
Good point, I didn't think of that.giwo wrote:Also, just to note... that online check will mean that NPC's don't gain the benefit of the items.
Grimson, shoot me a PM when this change is available, and I'll switch to my original script and debug.giwo wrote:
Grimson, if this is happening at world load, it is probably happening when the item is created (and thus layer and container is set). Try adding a IsPostLoaded() check around the OnEquip call, this should fix the issue.
Will do it with my next commit.
Yeah, I thought of that. In the meantime I'm surviving my just making the NPCs tough with the GM. IE: 'set tactics 1200, instead of 1000.Also, just to note... that online check will mean that NPC's don't gain the benefit of the items.