- Home /
function CheckPassword():boolean{ is void?
so part of my script is:
if(networkView.RPC("CheckPassword", RPCMode.Server, Username,Password)){
Application.LoadLevel(1);
} else {
ImWrong=true;
}
then my function looks like this:
@RPC
function CheckPassword(User: String, Pass:String):boolean{
if(Network.isServer){
LoginPass=PlayerPrefs.GetString(User,"Pass");
if(LoginPass==Pass)
return true;
else
return false;
}
}
but i get an error saying
Assets/LoginScript.js(30,19): BCE0026: 'void' cannot be used in a boolean context.
is there a way to set the value of CheckPassword to false before its called? or is there a different way to fix this problem
Answer by Mike 3 · Jul 21, 2010 at 07:51 AM
No, that would mean your application would have to hang until the RPC returned a value (which can't happen).
The usual way to do this is like this:
client->server Login(user, pass)
server->client AllowLogin() or DenyLogin() depending on credentials
Alternatively, you could have a single function for the return which takes a bool - either way, it needs to be one message to server, and one message back
Your answer
Follow this Question
Related Questions
How do you achieve variables and functions that are global between scenes? What is the BEST way? 1 Answer
Error on my javascript code 1 Answer
How to access variable from another function? 2 Answers
Lower player's health from separate script. 2 Answers
Javascript Movement Script. Why am I getting these errors? 2 Answers