Category:TODO: Example: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 7: Line 7:
* Should be fully clear and working example
* Should be fully clear and working example
* Should be in a code block.  
* 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: '''
'''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);
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<syntaxhighlight lang="javascript" highlight="5">
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();
</syntaxhighlight>
</div>
 
 
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<syntaxhighlight lang="javascript">
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);
</syntaxhighlight>
</syntaxhighlight>
</div>


</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.
We thank you for your contribution.

Revision as of 02:07, 30 September 2017

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]]. We thank you for your contribution.

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)