Difference between revisions of "Player::setAsCop"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
(yay)
 
 
Line 8: Line 8:
 
==Example==
 
==Example==
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
// todo
+
mp.events.add({
 +
    "entityStreamIn" : (entity) => {
 +
if(entity.type === 'player') // check if it's a player or not
 +
{
 +
        const isOnDuty = entity.getVariable('isOnDuty'); // setVariable when player on duty, handle it on server-side
 +
        if(isOnDuty) entity.setAsCop(true); // if this player on duty, set this player as a cop
 +
}
 +
},
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
==See also==
 
==See also==
 
{{Player_function_c}}
 
{{Player_function_c}}
 
[[Category:Clientside API]]
 
[[Category:Clientside API]]
 
[[Category:TODO: Example]]
 
[[Category:TODO: Example]]

Latest revision as of 21:08, 12 February 2020

Turns the desired ped into a cop. If you use this on the player ped, you will become almost invisible to cops dispatched for you. You will also report your own crimes, get a generic cop voice, get a cop-vision-cone on the radar, and you will be unable to shoot at other cops. SWAT and Army will still shoot at you. Toggling ped as 'false' has no effect; you must change p0's ped model to disable the effect.

Syntax

player.setAsCop(toggle);

Required Arguments

  • toggle: Boolean

Return value

  • Undefined

Example

mp.events.add({
    "entityStreamIn" : (entity) => {
	if(entity.type === 'player') // check if it's a player or not
	{
        	const isOnDuty = entity.getVariable('isOnDuty'); // setVariable when player on duty, handle it on server-side
	        if(isOnDuty) entity.setAsCop(true); // if this player on duty, set this player as a cop
	}
},

See also