Error Hooks.OnResearch

Komrad

Member
Member
May 14, 2017
89
4
6
30
In general, I do the abolition of study - but study passes - repair it?

C#:
re.Cancel()
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
And they did not discover something new ...
C#:
public static void PerResearch(ResearchEvent re)
        {
            IniParser Settings = new IniParser(Path.Combine(Loader.Folder + "\\item", re.ItemName + ".ac"));
            if (Settings.GetSetting(re.ItemName, "isResearchable") == "false")
            {
                re.Cancel();
                re.Player.Message("Don't Research");
            }
        }
Sms comes - but study is being studied
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
And they did not discover something new ...
C#:
public static void PerResearch(ResearchEvent re)
        {
            IniParser Settings = new IniParser(Path.Combine(Loader.Folder + "\\item", re.ItemName + ".ac"));
            if (Settings.GetSetting(re.ItemName, "isResearchable") == "false")
            {
                re.Cancel();
                re.Player.Message("Don't Research");
            }
        }
Sms comes - but study is being studied
Maybe your ini file has incorrect ItemNames?
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
And they did not discover something new ...
C#:
public static void PerResearch(ResearchEvent re)
        {
            IniParser Settings = new IniParser(Path.Combine(Loader.Folder + "\\item", re.ItemName + ".ac"));
            if (Settings.GetSetting(re.ItemName, "isResearchable") == "false")
            {
                re.Cancel();
                re.Player.Message("Don't Research");
            }
        }
Sms comes - but study is being studied
I already made a plugin with that, it works perfectly .... I can give you the code when it is on my pc .... Now I'm with my mobile phone xd
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
And they did not discover something new ...
C#:
public static void PerResearch(ResearchEvent re)
        {
            IniParser Settings = new IniParser(Path.Combine(Loader.Folder + "\\item", re.ItemName + ".ac"));
            if (Settings.GetSetting(re.ItemName, "isResearchable") == "false")
            {
                re.Cancel();
                re.Player.Message("Don't Research");
            }
        }
Sms comes - but study is being studied
Is the hook being called, Did you change the hook name?
 
  • Agree
Reactions: salva

Komrad

Member
Member
May 14, 2017
89
4
6
30
Here is a pancake - the recipe does not really appear, but the report of a new study comes + takes the Research Kit 1
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
Yes messages are coming - and do not hold me for a stupid newbie - there really are some problems with the hook
Wtf !!
1 nobody here is treating you like a newbie ... I think since you created this thread we are trying to help you ...
2 my opinion is that there is no problem with the hook (because I currently use a plugin on my server with that hook)
3 I totally agree with @Jakkee , maybe you're not using the hook well

You should try it like this:

C#:
public void OnResearch(ResearchEvent re)
        {
            if (re.ItemName == "M4")
            {
                re.Player.Message("You cant craft M4, regards!!");
                re.Cancel();
            }
        }
This code I have not tried, but ...., should work, what do you think? regards!!!
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
I used this code

Code:
public override void Initialize()
        {
Hooks.OnResearch += Hooks_OnResearch;
        }

private void Hooks_OnResearch(ResearchEvent re)
        {
            re.Cancel();
        }
In the end, I get such a picture - the study does NOT appear in the crafts menu, but the message appears that the craft is passed + one is removed. Research Kit 1
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
I used this code

Code:
public override void Initialize()
        {
Hooks.OnResearch += Hooks_OnResearch;
        }

private void Hooks_OnResearch(ResearchEvent re)
        {
            re.Cancel();
        }
In the end, I get such a picture - the study does NOT appear in the crafts menu, but the message appears that the craft is passed + one is removed. Research Kit 1
what??? your code is bad!! try this...

C#:
public override void Initialize()
        {
          Fougerite.Hooks.OnResearch += OnResearch;
        }
public override void DeInitialize()
        {
          Fougerite.Hooks.OnResearch -= OnResearch;
        }
public void OnResearch(ResearchEvent re)
        {
            if (re.ItemName == "M4")
            {
                re.Player.Message("You cant craft M4, regards!!");
                re.Cancel();
               //Also return research kit..
                re.Player.Inventory.AddItem("Research Kit 1",1);
                return;
            }      
        }
regards!!
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
what??? your code is bad!! try this...

C#:
public override void Initialize()
        {
          Fougerite.Hooks.OnResearch += OnResearch;
        }
public override void DeInitialize()
        {
          Fougerite.Hooks.OnResearch -= OnResearch;
        }
public void OnResearch(ResearchEvent re)
        {
            if (re.ItemName == "M4")
            {
                re.Player.Message("You cant craft M4, regards!!");
                re.Cancel();
               //Also return research kit..
                re.Player.Inventory.AddItem("Research Kit 1",1);
                return;
            }     
        }
regards!!
Well, if the player had a set for several uses? Yes and anyway, the report of a successful study comes
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
Well, if the player had a set for several uses? Yes and anyway, the report of a successful study comes
But ... does it work for you ???? Why do you see everything so negative ???
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
But ... does it work for you ???? Why do you see everything so negative ???
Because the players will get confused - I have a changed craft craft, when people want to learn craft paper they write in the chat that "you have successfully studied the recipe of paper", although it is forbidden
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
Bug and that in the hook is not checked whether the study was canceled - still writes a message + takes the item
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
I showed you the same complete code ...

Code:
public override void Initialize()
        {
          Fougerite.Hooks.OnResearch += OnResearch;
        }
public override void DeInitialize()
        {
          Fougerite.Hooks.OnResearch -= OnResearch;
        }
public void OnResearch(ResearchEvent re)
        {
            if (re.ItemName == "Paper")
            {
                re.Player.Message("You cant craft Paper - Prohibited object for a while!!");
                re.Cancel();
            }    
        }
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
I showed you the same complete code ...

Code:
public override void Initialize()
        {
          Fougerite.Hooks.OnResearch += OnResearch;
        }
public override void DeInitialize()
        {
          Fougerite.Hooks.OnResearch -= OnResearch;
        }
public void OnResearch(ResearchEvent re)
        {
            if (re.ItemName == "Paper")
            {
                re.Player.Message("You cant craft Paper - Prohibited object for a while!!");
                re.Cancel();
            } 
        }
Because you must make a return; ...... "I explain it to you above xd :D"

C#:
if (re.ItemName == "Paper")
            {
                re.Player.Message("You cant craft Paper - Prohibited object for a while!!");
                re.Cancel();
                //TRY ADD RETURN
                return;
            }