manwitch

Member
I have a Halloween mobile I want to spawn next to an online player. So can I add a spanwer in to the script for the mobile or would I need to edit the spawner script? I want there to be only one of the mobile in the world at a time, and for it to spawn next to a random on-line player. Any one point me in the right direction?
 
first the spawner system if more for creating items in/at/around a location (typically defined by the location of the spawner). I wouldn't recommend using it for this since you are looking to track a moving player. Second the mobile script is for all mobiles, monsters npc and players alike and again not recommended for your goal.

What I think would work nicely for you:
  1. Create the mobile script you want to spawn around (you say you already have this).
  2. Create a static class script. keep a static variable to keep track of the mobile, and using ServUO's initialize functionality subscribe to the login/logout events. In the login event hook save the player logging in to a collection (generic list of playermobile). On log out remove the player from the collection.
  3. Have a timer or some other trigger that creates the mobile if it's not spawned already, and moves it to a random player in the collection you've generated. (optional, keep a static variable of the last selected player, this way you can make sure the next selected player is not the last selected player.)
  4. drink a cold beverage and enjoy.
If you need more let me know but that's the basics of what I'd recommend.
 
Thank you for you response!
I wasn't intending on altering the mobile.cs, but the script for the specific mobile.
I'm a novice at scripting and up until now have only "tweaked" already written scripts. I'm going off to read and hopefully learn more about creating a static class script.
So the mobile I'm wanting to use is a headless horseman script I found on the Runuo site, credit goes to dracana, Daat99, and Rogue. So if I am getting this right, I need to make a separate script from the headless horseman script, and call the headless horseman from the new script, and in the new script have it go to the on-line player.
Is the initialize functionality of Servuo different form Runuo, because I'm using Runuo 2.5? I apologize in advance if my questions are ridiculous, lol.
 
Nothing ridiculous here.
the methods are the same. I say servuo because we're on the boards here, but there is no difference. Pretty much when the server compiles the scripts it looks for that method and runs it, allowing for hooks and set up code to run.

A static class is created like this:
Code:
//<accesser> static class <class name>
public static class SpawnHorseman {

}

for more information on static you can check the msdn:
https://docs.microsoft.com/en-us/do...ructs/static-classes-and-static-class-members
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back