Raised This Month: $ Target: $400
 0% 

client_print problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 11-22-2011 , 07:59   Re: client_print problem
Reply With Quote #2

Might be due to the fact that 190 is maximum size of the TextMsg event, which is used in the client_print function to actually send the message (see UTIL_ClientPrint below). Not entirely sure however. As it seems to be working correctly with log_amx I would assume so.

Source code from client_print:
Code:
static cell AMX_NATIVE_CALL client_print(AMX *amx, cell *params) /* 3 param */ {     int len = 0;     char *msg;         if (params[1] == 0)     {         for (int i = 1; i <= gpGlobals->maxClients; ++i)         {             CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);                         if (pPlayer->ingame)             {                 g_langMngr.SetDefLang(i);                 msg = format_amxstring(amx, params, 3, len);                 msg[len++] = '\n';                 msg[len] = 0;                 UTIL_ClientPrint(pPlayer->pEdict, params[2], msg);             }         }     } else {         int index = params[1];                 if (index < 1 || index > gpGlobals->maxClients)         {             LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d", index);             return 0;         }                 CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);         g_langMngr.SetDefLang(index);                 msg = format_amxstring(amx, params, 3, len);         msg[len++] = '\n';         msg[len] = 0;                 if (pPlayer->ingame)             UTIL_ClientPrint(pPlayer->pEdict, params[2], msg);      //format_amxstring(amx, params, 3, len));     }         return len; } void UTIL_ClientPrint(edict_t *pEntity, int msg_dest, char *msg) {     if (!gmsgTextMsg)         return; // :TODO: Maybe output a warning log?         char c = msg[190];     msg[190] = 0; // truncate without checking with strlen()     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; }

About emit_sound() - parameter 4 (vol) decides the volume of the current sound.

Also, there is no need to iterate through all players to send a message, simply do the following to send it to all players:
Code:
client_print( 0, print_chat, "message" );
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 11-22-2011 at 07:59.
Xellath is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode