OP
Xeno

Xeno

Member
ServUO Version
Publish 57
Ultima Expansion
Time Of Legends
C#:
if (from.FindBuffIndex(BuffIcon.Cunning) != -1)
{
    from.SendMessage("Cannot drnk more Cerebral Beer, you are already under it's effects.");
}

The arror I am getting is

+ CUSTOM SCRIPTS PnP/Witchery/Drink/CerebralBeer2.cs:
CS1061: Line 26: 'Mobile' does not contain a definition for 'FindBuffIndex' and no accessible extension method 'FindBuffIndex' accepting a first argument of type 'Mobile' could be found (are you missing a using directive or an assembly reference?)

I cannot think of any scripts off hand that check for a buff icon before doing something. I do not mind looking at one to see how to implement it. Any help with solving this or letting me know of a distro script I can look at would be greatly appreciated!
 
1710562104658.png

Since the table is private, you'll need to add this code to playermobile, if you need access from another script, place code in a public method you can call to get info if icon there or not!
Code:
//Code for your drink
if (from is PlayerMobile pm && pm.HasIcon(BuffIcon.Cunning))
{
            pm.SendMessage("Cannot drink more Cerebral Beer, you are already under it's effects.");
}

//Public method added to PlayerMobile
public bool HasIcon(BuffIcon icon)
{
            return m_BuffTable != null && m_BuffTable.ContainsKey(icon);
}
 
Last edited:
Thank you, I had checked BuffIcons.cs but did not find anything that looked helpful in it. I never thought to look into playermobile.cs

It came back with this error:
+ CUSTOM SCRIPTS PnP/Witchery/Drink/CerebralBeer2.cs:
CS0122: Line 26: 'PlayerMobile.m_BuffTable' is inaccessible due to its protection level
CS0165: Line 28: Use of unassigned local variable 'pm'
Scripts: One or more scripts failed to compile or no script files were found.

It looks like pm is for playermobile and it did not like the pm.SendMessage so I changed that to from.SendMessage and that error was gone. The PlayerMobile.cs shows that table as Private, is that why the protection level error? It seems like I can change that to public but don't want to edit the playermobile if possible.

EDIT: I changed private to public and it did compile but is there a better way other than editing the player mobile?
 
Thank you, I had checked BuffIcons.cs but did not find anything that looked helpful in it. I never thought to look into playermobile.cs

It came back with this error:
+ CUSTOM SCRIPTS PnP/Witchery/Drink/CerebralBeer2.cs:
CS0122: Line 26: 'PlayerMobile.m_BuffTable' is inaccessible due to its protection level
CS0165: Line 28: Use of unassigned local variable 'pm'
Scripts: One or more scripts failed to compile or no script files were found.

It looks like pm is for playermobile and it did not like the pm.SendMessage so I changed that to from.SendMessage and that error was gone. The PlayerMobile.cs shows that table as Private, is that why the protection level error? It seems like I can change that to public but don't want to edit the playermobile if possible.

EDIT: I changed private to public and it did compile but is there a better way other than editing the player mobile?
Add the public method HasIcon to player mobile

Then in CerebralBeer2 change the code from

if (from.FindBuffIndex(BuffIcon.Cunning) != -1)
{
from.SendMessage("Cannot drnk more Cerebral Beer, you are already under it's effects.");
}


To

//Code for your drink
if (from is PlayerMobile pm && pm.HasIcon(BuffIcon.Cunning))
{
pm.SendMessage("Cannot drink more Cerebral Beer, you are already under it's effects.");
}
 
Add the public method HasIcon to player mobile
Is this the part that you are referring to?
C#:
if (!BuffInfo.Enabled || m_BuffTable == null)
{
    return;
}

or is it
C#:
if (!BuffInfo.Enabled || b == null)
{
    return;
}

I am trying to learn from this as I go.

I got errors again.
+ CUSTOM SCRIPTS PnP/Witchery/Drink/CerebralBeer2.cs:
CS1061: Line 26: 'PlayerMobile' does not contain a definition for 'HasIcon' and no accessible extension method 'HasIcon' accepting a first argument of type 'PlayerMobile' could be found (are you missing a using directive or an assembly reference?)
CS0165: Line 28: Use of unassigned local variable 'pm'

I am confused by this section though because it seems it is all about resending buffs, adding buffs, or removing buffs but I do not see anything about reading current buffs though that is probably my novice-ness showing.

It also really does not like the pm.SendMessage and I am not sure why not on that one either.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back