Foakx

[SERVER -> CLIENT] player.call arguments undefined

Recommended Posts

I try to make a Callback to the Client but the Arguments are undefined.
If i Log one of the Arguments (Console.Log(argument)) it returns the correct value.
 

//----------------------SERVER-------------------------
mp.events.add("phone:insertNumber", (player, name) => {
    var number = Math.round(Math.random() * 1000000);
    db.insert(name, number);
    console.log(number);
    player.call("phone:callbackNumber", number);
});
//----------------------CLIENT-------------------------
mp.events.add("phone:callbackNumber", function(number) {
	mp.game.graphics.notify(toString(number));
	telnumber = number;
});
setTimeout(function () {
	mp.events.callRemote("phone:getNumber", name);
}, 2000);

In Console: 

Zitat

Started HTTP server at 22006 port.
(node:18348) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
sendto failed with code -1 for char 5 and length 1464.
sendto failed with code -1 for char 5 and length 1464.
sendto failed with code -1 for char 5 and length 1464.
sendto failed with code -1 for char 5 and length 1464.
284110

Ingame:

Zitat

[object Undefined]

I don't know if there is a Bug with send Arguments

Share this post


Link to post
Share on other sites
player.call("phone:callbackNumber", [number]);

[] was missing!

Share this post


Link to post
Share on other sites
vor 7 Minuten schrieb veers:
player.call("phone:callbackNumber", [number]);

[] was missing!

Sorry it was the wrong code:
 

p.events.add("phone:getNumber", (player, name) => {
  var entry = {};
  db.numbers.forEach((val) => {
    if(val["username"] == name) {
      entry = val;
    }
  });
  if(entry["username"] == null) {
    player.call("phone:callbackNotExist");
  } else {
    var num = entry["number"];
    console.log(num);
    player.call("phone:callbackNumber", num);
  }
});

with [] it return undefined too.

Share this post


Link to post
Share on other sites

I found my misstake:
toString() is not working with Numbers
I need to use ("" + number)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.