Advertisement
Dimitri_UA

[SA|C++]Plugin SDK. Класс шрифта (CFont).

Oct 30th, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. #include <Windows.h>
  2. #include "plugin\plugin.h"
  3. #include "game_sa\CFont.h" // класс CFont и его функции
  4. #include "game_sa\CWeaponInfo.h" // класс CWeaponInfo и переменная ms_aWeaponNames
  5. #include "game_sa\common.h" // функция FindPlayerPed(), подключение CPed.h
  6. #include "stdio.h" // функция sprintf()
  7.  
  8. using namespace plugin;
  9.  
  10. void TestFont();
  11.  
  12. BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved)
  13. {
  14.     if(reason == DLL_PROCESS_ATTACH)
  15.     {
  16.         System::RegisterPlugin("Test CFont", "DK", "test_font.asi", "1.0", 1, GAME_SA_1_0_US, NULL);
  17.         Core::RegisterFunc(FUNC_DRAWING, TestFont);
  18.     }
  19.     return TRUE;
  20. }
  21.  
  22. void TestFont()
  23. {
  24.     char string[256];
  25.     CPed *playa = FindPlayerPed(-1); // находим педа игрока
  26.     if(playa) // если пед найден
  27.     {
  28.         CWeapon &playaWep = playa->m_aWeapons[playa->m_nActiveWeaponSlot]; // Создаём ссылку на поточное оружие игрока
  29.         // форматируем строку для вывода
  30.         sprintf(string, "Player Info:~n~Health: ~r~%.2f/%.2f ~w~Armour: ~b~%.2f~n~~w~Weapon: ~y~%s ~w~Ammo: ~g~%d/%d~n~~w~ModelId: ~p~%d",
  31.             playa->m_fHealth, playa->m_fMaxHealth, playa->m_fArmour, CWeaponInfo::ms_aWeaponNames[playaWep.m_Type],
  32.             playaWep.m_dwAmmoInClip, playaWep.m_dwTotalAmmo - playaWep.m_dwAmmoInClip, playa->m_wModelIndex);
  33.         CFont::SetAlignment(ALIGN_LEFT); // выравние текста по левой стороне
  34.         CFont::SetColor(CRGBA(255, 255, 255, 255)); // цвет текста
  35.         CFont::SetOutlinePosition(1); // устанавливаем обводку текста
  36.         CFont::SetBackground(true, true); // включаем бокс
  37.         CFont::SetWrapx(500.0); // устанавливаем ширину строки
  38.         CFont::SetBackgroundColor(CRGBA(0, 0, 0, 180)); // устанавливаем цвет бокса
  39.         CFont::SetScale(0.7, 1.0); // размер шрифта
  40.         CFont::SetFontStyle(FONT_SUBTITLES); // стиль шрифта
  41.         CFont::SetProp(true); // включаем пропорциональность шрифта
  42.         CFont::PrintString(15.0, 15.0, string); // выводим текст, указаываем координаты
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement