GetPlayerCameraMode
#1

Where should I put the GetPlayerCameraMode to detect if a player is aiming? I just have no idea, I want to detect if a player is aiming and I know that I have to do something like:
pawn Код:
if(GetPlayerCameraMode(playerid) == 53)
{
// Do stuff here
}
Reply
#2

Bumb.
Reply
#3

I think you need to use OnPlayerUpdate(playerid)

Код:
public OnPlayerUpdate(playerid)
{
	if(GetPlayerCameraMode(playerid) == 46) // 46 or other camera id type
	{
	    // Do what you want there
 	}
 	
 	return 1;
}
Reply
#4

Hello!

You shouldn't use OnPlayerUpdate, this is calling 50 times per second (approximately).
Use a timer, this is better for the performance.

- Mencent
Reply
#5

Under OnPlayerWeaponShot?

Kind of :

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
             new 
cmode GetPlayerCameraMode(playerid);
            if( 
cmode == 53 )
                {
                }
        return 
1;

Reply
#6

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
Under OnPlayerWeaponShot?

Kind of :

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
             new 
cmode GetPlayerCameraMode(playerid);
            if( 
cmode == 53 )
                {
                }
        return 
1;

Hmm, no. He is trying to get if the player is aiming. He doesn't have to aim to shoot.

OT: One of the best way would be checking for camera mode under OnPlayerUpdate but like other users said, it gets called too frequently. You could create a timer and a boolean variable which when it's set to true, certain code would be executed under your timer.
Reply
#7

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Hmm, no. He is trying to get if the player is aiming. He doesn't have to aim to shoot.

OT: One of the best way would be checking for camera mode under OnPlayerUpdate but like other users said, it gets called too frequently. You could create a timer and a boolean variable which when it's set to true, certain code would be executed under your timer.
I just want the player to have the drunk effect when aiming under 30 HP
Reply
#8

Why not use OnPlayerKeySateChange?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED( KEY_HANDBRAKE ))
    {
        if(GetPlayerCameraMode(playerid) == 53)
        {
            //do stuff here
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Onfroi
Посмотреть сообщение
Why not use OnPlayerKeySateChange?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED( KEY_HANDBRAKE ))
    {
        if(GetPlayerCameraMode(playerid) == 53)
        {
            //do stuff here
        }
    }
    return 1;
}
Did you read my post above? I don't want to check if the player is shooting or whatever, I just want to check if the player is aiming and then if he has less than 30 HP there will be a Drunk Effect.
Reply
#10

Quote:
Originally Posted by dionisak0s
Посмотреть сообщение
Did you read my post above? I don't want to check if the player is shooting or whatever, I just want to check if the player is aiming and then if he has less than 30 HP there will be a Drunk Effect.
I think he did.

pawn Код:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>

// DEFINES:

// GENERAL:

#define KEY_AIM KEY_HANDBRAKE

// KEY PRESS TYPES:

#define HOLDING(%0) ((newkeys & (%0)) == (%0))
#define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))

// MAIN:

main()
{
    print("Development Mode: player_aiming.amx");
}

// CALLBACKS:

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(HOLDING(KEY_AIM))
    {
        SendClientMessage(playerid, -1, "You are now aiming.");
    }
    else if(RELEASED(KEY_AIM))
    {
        SendClientMessage(playerid, -1, "You are no longer aiming.");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)