Player::registerheadshot: Difference between revisions

From RAGE Multiplayer Wiki
(Fixed example code.)
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
=== Required Arguments ===
=== Required Arguments ===
===Return value===
===Return value===
*'''unknown (to be checked)'''
*'''int'''
 
==Example==
==Example==
<syntaxhighlight lang="javascript">
{{JSContainer|
<pre>
let pedHeadShot;
let pedHeadShot;
if (pedHeadShot == null) {
    pedHeadShot = mp.players.local.registerheadshot();
    mp.gui.chat.push(`pedHeadShot: ${pedHeadShot}`);
}
mp.events.add('render', () => {
     if (pedHeadShot == null) {
     if (pedHeadShot == null) {
         pedHeadShot = mp.players.local.registerheadshot();
         pedHeadShot = mp.players.local.registerheadshot();
         mp.gui.chat.push(`pedHeadShot: ${pedHeadShot});
         mp.gui.chat.push(`pedHeadShot: ${pedHeadShot}`);
     }
     }
     if (mp.game.ped.isPedheadshotValid(pedHeadShot) && mp.game.ped.isPedheadshotReady(pedHeadShot)) {
     if (mp.game.ped.isPedheadshotValid(pedHeadShot) && mp.game.ped.isPedheadshotReady(pedHeadShot)) {
         let headshotTexture = mp.game.ped.getPedheadshotTxdString(pedHeadShot);
         const headshotTexture = mp.game.ped.getPedheadshotTxdString(pedHeadShot);
         mp.events.add(`render`, () => {
            mp.game.graphics.drawSprite(headshotTexture, headshotTexture, 0.5, 0.5, 0.1, 0.1, 0, 255, 255, 255, 100);
         mp.game.graphics.drawSprite(headshotTexture, headshotTexture, 0.5, 0.5, 0.1, 0.1, 0, 255, 255, 255, 100);
        })
     }
     }
</syntaxhighlight>
});
 
</pre>
}}
==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 16:59, 28 November 2019

Syntax

player.registerheadshot();

Required Arguments

Return value

  • int

Example

JavaScript Syntax

let pedHeadShot;
if (pedHeadShot == null) {
    pedHeadShot = mp.players.local.registerheadshot();
    mp.gui.chat.push(`pedHeadShot: ${pedHeadShot}`);
}

mp.events.add('render', () => {
    if (pedHeadShot == null) {
        pedHeadShot = mp.players.local.registerheadshot();
        mp.gui.chat.push(`pedHeadShot: ${pedHeadShot}`);
    }
    if (mp.game.ped.isPedheadshotValid(pedHeadShot) && mp.game.ped.isPedheadshotReady(pedHeadShot)) {
        const headshotTexture = mp.game.ped.getPedheadshotTxdString(pedHeadShot);
	
        mp.game.graphics.drawSprite(headshotTexture, headshotTexture, 0.5, 0.5, 0.1, 0.1, 0, 255, 255, 255, 100);
    }
});


See also