SendMessage QuestStarted has no receiver! issue..

Hello, I am currently learning the basics of C# and I am trying to build a RPG game. Now I 've downloaded a package to help me setup a quest system, the demo project works fine and i can also edit it without any problem but when I import the scripts into my own project I keep getting this error “SendMessage QuestStarted has not receiver” and “SendMessage QuestEnded has not receiver”, I get this error when I want to talk to an npc who has the quest script attached to him. This is the script where the error is coming from.

using UnityEngine;
using System.Collections.Generic;

public class QuestGui : MonoBehaviour {

	public Vector2 questSize=new Vector2(800,371);
	public GUISkin questSkin;
	public bool showQuestsSummary=true;
	public string showQuestsAction="ShowQuests";

	private bool hideStatusInDialog=false;
	
	private bool showQuests=false;
	private Vector2 scrollPosition;
	private Quest currentQuest=null;
	private float svw=800;
	private float svh=256+20+30+50+15;
	
	private string questText="";
	private float questTextStartSec=0f;
	
	public void Start(){
		svw=questSize.x;
		svh=questSize.y;
	}
	
	public void Update(){
		if (!showQuests  Input.GetButtonUp(showQuestsAction)  !Parley.GetInstance().IsInGui()){
			Parley.GetInstance().SetInGui(true);
			showQuests=true;
			currentQuest=null;
			questText="";				
			SendMessage("QuestsStarted",SendMessageOptions.RequireReceiver);
		}
	}

	
	public void OnGUI(){
		if (Parley.GetInstance()==null){
			return;
		}
		
		// Return if we are in a dialog
		if (hideStatusInDialog  Parley.GetInstance().GetCurrentDialog()!=null){
			return;
		}
		if (questSkin!=null){
			GUI.skin=questSkin;
		}
		
		if (showQuests  Parley.GetInstance().GetCurrentDialog()==null){
			ShowQuestDetails();
		}
		
		if (showQuestsSummary){
			ShowQuestList();
		}
	}

	public void SelectQuest(Quest q){
		currentQuest=q;
		questText=currentQuest.description+"\n\n";
		
		foreach (Objective o in q.objectives){
			if (o.open){
				if (o.completed){
					questText+=" - "+o.GetStatus()+" ("+(o.optional?"Optional, ":"")+"done)\n";
				}else{
					questText+=" - "+o.GetStatus()+(o.optional?" (Optional)":"")+"\n";
				}
			}
		}
		
		questTextStartSec=Time.time;
	}
	
	public void ShowQuestDetails(){
		Rect skillView=new Rect((Screen.width-svw)/2,(Screen.height-svh)/2,svw,svh);
		Rect skillBox=new Rect(0,0,svw,svh);
	    GUI.BeginGroup (skillView);
	    
	    	GUI.Label(skillBox,"","box");
	    	Rect titleBox=new Rect(150,0,skillBox.width-300,22);
	    	if (currentQuest==null){
				GUI.Label(titleBox,"Quests","window");
			}else{
				GUI.Label(titleBox,currentQuest.name,"window");
			}
	    	
	    	// Close button
        	if (GUI.Button(new Rect(skillBox.width-42,0,42,16),"Close")){
				showQuests=false;
				Parley.GetInstance().SetInGui(false);
				SendMessage("QuestsEnded",SendMessageOptions.RequireReceiver);
	    	}
	    	
	 		Rect skillTextRect=new Rect(20,40,svw-40,skillView.height-180);
			int textPos=(int)((Time.time-questTextStartSec)*50);
			textPos=Mathf.Min(questText.Length,textPos);
			
	        GUI.Label(skillTextRect,questText.Substring(0,textPos));
	
			// Draw options only when all of text has been displayed
	       	if (textPos>=questText.Length){
	        	int countOptions=0;
	        	foreach (Quest o in Parley.GetInstance().GetQuests()){
	        		if (o.open){
		        		countOptions++;
	        		}
	        	}
	        	        	        	
				Rect scrollPanelRect=new Rect(10,skillView.height-130,svw-20,120);
				Rect skillPanelRect=new Rect(0,0,svw-30,countOptions*25);
				scrollPosition=GUI.BeginScrollView(scrollPanelRect, scrollPosition, skillPanelRect);
					countOptions=0;
		        	foreach (Quest o in Parley.GetInstance().GetQuests()){
		        		if (o.open){
		        			Rect  buttonRect=new Rect(0,countOptions*25,svw-30,20);
				        	
				  			if (GUI.Button(buttonRect, o.name,o.completed?"toggle":"button")) {
					  			SelectQuest(o);
					  		}
					  		countOptions++;
					  	}
		        	}
	
				GUI.EndScrollView ();
			}						
	    GUI.EndGroup ();
	}
	
	private void ShowQuestList(){	
		int q=0;
		List<Quest> quests=Parley.GetInstance().GetQuests();
		for (int t=quests.Count-1;t>=0;t--){
			Quest qq=quests[t];
			if (qq.open  (!qq.completed || Time.time-3<qq.lastEffected)){
				Rect currentQuestDisplay=new Rect(Screen.width-190,Screen.height-70-80*q,180,60);
				GUI.BeginGroup(currentQuestDisplay,qq.name,(Time.time-3<qq.lastEffected)?"QuestSummaryFocus":"QuestSummary");
				GUI.Label(new Rect(3,20,currentQuestDisplay.width-6,currentQuestDisplay.height-23),qq.GetStatus(),"Tiny");
				GUI.EndGroup();
				q++;
			}
		}
	}	
}

Now since I’m just a total beginner, I really don’t know where to look, it has to do something with the RequireReceiver but I don’t know exactly what.

Thanks in advance!

You are sending a message that require at least one script to receive it, which is good for debugging of course. You need to have a script that has a method exactly named QuestsStarted, and it must exist in the current scene. One way of looking at it is the SendMessage method is going to send Request to each gameobject in the scene asking if it has a particular method, in your case QuestsStarted, if it does, it will be executed under most conditions, now with the option you have set, it will throw an exception/error if it can’t find a script… at least one, that can execute this request.

Thanks for your reply! I looked in all the scripts I have that came with this quest system but I can’t find any method called “QuestsStarted”… The only place i can find it is in the script i posted above, could there be another explanation?

The SendMessage method is designed to call a method from a remote script without having a reference to that object, so you have to make a method called QuestsStarted, thats the whole point

Thanks for the explanation, I created a new script with the method QuestStarted and attached it to my player and everything works now :slight_smile: