NOINLINE void UTIL_ClientSayText(edict_t *pEntity, char* msg, int sender, CsTeams team) { gmsgSayText = GET_USER_MSG_ID(PLID, "SayText", NULL); if (sender) { MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, pEntity); WRITE_BYTE(sender); WRITE_STRING(msg); MESSAGE_END(); } else { size_t player_index = g_game.indexOfEdict(pEntity); CsTeams player_team = g_players.getPlayer(player_index)->getTeam(); MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pEntity); WRITE_BYTE(player_index); WRITE_STRING(g_teamNames[team]); MESSAGE_END(); MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, pEntity); WRITE_BYTE(sender); WRITE_STRING(msg); MESSAGE_END(); MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pEntity); WRITE_BYTE(player_index); WRITE_STRING(g_teamNames[player_team]); MESSAGE_END(); } }
int EventsMngr::getEventId(const char* msg) { // :TODO: Remove this somehow!!! :) const struct CS_Events { const char* name; CS_EventsIds id; } table[] = { {"CS_DeathMsg", CS_DeathMsg}, // {"CS_RoundEnd", CS_RoundEnd}, // {"CS_RoundStart", CS_RoundStart}, // {"CS_Restart", CS_Restart}, {"", CS_Null} }; // if msg is a number, return it int pos = atoi(msg); if (pos != 0) return pos; // try to find in table first for (pos = 0; table[pos].id != CS_Null; ++pos) if (!strcmp(table[pos].name, msg)) return table[pos].id; // find the id of the message return pos = GET_USER_MSG_ID(PLID, msg, 0); }
// This is called through ServerActivate_Post void Initialize_MessageHandler(void) { if (MessageHandler_Initialized) { return; } MessageHandler_Initialized=true; int i=0; while (i<255) { MessageLists[i++]=NULL; }; // Hook our messages int index; index=GET_USER_MSG_ID(&Plugin_info,"Countdown",NULL); if (index) { MessageLists[index]=new MessageCountDown; } index=GET_USER_MSG_ID(&Plugin_info,"GameStatus",NULL); if (index) { MessageLists[index]=new MessageGameStatus; } #if 0 index=GET_USER_MSG_ID(&Plugin_info,"Particles",NULL); if (index) { MessageLists[index]=new MessageDebug; } #endif // Start hooking messagebegin_post g_pengfuncsTable_Post->pfnMessageBegin=MessageBegin_Post; };
void REG_MESSAGE_HOOK(char *msg, void (*function)(void*)) { int msg_id; if(msg_id = GET_USER_MSG_ID(PLID, msg, NULL )) { msgHooks[msg_id].function = function; } }
void wd_msgid(void) { const char *msgname; int id; msgname=CMD_ARGV(1); id=GET_USER_MSG_ID(PLID, msgname, NULL); if(id) LOG_CONSOLE(PLID, "%s = %d", msgname, id); else LOG_CONSOLE(PLID, "msg not found: %s", msgname); }
/* 0 [Byte] 1 // Weapons Groupings 1 [Byte] 210 // Total Rounds Allowed 2 [Byte] -1 // Undefined Not Used 3 [Byte] -1 // Undefined Not Used 4 [Byte] 2 // Weapon Slot 5 [Byte] 0 // Bucket ( Position Under Weapon Slot ) 6 [Short] 7 // Weapon Number / Bit Field for the weapon 7 [Byte] 128 // Bit Field for the Ammo or Ammo Type 8 [Byte] 30 // Rounds Per Mag id, wpnID, slot, position, totalrds */ static cell AMX_NATIVE_CALL dod_weaponlist(AMX *amx, cell *params) // player { if(!weaponlist[params[1]].changeable) { MF_LogError(amx, AMX_ERR_NATIVE, "This Weapon Cannot be Changed"); return 0; } int id = params[1]; int wpnID = params[2]; int slot = params[3]; int position = params[4]; int totalrds = params[5]; UTIL_LogPrintf("ID (%d) WpnID (%d) Slot (%d) Pos (%d) Rounds (%d)", id, wpnID, slot, position, totalrds); CHECK_PLAYER(id); CPlayer* pPlayer = GET_PLAYER_POINTER_I(id); if(!pPlayer->ingame) { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Player, Not on Server"); return 0; } MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "WeaponList", NULL), NULL, INDEXENT(id)); WRITE_BYTE(weaponlist[wpnID].grp); WRITE_BYTE(totalrds); WRITE_BYTE(-1); WRITE_BYTE(-1); WRITE_BYTE(slot - 1); WRITE_BYTE(position); WRITE_SHORT(wpnID); WRITE_BYTE(weaponlist[wpnID].bitfield); // Is it grenades if(wpnID == 13 || wpnID == 14 || wpnID == 15 || wpnID == 16 || wpnID == 36) WRITE_BYTE(-1); else if(wpnID == 29 || wpnID == 30 || wpnID == 31) WRITE_BYTE(1); else WRITE_BYTE(weaponlist[wpnID].clip); MESSAGE_END(); return 1; }
void UTIL_ClientPrint(edict_t* pEntity, int msg_dest, char* msg) { gmsgTextMsg = GET_USER_MSG_ID(PLID, "TextMsg", NULL); char c = msg[190]; msg[190] = '\0'; if (pEntity) MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, NULL, pEntity); else MESSAGE_BEGIN(MSG_BROADCAST, gmsgTextMsg); WRITE_BYTE(msg_dest); WRITE_STRING(msg); MESSAGE_END(); msg[190] = c; }
static cell AMX_NATIVE_CALL esf_set_maxhealth(AMX *amx, cell *params) // esf_set_maxhealth(index, health); = 2 args { // Set maxhealth to a player // params[1] = index // params[2] = health // Check index CHECK_PLAYER( params[ 1 ] ); // Fetch player pointer edict_t *pPlayer = MF_GetPlayerEdict( params[ 1 ] ); *((int *)pPlayer->pvPrivateData + ESFX_MAXHEALTH_OFFSET) = params[ 2 ]; // Writing maxhealth message to client... MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "MaxHealth", NULL), NULL, pPlayer); WRITE_BYTE(params[ 2 ]); MESSAGE_END(); return 1; }
void print_client(edict_t *pEdict, int type, const char *fmt, ...) { //don't do this to bots if (pEdict->v.flags & FL_FAKECLIENT) return; char buffer[255]; va_list ap; va_start(ap, fmt); vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); va_end(ap); if (!g_TextMsg) { g_TextMsg = GET_USER_MSG_ID(PLID, "TextMsg", NULL); if (!g_TextMsg) return; } MESSAGE_BEGIN(pEdict ? MSG_ONE : MSG_BROADCAST, g_TextMsg, NULL, pEdict); WRITE_BYTE(type); WRITE_STRING(buffer); MESSAGE_END(); }