Category:TODO: Example: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "These are the pages that requires Examples. If you are able to put a working example, then we will be very thankful for your contribution. == Requirements == * Should be fu...")
 
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 6: Line 6:


* Should be fully clear and working example
* Should be fully clear and working example
* Should be in a code block. '''Example: '''
* Should be in a code block.  
* Client-side scripts must be in red 'client-side' containers and server-side scripts must be in blue 'server-side' containers.
'''Example: '''


<syntaxhighlight lang="javascript" style="width: 98%; background-color: #E4F1FE;">
<div style="width: 98%; background-color: #E4F1FE; padding: 15px;">
function playerQuitHandler(player, exitType, reason) {
That's example will just call server side event, from client, if player screen size not a 1280x1024.
  if (exitType != "kicked") {
    var str = player.name + " quit.";
  } else {
    var str = player.name + " kicked. Reason: " + reason + ".";
  }
  console.log(str);
}


mp.events.add("playerQuit", playerQuitHandler);
{{ClientsideCode|
</syntaxhighlight>
<pre>
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();
</pre>
}}
{{ServersideCode|
<pre>
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);
</pre>
}}
</div>
* Description for the code block you provided.
* Description for the code block you provided.


When you finish your example, Don't forget to remove the '''<nowiki>[[Category:TODO: Example]]</nowiki>'''.
When you finish your example, Don't forget to remove the '''<nowiki>[[Category:TODO: Example]]</nowiki>'''.
We thank you for your contribution.

Latest revision as of 11:07, 6 December 2019

These are the pages that requires Examples.

If you are able to put a working example, then we will be very thankful for your contribution.

Requirements

  • Should be fully clear and working example
  • Should be in a code block.
  • Client-side scripts must be in red 'client-side' containers and server-side scripts must be in blue 'server-side' containers.

Example:

That's example will just call server side event, from client, if player screen size not a 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);
  • Description for the code block you provided.

When you finish your example, Don't forget to remove the [[Category:TODO: Example]].

Pages in category "TODO: Example"

The following 200 pages are in this category, out of 6,572 total.

(previous page) (next page)

A

(previous page) (next page)