Welcome,
Guest
. Please
login
or
register
.
May 20, 2025, 11:23:56 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
TNet 3 Support
»
"Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
« previous
next »
Print
Pages: [
1
]
Author
Topic: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?" (Read 8572 times)
Etarnalazure
Guest
"Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
on:
August 10, 2013, 12:12:42 AM »
Hey again!
I've started getting this error, and I have no idea why!
I mean, its its right there!
protected
override
void
OnSubmit
(
string
text
)
{
tno
.
Send
(
"OnChat"
, Target
.
All
, TNManager
.
playerID
, text
)
;
}
[
RFC
]
void
OnChat
(
int
playerID,
string
text
)
{
Color color
=
Color
.
white
;
Player sender
=
TNManager
.
GetPlayer
(
playerID
)
;
if
(
sender
!=
null
)
{
// If the message was not sent by the player, color it differently and play a sound
if
(
playerID
!=
TNManager
.
playerID
)
color
=
new
Color
(
0
.
6f, 1
.
0f, 0f
)
;
// Embed the player's name into the message
text
=
string
.
Format
(
"[{0}]: {1}"
, sender
.
name
, text
)
;
}
Add
(
text, color
)
;
if
(
notificationSound
!=
null
)
NGUITools
.
PlaySound
(
notificationSound
)
;
}
As you can see, the RFC is right there.
So, I dont really understand why its giving me that error.
Full Error:
Unable to execute function
'OnChat'
.
Did
you forget an
[
RFC
]
prefix, perhaps
?
UnityEngine
.
Debug
:
LogError
(
Object
,
Object
)
TNObject
:
FindAndExecute
(
UInt32,
String
,
Object
[
]
)
(
at Assets
/
Tools
/
TNet
/
Client
/
TNObject
.
cs
:
459
)
TNObject
:
SendRFC
(
UInt32,
Byte
,
String
, Target, Boolean,
Object
[
]
)
(
at Assets
/
Tools
/
TNet
/
Client
/
TNObject
.
cs
:
658
)
TNObject
:
Send
(
String
, Target,
Object
[
]
)
(
at Assets
/
Tools
/
TNet
/
Client
/
TNObject
.
cs
:
523
)
UIGameChat
:
OnSubmit
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
Custom
/
UI
/
UIGameChat
.
cs
:
45
)
UIChat
:
OnSubmitInternal
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
Generic
/
UI
/
UIChat
.
cs
:
129
)
UIInput
:
Append
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UIInput
.
cs
:
417
)
UIInput
:
OnInput
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UIInput
.
cs
:
385
)
UnityEngine
.
GameObject
:
SendMessage
(
String
,
Object
, SendMessageOptions
)
UICamera
:
Notify
(
GameObject,
String
,
Object
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UICamera
.
cs
:
679
)
UICamera
:
Update
(
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UICamera
.
cs
:
820
)
Logged
pyscho2day
Jr. Member
Thank You
-Given: 2
-Receive: 0
Posts: 74
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #1 on:
August 10, 2013, 12:20:50 AM »
If this is a static object, rebuild the object. Not sure why atm but it seams that some times static objects get stuck in not noticing their [RFC]'s. If it works for you please post as you will be at least the 3rd person that has this issue. Also if this does fix the issue did you have a prior version of TNET and upgrade recently?
Logged
Etarnalazure
Guest
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #2 on:
August 10, 2013, 03:34:50 AM »
Its not static, though I did build it anyway just to make sure, didnt work.
I checked for updates, there were none. The weird thing is.. It worked yesterday, I havent touched the script since..
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #3 on:
August 10, 2013, 10:40:14 AM »
Check the IDs of your TNObjects in the scene. Chances are you have more than one with the same ID, so it's going to the wrong object.
P.S. Modify the Debug.Logs in the two FindAndExecute functions like so for additional info:
Debug
.
LogError
(
"Unable to execute function with ID of '"
+
funcID
+
"'. Make sure there is a script that can receive this call.
\n
"
+
"GameObject: "
+
GetHierarchy
(
obj
.
gameObject
)
, obj
.
gameObject
)
;
Debug
.
LogError
(
"Unable to execute function '"
+
funcName
+
"'. Did you forget an [RFC] prefix, perhaps?
\n
"
+
"GameObject: "
+
GetHierarchy
(
obj
.
gameObject
)
, obj
.
gameObject
)
;
Logged
Etarnalazure
Guest
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #4 on:
August 10, 2013, 07:12:46 PM »
Changed the ID to something I know for sure is not used, same deal.
I put in the new debug info as well;
Unable to execute function
'OnChat'
.
Did
you forget an
[
RFC
]
prefix, perhaps
?
GameObject
:
"Camera/Chat/ChatWindow"
UnityEngine
.
Debug
:
LogError
(
Object
,
Object
)
TNObject
:
FindAndExecute
(
UInt32,
String
,
Object
[
]
)
(
at Assets
/
Tools
/
TNet
/
Client
/
TNObject
.
cs
:
464
)
TNObject
:
SendRFC
(
UInt32,
Byte
,
String
, Target, Boolean,
Object
[
]
)
(
at Assets
/
Tools
/
TNet
/
Client
/
TNObject
.
cs
:
664
)
TNObject
:
Send
(
String
, Target,
Object
[
]
)
(
at Assets
/
Tools
/
TNet
/
Client
/
TNObject
.
cs
:
529
)
UIGameChat
:
OnSubmit
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
Custom
/
UI
/
UIGameChat
.
cs
:
45
)
UIChat
:
OnSubmitInternal
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
Generic
/
UI
/
UIChat
.
cs
:
129
)
UIInput
:
Append
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UIInput
.
cs
:
417
)
UIInput
:
OnInput
(
String
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UIInput
.
cs
:
385
)
UnityEngine
.
GameObject
:
SendMessage
(
String
,
Object
, SendMessageOptions
)
UICamera
:
Notify
(
GameObject,
String
,
Object
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UICamera
.
cs
:
679
)
UICamera
:
Update
(
)
(
at Assets
/
NGUI
/
Scripts
/
UI
/
UICamera
.
cs
:
820
)
Logged
Etarnalazure
Guest
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #5 on:
August 10, 2013, 07:23:14 PM »
The rest of the RFC's work though..
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #6 on:
August 10, 2013, 10:26:29 PM »
So Camera/Chat/ChatWindow game object has the script that has the [RFC] void OnChat() function? And that's the exact same object with the TNObject on it? And it doesn't have a parent object with a TNObject on it?
Logged
Etarnalazure
Guest
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #7 on:
August 11, 2013, 04:26:45 AM »
Yeps,
Heres a screenshot:
http://i.imgur.com/Lx8FNty.png
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #8 on:
August 11, 2013, 12:35:55 PM »
Curious. Well, something is building its list of RFCs before all of them are present.
Do this: open TNBehaviour and change the 'tno' function to this:
public
TNObject tno
{
get
{
if
(
mTNO
==
null
)
{
mTNO
=
GetComponent
<
TNObject
>
(
)
;
if
(
mTNO
!=
null
)
mTNO
.
rebuildMethodList
=
true
;
}
return
mTNO
;
}
}
Logged
Etarnalazure
Guest
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #9 on:
August 12, 2013, 12:50:11 PM »
Nope, still wont work.
Besides, all the other RFC's work just fine. Could it be the script?
I'll post the entirety of the script. It should largely be the same as the one from Starlink except that I'm using pixelSize instead of size.
using
UnityEngine
;
using
TNet
;
/// <summary>
/// Networked chat logic. Takes care of sending and receiving of chat messages.
/// </summary>
[
RequireComponent
(
typeof
(
TNObject
)
)
]
public
class
UIGameChat
:
UIChat
{
TNObject tno
;
/// <summary>
/// Sound to play when a new message arrives.
/// </summary>
public
AudioClip notificationSound
;
/// <summary>
/// If you want the chat window to only be shown in multiplayer games, set this to 'true'.
/// </summary>
public
bool
destroyIfOffline
=
false
;
/// <summary>
/// We want to listen to input field's events.
/// </summary>
void
Start
(
)
{
if
(
destroyIfOffline
&&
!
TNManager
.
isInChannel
)
{
Destroy
(
gameObject
)
;
}
else
tno
=
GetComponent
<
TNObject
>
(
)
;
}
/// <summary>
/// Send the chat message to everyone else.
/// </summary>
protected
override
void
OnSubmit
(
string
text
)
{
tno
.
Send
(
"OnChat"
, Target
.
All
, TNManager
.
playerID
, text
)
;
}
[
RFC
]
void
OnChat
(
int
playerID,
string
text
)
{
Color color
=
Color
.
white
;
Player sender
=
TNManager
.
GetPlayer
(
playerID
)
;
if
(
sender
!=
null
)
{
// If the message was not sent by the player, color it differently and play a sound
if
(
playerID
!=
TNManager
.
playerID
)
color
=
new
Color
(
0
.
6f, 1
.
0f, 0f
)
;
// Embed the player's name into the message
text
=
string
.
Format
(
"[{0}]: {1}"
, sender
.
name
, text
)
;
}
Add
(
text, color
)
;
if
(
notificationSound
!=
null
)
NGUITools
.
PlaySound
(
notificationSound
)
;
}
void
OnNetworkPlayerJoin
(
Player p
)
{
Add
(
p
.
name
+
" has joined the game."
)
;
}
void
OnNetworkPlayerLeave
(
Player p
)
{
Add
(
p
.
name
+
" has left the game."
)
;
}
}
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #10 on:
August 12, 2013, 03:31:14 PM »
It doesn't work with that script because it's not derived from TNBehaviour. See how in Start it gets the TNObject component manually? When you do that, you also have to do tno.rebuildMethodList = true;
Logged
Etarnalazure
Guest
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #11 on:
August 12, 2013, 03:47:22 PM »
Yeps, works now
Logged
swizzersweet
Newbie
Thank You
-Given: 0
-Receive: 2
Posts: 6
Re: "Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"
«
Reply #12 on:
June 22, 2014, 10:26:02 AM »
Was pulling my hair out on this one. Also make sure your visibility modifier let's TNET find your function. Eg, a private method won't be able to be called
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
TNet 3 Support
»
"Unable to execute function 'OnChat'. Did you forget an [RFC] prefix, perhaps?"