Events::callRemote: Difference between revisions
No edit summary |
MrPancakers (talk | contribs) m (Grammar) |
||
| Line 1: | Line 1: | ||
This function used | This function is used to call a server-side event from a client-side script. | ||
==Syntax== | ==Syntax== | ||
| Line 8: | Line 8: | ||
==Example== | ==Example== | ||
This example will call the server-side event, from the client-side script, to see if the player screen size is not 1280x1024. | |||
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;"> | <div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;"> | ||
Revision as of 11:13, 28 June 2018
This function is used to call a server-side event from a client-side script.
Syntax
mp.events.callRemote(String eventName [, ...args])
Example
This example will call the server-side event, from the client-side script, to see if the player screen size is not 1280x1024.
Client-Side
let checkResolution = () => {
let res = mp.game.graphics.getScreenActiveResolution(x, y);
if (!((res.x == 1280) && (res.y == 1024))) {
mp.events.callRemote("kickMeImBad", res.x, res.y);
};
};
checkResolution();
Server-Side
let blahBlah = (player, sx, sy) => {
console.log(`${player.name} bad boy :c, his screen size ${sx}x${sy}`);
player.kick();
};
mp.events.add("kickMeImBad", blahBlah);
See Also
- Functions
- Properties