04.12.2018, 00:55
Olб, estou tentando fazer um sistema pra esconder objetos anexados na cabeзa do jogador apenas para ele e ficar visнvel para os outros jogadores utilizando Pawn.RakNet, sendo assim, nгo atrapalha na mira, pra isso usei OnPlayerKeyStateChange, quando o sistema verifica que o jogador estб na mira, eu uso BS_RPC e BS_WriteValue pra esconder, mas quando o jogador sai da mira simplesmente o objeto nгo volta
Macros
Cуdigo no OnPlayerKeyStateChange
Enum
Macros
PHP Code:
// HOLDING(keys)
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
PHP Code:
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
if(HOLDING(128))
{
if(GetPlayerWeapon(playerid) == 34)
{
if(IsPlayerAttachedObjectSlotUsed(playerid, 0))
{
new BitStream:bs = BS_New();
BS_WriteValue(bs,
PR_UINT16, playerid,
PR_UINT32, 0,
PR_BOOL, 0);
BS_RPC(bs, playerid, 113);
BS_Delete(bs);
}
}
}
else if(RELEASED(128))
{
if(IsPlayerAttachedObjectSlotUsed(playerid, 0))
{
new BitStream:bs = BS_New();
BS_WriteValue(
bs,
PR_UINT16, playerid,
PR_UINT32, 0,
PR_BOOL, 1,
PR_INT32, e_Player_Attached[playerid][ObjID],
PR_UINT32, e_Player_Attached[playerid][BoneID],
PR_FLOAT, e_Player_Attached[playerid][oPosX],
PR_FLOAT, e_Player_Attached[playerid][oPosY],
PR_FLOAT, e_Player_Attached[playerid][oPosZ],
PR_FLOAT, e_Player_Attached[playerid][orPosX],
PR_FLOAT, e_Player_Attached[playerid][orPosY],
PR_FLOAT, e_Player_Attached[playerid][orPosZ],
PR_FLOAT, e_Player_Attached[playerid][oScaleX],
PR_FLOAT, e_Player_Attached[playerid][oScaleY],
PR_FLOAT, e_Player_Attached[playerid][oScaleZ]
);
BS_RPC(bs, playerid, 113);
BS_Delete(bs);
}
}
}
PHP Code:
enum ATTACH_DATA_OBJ
{
ObjID,
BoneID,
Float:oPosX,
Float:oPosY,
Float:oPosZ,
Float:orPosX,
Float:orPosY,
Float:orPosZ,
Float:oScaleX,
Float:oScaleY,
Float:oScaleZ
};
new e_Player_Attached[MAX_PLAYERS][ATTACH_DATA_OBJ];