Looking to add a prefix, This what I have at the moment;
So here is the error in the console:
I also have this that works but it changes the players name & it doesn't add a colour.
JavaScript:
function On_PluginInit() {
if (!Plugin.IniExists("Settings")){
var ini = Plugin.CreateIni("Settings");
ini.AddSetting("Settings", "AdminChatColour", "[color red]");
}
DataStore.Add("Prefix", "AdminChatColour", ini.GetSetting("Settings", "AdminChatColour"));
}
var Prefix = {
get AdminChatColour () { return DataStore.Get("Prefix", "AdminChatColour");}
}
function On_Chat(Player, ChatMessage) {
if(Player.Admin)){
var ChatMSG = ChatMessage.toString();
var ChatColour = Prefix.AdminChatColour;
Server.BroadcastFrom("[Admin] " + Player.Name, ChatColour ChatMSG);
ChatMessage.NewText = ""
return;
}
}
Code:
Failed to invoke Method ConsoleNetworker:SV_RunConsoleCommand with 2 parameters:
chat.say "test", Sender: Player Client (113), timestamp: 10508.713
System.Reflection.TargetInvocationException: Exception has been thrown by the ta
rget of an invocation. ---> System.Reflection.TargetInvocationException: Excepti
on has been thrown by the target of an invocation. ---> System.ArgumentOutOfRang
eException: Cannot be negative.
Parameter name: length
at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in <file
name unknown>:0
at Fougerite.Hooks.ChatReceived (.Arg& arg) [0x00000] in <filename unknown>:0
at chat.say (.Arg& arg) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (ob
ject,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invoke
Attr, System.Reflection.Binder binder, System.Object[] parameters, System.Global
ization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invoke
Attr, System.Reflection.Binder binder, System.Object[] parameters, System.Global
ization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] par
ameters) [0x00000] in <filename unknown>:0
at ConsoleSystem.RunCommand (.Arg& arg, Boolean bWantReply) [0x00000] in <file
name unknown>:0
at ConsoleSystem.RunCommand_Serverside (System.String strCommand, .NetUser use
r, System.String& StrOutput) [0x00000] in <filename unknown>:0
at ConsoleNetworker.SV_RunConsoleCommand (System.String cmd, uLink.NetworkMess
ageInfo info) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (ob
ject,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invoke
Attr, System.Reflection.Binder binder, System.Object[] parameters, System.Global
ization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invoke
Attr, System.Reflection.Binder binder, System.Object[] parameters, System.Global
ization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] par
ameters) [0x00000] in <filename unknown>:0
at #=qaL2AMBCaBLCj4lGSCwjcBVYUs_5vzeQVgu44HVklVYQ=.#=qG_E6hqIvz6NLWQQCT2N5IA==
(System.Object #=qHU1X5mvYu3s1KCG5AbpxtA==, System.Object[] #=qkZ6vhdfn7DFsLIYE
dsMCpg==) [0x00000] in <filename unknown>:0
JavaScript:
function On_PlayerConnected(Player){
if (Player.Admin){
Player.Name = "[Admin]" +Player.Name
Player.Message("Your new name is: " +Player.Name);
}
}