kostya_nad

Вызовы событий клиента с сервера

Recommended Posts

kostya_nad    4

Как вызвать клиентское событие с сервера? Метод ::callRemote не существует, метод ::call не вызывает сторону клиента, лишь сервера.

Share this post


Link to post
Share on other sites
kemperrr    141
//cef
mp.trigger("eventCef", "HAHAHAH");

//client-side
mp.events.add("eventCef", test => {
  mp.events.callRemote("eventServer", test);
});

//server-side
mp.events.add("eventServer", (player, test) => {
  console.log(player.name, test) // -> "player_name", "HAHAHAH"
});

 

  • Like 1

Share this post


Link to post
Share on other sites
kostya_nad    4
Только что, kemperrr сказал:
//cef
mp.trigger("eventCef", "HAHAHAH");

//client-side
mp.events.add("eventCef", test => {
  mp.events.callRemote("eventServer", test);
});

//server-side
mp.events.add("eventServer", (player, test) => {
  console.log(player.name, test) // -> "player_name", "HAHAHAH"
});

 

 

mp.trigger - функция на клиентской стороне?

Edited by kostya_nad

Share this post


Link to post
Share on other sites
kemperrr    141
1 час назад, kostya_nad сказал:

 

mp.trigger - функция на клиентской стороне?

в CEF

Share this post


Link to post
Share on other sites
kostya_nad    4

Стой, нет. Я имею в виду, чтобы вызвать клиентское события с сервера.

Edited by kostya_nad

Share this post


Link to post
Share on other sites
kemperrr    141
45 минут назад, kostya_nad сказал:

@kemperrr, так именно с сервера как вызвать клиент?

//example

//server-side
mp.events.add("playerJoin", (player) => {
	player.call("keks", "string", 1, 2.2, true, player);
});

//client-side
mp.events.add("keks", (str, num, float, bool, player) => {
	mp.game.graphics.notify(`${str} ${num} ${float} ${bool} ${player.name}`);
});

 

  • Like 1

Share this post


Link to post
Share on other sites
kostya_nad    4
1 час назад, kemperrr сказал:
//example

//server-side
mp.events.add("playerJoin", (player) => {
	player.call("keks", "string", 1, 2.2, true, player);
});

//client-side
mp.events.add("keks", (str, num, float, bool, player) => {
	mp.game.graphics.notify(`${str} ${num} ${float} ${bool} ${player.name}`);
});

 

А, блин, спасибо!

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.