hlmod.hu
https://hlmod.hu/

show_activity_key átírása
https://hlmod.hu/viewtopic.php?f=29&t=29151
Oldal: 1 / 1

Szerző:  RihO [ 2018.07.13. 15:57 ]
Hozzászólás témája:  show_activity_key átírása

Sziasztok!
Azon gondolkodtam, milyen jó lenne ha az alap forráskódokban benne lenne a színes chat funkció.
Elkezdtem a forrásódokat egyesével átírni(persze ami ment), viszont akadályba ütköztem.
Megláttam ezt:
  1. show_activity_key("ADMIN_TELEPORT_1", "ADMIN_TELEPORT_2", name, name2)

Utána néztem, ennek nem lehet alapból egy színkód megadásával be színezni a szöveget.
Megnéztem pontosan mit is takar a show_activity_key funkció.

------------------------------------
Funkciója:
a /configs mappában található amxx.cfg-be van olyan, hogy amx_show_activity érték.
Ennek az értékével el lehet dönteni, hogy milyen legyen a chatben megjelenő admin cselekvések üzeneteinek formája.

Ez lehet:
0 - Kikapcsolva (Nem jelelenik meg semmi)
1 - Admin név nélküli megjelenés (PL: ADMIN kirúgta játékos-t)
2 - Admin név együtti megjelenés (PL: ADMIN:RihO kirúgta játékos-t)

------------------------------------

Ezt a kódolást szeretném átírni client_print_colorra, viszont a forráskódban a szerepét nem szeretném megváltozatni.

Az átalakításom jelenleg így áll:
  1. if((get_pcvar_num("show_activity_key")) == 1 )
  2.             {
  3.                 client_print_color(id, print_team_default, "%L", id, "ADMIN_TELEPORT_1", name2)
  4.             }
  5.             else if((get_pcvar_num("show_activity_key")) == 2 )
  6.             {
  7.                 client_print_color(id, print_team_default, "%L", id, "ADMIN_TELEPORT_2", name, name2)
  8.             }
  9.             else
  10.             {
  11.                 client_print_color(id, print_team_default, "") /*ez csak ideinglenesen van itt, ha valaki leszólna :)*/
  12.             }


És ebben nem vagyok biztos hogy müködne.
Beillesztettem az eredeti forráskódba és ezt a hibát irta ki a fordító:
► Spoiler mutatása


Valaki tudna nekem segíteni?
Előre is megköszönöm.

Szerző:  Dooz [ 2018.07.14. 00:58 ]
Hozzászólás témája:  Re: show_activity_key átírása

Üdv. :D

Próbáld meg átírni ezt get_pcvar_num("show_activity_key") erre get_cvar_num("amx_show_activity").

Megj. A get_pcvar_num-ba a p betü a pointert jelenti. De mivel a jelen esetben nincs pointered, ezért a p nélküli változatot kell használnod.

Szerző:  RihO [ 2018.07.14. 16:36 ]
Hozzászólás témája:  Re: show_activity_key átírása

Hali, köszi a segítséget, müködik!

Szerző:  demon [ 2018.07.16. 19:25 ]
Hozzászólás témája:  Re: show_activity_key átírása

Egyszerűbb a amxmisc.inc fájlban a show_activity_key stockban a kiíratást átírni színes chatre és újrafordítani az összes sma-t, majd a lang fájlokban színezni a szöveget.

  1. /**
  2.  * Standard method to show activity to one single client with normal language keys.
  3.  * These keys need to be in the format of standard AMXX keys:
  4.  *   eg: ADMIN_KICK_1 = ADMIN: kick %s
  5.  *       ADMIN_KICK_2 = ADMIN %s: kick %s
  6.  * This depends on the amx_show_activity cvar.  See documentation for more details.
  7.  *
  8.  * @param KeyWithoutName    The language key that does not have the name field.
  9.  * @param KeyWithName       The language key that does have the name field.
  10.  * @param __AdminName       The name of the person doing the action.
  11.  * @extra                   Pass any extra format arguments for the language key in the variable arguments list.
  12.  */
  13. stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___AdminName[], any:...)
  14. {
  15. // The variable gets used via vformat, but the compiler doesn't know that, so it still cries.
  16. #pragma unused ___AdminName
  17.     static __amx_show_activity;
  18.     if (__amx_show_activity == 0)
  19.     {
  20.         __amx_show_activity = get_cvar_pointer("amx_show_activity");
  21.    
  22.         // if still not found, then register the cvar as a dummy
  23.         if (__amx_show_activity == 0)
  24.         {
  25.             __amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
  26.         }
  27.     }
  28.    
  29.     new buffer[512];
  30.     new keyfmt[256];
  31.     new i;
  32.    
  33.     switch( get_pcvar_num(__amx_show_activity) )
  34.     {
  35.     case 5: // hide name to admins, display nothing to normal players
  36.         while (i++ < MaxClients)
  37.         {
  38.             if ( is_user_connected(i) )
  39.             {
  40.                 if ( is_user_admin(i) )
  41.                 {
  42.                     LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
  43.  
  44.                     // skip the "adminname" argument if not showing name
  45.                     vformat(buffer, charsmax(buffer), keyfmt, 4);
  46.                     //client_print(i, print_chat, "%s", buffer);
  47.                     client_print_color(i, print_team_default, "%s", buffer);
  48.                 }
  49.             }
  50.         }
  51.     case 4: // show name only to admins, display nothing to normal players
  52.         while (i++ < MaxClients)
  53.         {
  54.             if ( is_user_connected(i) )
  55.             {
  56.                 if ( is_user_admin(i) )
  57.                 {
  58.                     LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
  59.                     vformat(buffer, charsmax(buffer), keyfmt, 3);
  60.                     //client_print(i, print_chat, "%s", buffer);
  61.                     client_print_color(i, print_team_default, "%s", buffer);
  62.                 }
  63.             }
  64.         }
  65.     case 3: // show name only to admins, hide name from normal users
  66.         while (i++ < MaxClients)
  67.         {
  68.             if ( is_user_connected(i) )
  69.             {
  70.                 if ( is_user_admin(i) )
  71.                 {
  72.                     LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
  73.                     vformat(buffer, charsmax(buffer), keyfmt, 3);
  74.                 }
  75.                 else
  76.                 {
  77.                     LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
  78.                    
  79.                     // skip the "adminname" argument if not showing name
  80.                     vformat(buffer, charsmax(buffer), keyfmt, 4);
  81.                 }
  82.                 //client_print(i, print_chat, "%s", buffer);
  83.                 client_print_color(i, print_team_default, "%s", buffer);
  84.             }
  85.         }
  86.     case 2: // show name to all users
  87.         while (i++ < MaxClients)
  88.         {
  89.             if ( is_user_connected(i) )
  90.             {
  91.                 LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
  92.                 vformat(buffer, charsmax(buffer), keyfmt, 3);
  93.                 //client_print(i, print_chat, "%s", buffer);
  94.                 client_print_color(i, print_team_default, "%s", buffer);
  95.             }
  96.         }
  97.     case 1: // hide name from all users
  98.         while (i++ < MaxClients)
  99.         {
  100.             if ( is_user_connected(i) )
  101.             {
  102.                 LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
  103.  
  104.                 // skip the "adminname" argument if not showing name
  105.                 vformat(buffer, charsmax(buffer), keyfmt, 4);
  106.                 //client_print(i, print_chat, "%s", buffer);
  107.                 client_print_color(i, print_team_default, "%s", buffer);
  108.             }
  109.         }
  110.        
  111.     }
  112. }

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/