Synapse
Search…
CustomRoles

CustomRoles

The Synapse API allows for creating easily new roles.
The first step for creating a custom role is it to create a new class that inherits from Synapse.Api.Roles.Role and override GetRoleName(), GetRoleID() and Spawn().
In this class can you access the current player with Player
1
using Synapse.Api.Roles;
2
using System.Collections.Generic;
3
4
namespace NewRole
5
{
6
public class NewRoleName : Synapse.Api.Roles.Role
7
{
8
public override int GetRoleID() => 25; //The Id of your new CustomRole
9
10
public override string GetRoleName() => "Awesome-Role"; //The name of your custom role
11
12
public override void Spawn() //The method that is activated when the player spawn as your Role
13
{
14
Player.RoleType = RoleType.ClassD; //An Example what you can do in here it is also recommended to set health items etc.
15
}
16
}
17
}
Copied!
The next step is it to register the role in your plugin class
1
using Synapse;
2
using Synapse.Api;
3
using Synapse.Api.Plugin;
4
5
namespace FirstPlugin
6
{
7
[PluginInformation(
8
Name = "FirstPlugin",
9
Author = "Dimenzio",
10
Description = "My First Awesome Plugin",
11
LoadPriority = 0,
12
SynapseMajor = 2,
13
SynapseMinor = 7,
14
SynapsePatch = 0,
15
Version = "v.1.0.0"
16
)]
17
public class PluginClass : AbstractPlugin
18
{
19
public override void Load()
20
{
21
Server.Get.RoleManager.RegisterCustomRole<NewRole>();
22
}
23
}
24
}
Copied!
and then your basic custom role is done and you can test it with the command setclass playerid 25 <= the 25 is your role id
However, the Synapse role API has more to offer that you can access by override more of the methods in your Role class
  • GetTeamID() => The ID of the Team the Role has (by default Spectator)
  • GetFriendsID() => all teams in here are "friends" of the player and therefore they can't attack each other
  • GetEnemiesID() => all teams in here must be defeated in order to end the round (they also still have to kill all beings that must be killed by the team of your role for example when the team of your role is SCP the player of the role must always kill all ClassD, MTF, Scientiest)
  • Escape() => the method is activated when a player tries to escape.
  • Despawn() => the method is activated when the player changes his Role
Example:
1
using Synapse.Api.Roles;
2
using System.Collections.Generic;
3
4
namespace NewRole
5
{
6
public class NewRoleName : Synapse.Api.Roles.Role
7
{
8
public override int GetRoleID() => 25; //The Id of your new CustomRole
9
10
public override string GetRoleName() => "Awesome-Role"; //The name of your custom role
11
12
public override Team GetTeamID() => (int)Team.CDP; //The Team of your Role
13
14
public override void Spawn() //The method that is activated when the player spawn as your Role
15
{
16
Player.RoleType = RoleType.ClassD; //An Example what you can do in here it is also recommended to set health items etc.
17
}
18
19
public override void DeSpawn()
20
{
21
Player.SendBroadcast(5,"You are no longer my Awesome Custom Role D:")
22
}
23
24
public override List<int> GetFriendsID() => new List<int> { (int)Team.RSC }; //This means the player can't hurt or be hurt by a scientist
25
26
public virtual void Escape()
27
{
28
Player.RoleID = (int)RoleType.ClassD;
29
Player.SendBroadcast(5,"You are now a real DBoy!!");
30
}
31
32
public virtual List<int> GetEnemiesID() => new List<int> { (int)Team.CHI }; //This means this Role and Chaos must kill each other or else the round will not end
33
}
34
}
Copied!
You can set a player to your new Role with player.RoleID = 20; and then the rest is up to you to use the event and create special abilities for your custom role.
Copy link