sahisahi

Member
Code:
public override bool CheckCast( )
        {
       
                     if (Caster != null && Caster.Player && Caster.Region != null && Caster.Region.IsPartOf( "Felucca" ) )
            return false;
                if (Caster != null && Caster.Player && Caster.Region != null && Caster.Region.IsPartOf( "Tokuno" ) )
            return false;
                 if (Caster != null && Caster.Player && Caster.Region != null && Caster.Region.IsPartOf( "Trammel" ) )
            return false;
             if (Caster != null && Caster.Player && Caster.Region != null && Caster.Region.IsPartOf( "Ilshenar" ) )
            return false;

Got this inside some custom spell, doesnt seem to work thought, thanks
 
This could be compacted a bit more:
Code:
if ( Caster == null || !Caster.Player || Caster.Region == null )
    return false;

if ( Caster.Region.IsPartOf( "Felucca" ) || Caster.Region.IsPartOf( "Trammel" ) || Caster.Region.IsPartOf( "Ilshenar" ) || Caster.Region.IsPartOf( "Tokuno" ) )
    return false;

Also tell us what it does and what it should do, just that doesn't tell us much.
Furthermore, why are you using region instead of map? Is it because of the tokuno area in malas or such?
 
Thanks.

I have a custom region i only want player be able to use that spell inside that region .

I tried this:
Code:
  if (Caster.Region.Name != "Myregionname")
    {
        Caster.SendAsciiMessage("You cannot cast that spell here");
        return false;
    }

And it doesnt work (For some reason i have exactly the same code on a different spell and it works)

So i tried to restrict that spell to Malas only, i dont know the spell is a huge mess, if i post it your eyes will bleed.
 
Thanks.

I have a custom region i only want player be able to use that spell inside that region .

I tried this:
Code:
  if (Caster.Region.Name != "Myregionname")
    {
        Caster.SendAsciiMessage("You cannot cast that spell here");
        return false;
    }

And it doesnt work (For some reason i have exactly the same code on a different spell and it works)

So i tried to restrict that spell to Malas only, i dont know the spell is a huge mess, if i post it your eyes will bleed.

Post it as an attachment, that way those that are sensitive to eye-bleeding can read your post without needing to avert their eyes.
 
Weird, tried to cast it outside a region ''Ar'' . Also inside of it, no difference
arregion.png

Code:
 else
            {
                Caster.SendMessage(Caster.Region.Name);   // If the previous code is not working, this should tell you why....
            }

That part is not telling me the region name im in.
 
Last edited:
Try changing it to this:

Caster.SendMessage("You are unable to cast in this region: {0} <- There should be a region name there.", Caster.Region.Name);
 
Oh, so you want the spell to only be available in the specified regions?
Then do:
Code:
if ( !Caster.Region.IsPartOf( "Felucca" ) && !Caster.Region.IsPartOf( "Trammel" ) && !Caster.Region.IsPartOf( "Ilshenar" ) && !Caster.Region.IsPartOf( "Tokuno" ) )
    return false;
 
Oh, so you want the spell to only be available in the specified regions?
Then do:
Code:
if ( !Caster.Region.IsPartOf( "Felucca" ) && !Caster.Region.IsPartOf( "Trammel" ) && !Caster.Region.IsPartOf( "Ilshenar" ) && !Caster.Region.IsPartOf( "Tokuno" ) )
    return false;

For some reason it doesnt work, i tried

Code:
if ( !Caster.Region.IsPartOf( "Malas" ) )
Caster.SendAsciiMessage("You cannot cast that spell here");
return false;
Cant cast inside malas or even outside, it get the same ''You cannot cast that spell here'' message everywhere :S.

Im thinking of giving an attachment to players so they can cast spells then remove it after event is done. At least it works that way.
 
Hehe just an attachment, thats the attachment i added to fix the issue.

sorakabooka is just a random name
 
Hehe just an attachment, thats the attachment i added to fix the issue.

sorakabooka is just a random name

Try this one and let me know EXACTLY what messages get sent to the Caster when you use it.
 

Attachments

  • RegionCheckerSpell.cs
    9.2 KB · Views: 8
Try this one and let me know EXACTLY what messages get sent to the Caster when you use it.
Ok, going to try right now

Good way to debug :O

Im inside a region called Sr


Code:
 if (Caster.Region.Name != "Sr"   //means if the region is not called Sr we dont allow right?
{
                Caster.SendAsciiMessage("No puedes utilizar esa habilidad aqui eso aqui!"); //WHY THIS CODE IS NOT WORKING?
                return false; //WHY THIS CODE IS NOT WORKING?
            }

uuumm.png

In felucca Test 3 still suceed, how come?
 
Last edited:
Regions are layered, so you can actually be in multiple regions at the same time.

Typically Mobile.Region is never null because the entire map has an unnamed "Default Region", which will be why no region name is showing in the output tests. When you're in the wilderness, you're typically in the Map's top-level (default) region. The Region.IsDefault property returns true for the map's default region.

Region.IsPartOf( ) checks the hierarchy of the target's Region, so it will check the names of every parent region.

Code:
if ( Caster.Region.IsPartOf( "Custom Region Name" ) )
{
    // current region, or one of its parents, was found.
}
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back