GetPlayerCameraMode -
dionisak0s - 18.07.2015
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
}
Re: GetPlayerCameraMode -
dionisak0s - 19.07.2015
Bumb.
Re: GetPlayerCameraMode -
Mariciuc223 - 19.07.2015
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;
}
AW: GetPlayerCameraMode -
Mencent - 19.07.2015
Hello!
You shouldn't use OnPlayerUpdate, this is calling 50 times per second (approximately).
Use a timer, this is better for the performance.
- Mencent
Re : GetPlayerCameraMode -
KillerDVX - 19.07.2015
Under OnPlayerWeaponShot?
Kind of :
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new cmode = GetPlayerCameraMode(playerid);
if( cmode == 53 )
{
}
return 1;
}
Re: Re : GetPlayerCameraMode -
dominik523 - 19.07.2015
Quote:
Originally Posted by KillerDVX
Under OnPlayerWeaponShot?
Kind of :
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float: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.
Re: Re : GetPlayerCameraMode -
dionisak0s - 19.07.2015
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
Re: GetPlayerCameraMode -
Onfroi - 19.07.2015
Why not use OnPlayerKeySateChange?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED( KEY_HANDBRAKE ))
{
if(GetPlayerCameraMode(playerid) == 53)
{
//do stuff here
}
}
return 1;
}
Re: GetPlayerCameraMode -
dionisak0s - 20.07.2015
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.
Re: GetPlayerCameraMode -
SickAttack - 20.07.2015
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;
}