Solved New hook (RustBuster) or normal plugin...

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Hi everyone.
I want a RustBuster hook for the admin to kill a player with command. Example:
void KillPlayer (PlayerClient player)
{
player.Kill ();
}
This already works in python, java and normal modules, but does not work in RustBuster...:(
Another useful hook ... find out which player key you pressed using MODULE. Example:
In module OR for java, python ... :
if (Input.GetKeyDown ("m"))
{
// make anything
}
Java, python, modules do not discover which player key presses. Thnaks any help.
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
1: killing player is easy, Send a clientcommand to suicide or just Player.Kill()
2: Using RB you can create a client plugin to send the Key Presses to the server
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Hello greetings. Thanks for the quick response. But...
Sorry but ... I already tested everything that is possible in RB and when using suicide, only the admin is that it dies. Suicide is recognized as the part of the client that started and ran the command, since the option to put the target name does not appear. Example of target uses:
Rust.TakeDamage.KillSelf (target.playerClient.controllable.idMain, nil); // <- kill target, but not work in RB (I need feature RB version)
target.Kill (); // <- works in normal plugins not Rust Buster(I need feature RB version)
Suicide in RustBuster has no place to put the name of the victim, only dies who started the command.
RB ok, get key pressed easy, easy, but others plugins not... (I need feature normal plugins)
Do you have an example? If you have post here please, because I do not know the solution in RB to kill players with command being admin ... I also do not know solution in normal plugins (java, python, module) to find which key the player presses ...
 

MeshBenth

☒Rustʕ•ᴥ•ʔRedux☒
Member
Oct 5, 2017
48
46
8
Parts Unknown
Hello greetings. Thanks for the quick response. But...
Sorry but ... I already tested everything that is possible in RB and when using suicide, only the admin is that it dies. Suicide is recognized as the part of the client that started and ran the command, since the option to put the target name does not appear. Example of target uses:
Rust.TakeDamage.KillSelf (target.playerClient.controllable.idMain, nil); // <- kill target, but not work in RB (I need feature RB version)
target.Kill (); // <- works in normal plugins not Rust Buster(I need feature RB version)
Suicide in RustBuster has no place to put the name of the victim, only dies who started the command.
RB ok, get key pressed easy, easy, but others plugins not... (I need feature normal plugins)
Do you have an example? If you have post here please, because I do not know the solution in RB to kill players with command being admin ... I also do not know solution in normal plugins (java, python, module) to find which key the player presses ...
You can get the player and send him the command suicide
FindByPlayerClient
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Hi. Need for new weapon effect. Example, player press Fire1 (on mouse - hook RB - InputGetKey -easy get) and after produce Takedamage(on victim) or after tests and detect victim positioon ok aim, trace eyes, raycast... from attacker... then create effect kill on victim (kill scan players an apply for vctim only). General example only:

C#:
void OnFireVictim(PlayerCliente victimTarget)
{
foreach PlayerClient player in PlayerClient.FindByPlayerClientAll<Players>()
        if (player.IDSteam == victimTarget.IDSteam )
        {
           player.Kill()
        }
}
Work but normal plugins, not work RB. I judge be easy also make, but very complex create... If I use suicide hack effect (from hacks injecting network damage rads)maybe risk RB detect and ban normal players (because injection hacks). Thanks a lot.
 
Last edited by a moderator:

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Hi. Need for new weapon effect. Example, player press Fire1 (on mouse - hook RB - InputGetKey -easy get) and after produce Takedamage(on victim) or after tests and detect victim positioon ok aim, trace eyes, raycast... from attacker... then create effect kill on victim (kill scan players an apply for vctim only). General example only:

void OnFireVictim(PlayerCliente victimTarget)
{
foreach PlayerClient player in PlayerClient.FindByPlayerClientAll<Players>()
if (player.IDSteam == victimTarget.IDSteam )
{
player.Kill()
}
}
Work but normal plugins, not work RB. I judge be easy also make, but very complex create... If I use suicide hack effect (from hacks injecting network damage rads)maybe risk RB detect and ban normal players (because injection hacks). Thanks a lot.
You need a client and a server plugin for this.

Client:

You could either use the clienthurt event for this or a simple raycast upon a specific key press.

Add the hook:
C#:
RustBuster2016.API.Hooks.OnRustBusterMetabolismDamage += OnMDamage;
Code:
C#:
public void OnMDamage(DamageEvent de)
        {
            if (Input.GetKeyDown(KeyCode.Mouse2))
            {
                if (de.victim.character.alive)
                {
                    string msg = this.SendMessageToServer("kill-" + de.victim.userID);
                    if (msg.ToLower().Contains("failed"))
                    {
                        Rust.Notice.Inventory("", "Kill failed!");
                    }
                    else
                    {
                        Rust.Notice.Inventory("", "Killed: " + de.victim.client.name);
                    }
                }
            }
        }

Server:
C#:
API.OnRustBusterUserMessage += On_MessageReceived;

C#:
public void On_MessageReceived(API.RustBusterUserAPI user, Message msgc)
{
    // If the Client Plugin that is sending the message is MyClientPluginsName
    // Ensure to do this ALL the time, or you can mess up other plugin's code.
    if (msgc.PluginSender == "MyClientPluginsName")
    {
        string msg = msgc.MessageByClient;
        string[] split = msg.Split('-');
        // If The client wants to kill someone.
        if (split[0] == "kill")
        {
            Fougerite.Player player = Fougerite.Server.GetServer().FindPlayer(split[1]);
            if (player != null && player.IsOnline)
            {
                // Answer yes
                player.Kill();
                msgc.ReturnMessage = "yes";
            }
            else
            {
                msgc.ReturnMessage = "failed";
            }
        }
    }
}
 
  • Useful
Reactions: salva

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
I still do intend to do the constant communication thingy so servers can also send direct messages to the clients. Hump. >.<

I might do that soon.
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Humm... Interesting ... I will create the plugins and test to see if this mode actually works. After testing, I come back to talk about the results. Thank you very very much for the code.
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
You need a client and a server plugin for this.

Client:

You could either use the clienthurt event for this or a simple raycast upon a specific key press.

Add the hook:
C#:
RustBuster2016.API.Hooks.OnRustBusterMetabolismDamage += OnMDamage;
Code:
C#:
public void OnMDamage(DamageEvent de)
        {
            if (Input.GetKeyDown(KeyCode.Mouse2))
            {
                if (de.victim.character.alive)
                {
                    string msg = this.SendMessageToServer("kill-" + de.victim.userID);
                    if (msg.ToLower().Contains("failed"))
                    {
                        Rust.Notice.Inventory("", "Kill failed!");
                    }
                    else
                    {
                        Rust.Notice.Inventory("", "Killed: " + de.victim.client.name);
                    }
                }
            }
        }

Server:
C#:
API.OnRustBusterUserMessage += On_MessageReceived;

C#:
public void On_MessageReceived(API.RustBusterUserAPI user, Message msgc)
{
    // If the Client Plugin that is sending the message is MyClientPluginsName
    // Ensure to do this ALL the time, or you can mess up other plugin's code.
    if (msgc.PluginSender == "MyClientPluginsName")
    {
        string msg = msgc.MessageByClient;
        string[] split = msg.Split('-');
        // If The client wants to kill someone.
        if (split[0] == "kill")
        {
            Fougerite.Player player = Fougerite.Server.GetServer().FindPlayer(split[1]);
            if (player != null && player.IsOnline)
            {
                // Answer yes
                player.Kill();
                msgc.ReturnMessage = "yes";
            }
            else
            {
                msgc.ReturnMessage = "failed";
            }
        }
    }
}
It could also be communication [RPC]
Currently on my server I send messages to clients to control the weather and it works very well
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Sorry ... but in a few hours working trying, I could not make the system recognize the hooks/codes (API.RustBusterUserAPI user, Message msgc)
API.OnRustBusterUserMessage + = On_MessageReceived;
RustBuster2016.API.Hooks.OnRustBusterMetabolismDamage + = OnMDamage; ... and others...
The hooks/codes do not exist inside the code RustBuster2016 (last version). Also they do not exist in the RustBuster2016Server (last version) ... Also they are not inside Fougerite151 (last version also). I searched and tried to find but there is nothing. Unable to work the code that was posted here. Even the latest RustBuster164 version does not contain the hooks. Summary: Using the latest dlls available in Fougerite.com there are no such codes inside them .... If there is please show me where the codes are typed ... I did not find. Help me and show me. I believe I did not do anything wrong, it should have appeared ... I tried to create normal module and it was not possible. I also tried to create rust buster module and also it was not possible. Thanks and I hope some help if there is ...
 
Last edited:

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Sorry ... but in a few hours working trying, I could not make the system recognize the hooks/codes (API.RustBusterUserAPI user, Message msgc)
API.OnRustBusterUserMessage + = On_MessageReceived;
RustBuster2016.API.Hooks.OnRustBusterMetabolismDamage + = OnMDamage; ... and others...
The hooks/codes do not exist inside the code RustBuster2016 (last version). Also they do not exist in the RustBuster2016Server (last version) ... Also they are not inside Fougerite151 (last version also). I searched and tried to find but there is nothing. Unable to work the code that was posted here. Even the latest RustBuster164 version does not contain the hooks. Summary: Using the latest dlls available in Fougerite.com there are no such codes inside them .... If there is please show me where the codes are typed ... I did not find. Help me and show me. I believe I did not do anything wrong, it should have appeared ... I tried to create normal module and it was not possible. I also tried to create rust buster module and also it was not possible. Thanks and I hope some help if there is ...
Did you add references?
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Hi Dretax. But it was exactly version 164 (everything last version) that I searched for and did not have anything inside. I'll download and try again. Tahnks for the reply.
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Did you add references?
Jakkee yes I add reference on compiler list above Windows Clock and also reference:

using System;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RustBuster2016Server;
using RustBuster2016.API;
using RustBuster2016;

But do'nt work. Really there isn't inside .dll (fougerite151,dll, rustbuste2016, ). Thanks remember.
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Appear:

'Hooks' does not contain a definition for 'OnRustBusterMetabolismDamage'
I download today RustBuster2016Server.dll (update 164) and using Fougerite151 (last update) don't recognize hook...
 

watsitfts

Plugin Developer
Plugin Developer
Trusted Member
Aug 21, 2017
58
703
83
45
Parts Unknown
Finally!!! Working... I say sorry... really need use "Verifyer" on Client... then was recognized. Very thanks for help. Now I'm working trying develop weapon effects... maybe I back here if new doubts. Very thanks everyone. :D