_=Gigant=_
Известный
- 144
- 221
C++:
uint8_t getPlayerWeaponModelID(int iPlayerID)
{
if (g_Players == NULL || iPlayerID < 0 || iPlayerID > SAMP_MAX_PLAYERS)
return NULL;
if (iPlayerID == g_Players->sLocalPlayerID)
{
if (g_Players->pLocalPlayer->pSAMP_Actor == NULL)
return NULL;
return g_Players->pLocalPlayer->onFootData.byteCurrentWeapon;
}
if (g_Players->pRemotePlayer[iPlayerID]->pPlayerData == NULL)
return NULL;
return g_Players->pRemotePlayer[iPlayerID]->pPlayerData->onFootData.byteCurrentWeapon;
}
const char* getPlayerWeapon(int iPlayerID)
{
if (g_Players == NULL || iPlayerID < 0 || iPlayerID > SAMP_MAX_PLAYERS)
return NULL;
if (iPlayerID == g_Players->sLocalPlayerID)
{
for (int wep = 0; weapon_list[wep].name != nullptr; wep++)
{
const struct weapon_entry *weapon = &weapon_list[wep];
if (weapon->id == getPlayerWeaponModelID(iPlayerID))
return weapon->name;
}
}
if (g_Players->pRemotePlayer[iPlayerID] == NULL)
return NULL;
if (g_Players->pRemotePlayer[iPlayerID]->pPlayerData == NULL)
return NULL;
for (int wep = 0; weapon_list[wep].name != nullptr; wep++)
{
const struct weapon_entry *weapon = &weapon_list[wep];
if (weapon->id == getPlayerWeaponModelID(iPlayerID))
return weapon->name;
}
return NULL;
}
here if someone need to get current player weapon name
usage: ("%s", getPlayerWeapon(playerid));
Target Selector with multiple options for samp
C++:
void renderTargetSelector(int PlayerID, byte BONE_ID_BOX, byte BONE_ID_TARGET, byte BONE_ID_MY, byte HP_BAR_BONE, float box_width, float box_add_x_pos, float box_height, float box_add_y_pos
, bool DrawLine, bool DrawBox, bool bShowTargetPos, int pos_text_add_x, int pos_text_add_y, bool AddHealthBar, bool bShowHPValue, float hp_bar_width, float hp_bar_height
, bool bCopyTargetRotation, bool bFollowTarget
, D3DCOLOR COLOR_HP_BAR, D3DCOLOR COLOR_POS_TEXT, D3DCOLOR COLOR_SAME, D3DCOLOR COLOR_BOX, D3DCOLOR COLOR_LINE
, bool bUseSameColors, bool bUseTargetColor, bool bUseCustomColors)
{
traceLastFunc("renderTargetSelector()");
if (cheat_state->_generic.cheat_panic_enabled)
return;
if (!pGameInterface)
return;
if (!g_dwSAMP_Addr || !g_SAMP || !g_Players)
return;
if (gta_menu_active())
return;
actor_info * me = actor_info_get(ACTOR_SELF, NULL);
actor_info * target = getGTAPedFromSAMPPlayerID(PlayerID);
if (!me)
return;
if (!target)
return;
CPed *pPedTarget = pGameInterface->GetPools()->GetPed((DWORD*)target);
CPed *pPedSelf = pGameInterface->GetPools()->GetPed((DWORD*)me);
D3DXVECTOR3 box_get_vec, target_vec_box_set, target_pos_get, render_pos, hp_bar_check, hp_bar_render;
CVector target_bone_for_box_vec = GetBonePosition(PlayerID, BONE_ID_BOX);
CVector target_mainbone_vec = GetBonePosition(PlayerID, BONE_ID_TARGET);
CVector target_hpbar_bone_vec = GetBonePosition(PlayerID, HP_BAR_BONE); // hp bar set
CVector my_bone_vec = GetBonePosition(ACTOR_SELF, BONE_ID_MY);
float * f_pos = &target->base.matrix[4 * 3];
box_get_vec.x = CVecToD3DXVEC(target_bone_for_box_vec).x;
box_get_vec.y = CVecToD3DXVEC(target_bone_for_box_vec).y;
box_get_vec.z = CVecToD3DXVEC(target_bone_for_box_vec).z;
CalcScreenCoors(&box_get_vec, &target_vec_box_set);
D3DCOLOR color_target = samp_color_get(PlayerID);
if (render)
{
if (bShowTargetPos)
{
char print_pos[128];
target_pos_get.x = f_pos[0];
target_pos_get.y = f_pos[1];
target_pos_get.z = f_pos[2];
CalcScreenCoors(&target_pos_get, &render_pos);
if (render_pos.z < 1.0f)
{
sprintf(print_pos, "Pos X %0.02f Y %0.02f Z %0.02f", target_pos_get.x, target_pos_get.y, target_pos_get.z);
if (bUseSameColors)
{
pD3DFont_3DInformer->PrintShadow(render_pos.x + pos_text_add_x, render_pos.y + pos_text_add_y, COLOR_SAME, print_pos);
}
else if (bUseTargetColor)
{
pD3DFont_3DInformer->PrintShadow(render_pos.x + pos_text_add_x, render_pos.y + pos_text_add_y, color_target, print_pos);
}
else if (bUseCustomColors)
{
pD3DFont_3DInformer->PrintShadow(render_pos.x + pos_text_add_x, render_pos.y + pos_text_add_y, COLOR_POS_TEXT, print_pos);
}
}
}
if (bUseSameColors)
{
if (DrawBox)
render->D3DBox(target_vec_box_set.x + box_add_x_pos, target_vec_box_set.y + box_add_y_pos, box_width, box_height, COLOR_SAME);
if (DrawLine)
render->DrawLine(CVecToD3DXVEC(target_mainbone_vec), CVecToD3DXVEC(my_bone_vec), COLOR_SAME);
}
else if (bUseTargetColor)
{
if (DrawBox)
render->D3DBox(target_vec_box_set.x + box_add_x_pos, target_vec_box_set.y + box_add_y_pos, box_width, box_height, color_target);
if (DrawLine)
render->DrawLine(CVecToD3DXVEC(target_mainbone_vec), CVecToD3DXVEC(my_bone_vec), color_target);
}
else if (bUseCustomColors)
{
if (DrawBox)
render->D3DBox(target_vec_box_set.x + box_add_x_pos, target_vec_box_set.y + box_add_y_pos, box_width, box_height, COLOR_BOX);
if (DrawLine)
render->DrawLine(CVecToD3DXVEC(target_mainbone_vec), CVecToD3DXVEC(my_bone_vec), COLOR_LINE);
}
if (AddHealthBar)
{
hp_bar_check.x = CVecToD3DXVEC(target_hpbar_bone_vec).x;
hp_bar_check.y = CVecToD3DXVEC(target_hpbar_bone_vec).y;
hp_bar_check.z = CVecToD3DXVEC(target_hpbar_bone_vec).z;
CalcScreenCoors(&hp_bar_check, &hp_bar_render);
char hp_bar[128];
float hp_bar_lenght = g_Players->pRemotePlayer[PlayerID]->pPlayerData->fActorHealth + hp_bar_width;
if (bShowHPValue)
_snprintf_s(hp_bar, sizeof(hp_bar) - 1, "%u", g_Players->pRemotePlayer[PlayerID]->pPlayerData->onFootData.byteHealth);
if (bUseCustomColors)
{
render->D3DBox(hp_bar_render.x, hp_bar_render.y, hp_bar_lenght, hp_bar_height, COLOR_HP_BAR);
if(bShowHPValue)
pD3DFont_Nametags->PrintShadow(hp_bar_render.x + hp_bar_lenght, hp_bar_render.y, COLOR_HP_BAR, hp_bar);
}
else if (bUseTargetColor)
{
render->D3DBox(hp_bar_render.x, hp_bar_render.y, hp_bar_lenght, hp_bar_height, color_target);
if (bShowHPValue)
pD3DFont_Nametags->PrintShadow(hp_bar_render.x + hp_bar_lenght, hp_bar_render.y, color_target, hp_bar);
}
else if (bUseSameColors)
{
render->D3DBox(hp_bar_render.x, hp_bar_render.y, hp_bar_lenght, hp_bar_height, COLOR_SAME);
if (bShowHPValue)
pD3DFont_Nametags->PrintShadow(hp_bar_render.x + hp_bar_lenght, hp_bar_render.y, COLOR_SAME, hp_bar);
}
}
}
if (bCopyTargetRotation)
{
vect3_copy(&target->fCurrentRotation, &me->fCurrentRotation);
}
if (bFollowTarget)
{
float follow_pos_copy[3];
vect3_copy(&target->base.matrix[4 * 3], follow_pos_copy);
follow_pos_copy[2] -= 1.0f;
cheat_actor_teleport(me, follow_pos_copy, gta_interior_id_get());
}
}
Последнее редактирование: