x


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

more ▼

asked Jul 21 '10 at 07:04 AM

Adam 3 gravatar image

Adam 3
3 3 3 5

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jul 21 '10 at 07:51 AM

Mike 3 gravatar image

Mike 3
30.7k 10 67 256

thank you i have now changed my script to work :)

Jul 21 '10 at 09:34 AM Adam 3
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3571
x852
x499

asked: Jul 21 '10 at 07:04 AM

Seen: 1692 times

Last Updated: Jul 21 '10 at 07:04 AM