#include #include "plugin\plugin.h" #include "game_sa\CFont.h" #include "game_sa\CPed.h" #include "game_sa\CPools.h" #include "game_sa\CSprite.h" #include "game_sa\common.h" using namespace plugin; char *names[] = { "James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Charles", "Thomas", "Christopher", "Daniel", "Matthew", "Donald", "Anthony", "Paul", "Mark", "George", "Steven", "Kenneth", "Andrew", "Edward", "Brian", "Joshua", "Kevin", "Ronald", "Timothy", "Jason", "Jeffrey", "Gary", "Ryan", "Nicholas", "Eric", "Stephen", "Jacob", "Larry", "Frank", "Jonathan", "Scott", "Justin", "Raymond", "Brandon", "Gregory", "Samuel", "Patrick", "Benjamin", "Jack", "Dennis", "Jerry", "Alexander", "Tyler", "Douglas", "Henry", "Peter", "Walter", "Aaron", "Jose", "Adam", "Harold", "Zachary", "Nathan", "Carl", "Kyle", "Arthur", "Gerald", "Lawrence", "Roger", "Albert", "Keith", "Jeremy", "Terry", "Joe", "Sean", "Willie", "Jesse", "Ralph", "Billy", "Austin", "Bruce", "Christian", "Roy", "Bryan", "Eugene", "Louis", "Harry", "Wayne", "Ethan", "Jordan", "Russell", "Alan", "Philip", "Randy", "Juan", "Howard", "Vincent", "Bobby", "Dylan", "Johnny", "Phillip", "Craig" }; struct PedName { char name[16]; }; unsigned int PedNamePluginId; #define GetPedName(ped) (((PedName *)StructPlugins::GetPedPlugin(ped, PedNamePluginId))->name) void RegisterPedNamePlugin(); void PedNameInit(CPed *ped, PedName *data); void PedNameDelete(CPed *ped, PedName *data); void DrawPedNames(); BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { if(reason == DLL_PROCESS_ATTACH) { System::RegisterPlugin("Test CFont", "DK", "test_font.asi", "1.0", 1, GAME_SA_1_0_US, NULL); Core::RegisterFunc(FUNC_REGISTER_STRUCT_PLUGIN, RegisterPedNamePlugin); Core::RegisterFunc(FUNC_DRAWING, DrawPedNames); } return TRUE; } void RegisterPedNamePlugin() { PedNamePluginId = StructPlugins::RegisterPedPlugin(sizeof(PedName), 'NDEP', PedNameInit, PedNameDelete); } void PedNameInit(CPed *ped, PedName *data) { MakeUpperCase(data->name, names[rand() % 100]); } void PedNameDelete(CPed *ped, PedName *data) { } void DrawPedNames() { CPed *ped; RwV3d pedPosn, screenCoors; float w, h; for(int i = 0; i < CPools::ms_pPedPool->m_Size; i++) { if(!CPools::ms_pPedPool->m_ByteMap[i].bIsFreeSlot) { ped = &CPools::ms_pPedPool->m_Objects[i]; if(ped != FindPlayerPed(0)) { pedPosn = ped->m_pCoords? ped->m_pCoords->pos : ped->m_Placement.m_vPosn; pedPosn.z += 1.0f; if(CSprite::CalcScreenCoors(pedPosn, &screenCoors, &w, &h, true, true)) { CFont::SetAlignment(ALIGN_CENTER); CFont::SetColor(CRGBA(255, 255, 255, 255)); CFont::SetOutlinePosition(1); CFont::SetBackground(false, false); CFont::SetWrapx(500.0); CFont::SetScale(0.5, 1.0); CFont::SetFontStyle(FONT_SUBTITLES); CFont::SetProp(true); CFont::PrintString(screenCoors.x, screenCoors.y, GetPedName(ped)); } } } } }