hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.11.10. 19:49



Jelenlévő felhasználók

Jelenleg 324 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 323 vendég

A legtöbb felhasználó (2883 fő) 2025.07.30. 16:00-kor tartózkodott itt.

Regisztrált felhasználók: Google [Bot]az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása Hozzászólás a témához  [2 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: RTS complement - Mit csinál ?
HozzászólásElküldve:2012.07.24. 22:28 
Offline
Őstag
Avatar

Csatlakozott:2012.02.14. 15:09
Hozzászólások:1423
Megköszönték neki: 2 alkalommal
Mit csinál ez a plugin?
Annyit értettem, hogy "kiegészíti" ezt a plugint, de nem tudom pontosan mit és hogyan csinál.
Kód:
  1. /* RTS COMPLEMENT

  2.  

  3.         Showcase of RTS API

  4.        

  5.         by Nextra

  6.        

  7.         version 1.0.1

  8.        

  9.         This file is provided as is (no warranties).

  10. */

  11.  

  12. #include <amxmodx>

  13. #include <amxmisc>

  14. #include <fakemeta>

  15. #include <cstrike>

  16. #include <rememberthescore>

  17.  

  18. new g_msgid_ScoreInfo, bool:g_RTSEnabled = true;

  19.  

  20. public plugin_init( )

  21. {

  22.         register_plugin( "RTS Complement", "1.0.1", "Nextra" );

  23.        

  24.         // Some basic functions to showcase the features/powers of the RTS API

  25.         register_clcmd( "add_score"     , "_add_score"  , ADMIN_RCON, "Add to the score of yourself"    );

  26.         register_clcmd( "add_deaths", "_add_deaths"     , ADMIN_RCON, "Add to the deaths of yourself"   );

  27.         register_clcmd( "save_score", "_save_score"     , ADMIN_RCON, "Save your own score to the db"   );

  28.        

  29.         g_msgid_ScoreInfo = get_user_msgid( "ScoreInfo" );

  30. }

  31.  

  32. /* We could do stuff with the player now since we know that the player has been authorized

  33.  * and his score has been set from the db, but since this is only showcasing the functions

  34.  * provided we will only log what happened and do nothing more. */

  35. public rts_user_authorized( id )

  36. {

  37.         new szName[32];

  38.        

  39.         get_user_name( id, szName, charsmax(szName) );

  40.        

  41.         log_amx( "User %s (%d) was authorized by RTS. Set score: %d, deaths: %d.", szName, id, get_user_frags( id ), cs_get_user_deaths( id ) );

  42. }

  43.  

  44. // These two forwards tell us that the operating state of rts has changed. We'll issue some basic things.

  45. public rts_plugin_inactive( type )

  46. {

  47.         if( !type ) // RTS paused

  48.         {

  49.                 g_RTSEnabled = false;

  50.         }

  51.        

  52.         else // RTS set itself failed, no reason to continue.

  53.         {

  54.                 set_fail_state( "[RTSC] RTS set itself failed. Aborting any further operation." );

  55.         }

  56. }

  57.  

  58. public rts_plugin_active( )

  59.         g_RTSEnabled = true;

  60.  

  61. // Just a basic score adding routine coupled with RTS's updating function to notify it of the change.

  62. public _add_score( id, level, cid )

  63. {

  64.         if( !cmd_access( id, level, cid, 1 ) )

  65.         {

  66.                 return PLUGIN_HANDLED;

  67.         }

  68.        

  69.         else if( !g_RTSEnabled ) // RTS is not currently running, we should not continue

  70.         {

  71.                 console_print( id, "RTS is not currently running." );

  72.                 return PLUGIN_HANDLED;

  73.         }

  74.        

  75.        

  76.         // Getting the amount we should change

  77.         new szAmt[16], iAmt, iNegative = 0;

  78.        

  79.         read_argv( 1, szAmt, charsmax(szAmt) );

  80.        

  81.         if( szAmt[0] == '-' )

  82.         {

  83.                 iNegative = 1;

  84.         }

  85.        

  86.         if( is_str_num( szAmt[iNegative] ) )

  87.         {

  88.                 iAmt = str_to_num( szAmt );

  89.         }

  90.  

  91.         else

  92.         {

  93.                 console_print( id, "Invalid amount specified." );

  94.                 return PLUGIN_HANDLED;

  95.         }

  96.  

  97.  

  98.         if( rts_is_authorized( id ) ) // We require the user to be authorized.

  99.         {

  100.                 set_pev( id, pev_frags, float( get_user_frags( id ) + iAmt ) );

  101.                 rts_update_score( id ); // RTS will update its internal score tracking.

  102.         }                                                       // It reloads according to get_user_frags( id ) and therefore implements our change.

  103.        

  104.         else

  105.         {

  106.                 // We could take further action but again, only a showcase. We'll just log.

  107.                 log_amx( "[RTS] Attempted deaths update on player %d but he was not authorized.", id );

  108.         }

  109.        

  110.         msg_score( id ); // This will draw the information on the scoreboard.

  111.                

  112.         console_print( id, "Score updated." );

  113.        

  114.         return PLUGIN_HANDLED;

  115. }

  116.  

  117. // Just a basic deaths adding routine coupled with RTS's updating function to notify it of the change.

  118. public _add_deaths( id, level, cid )

  119. {

  120.         if( !cmd_access( id, level, cid, 1 ) )

  121.         {

  122.                 return PLUGIN_HANDLED;

  123.         }

  124.        

  125.         else if( !g_RTSEnabled ) // RTS is not currently running, we should not continue

  126.         {

  127.                 console_print( id, "RTS is not currently running." );

  128.                 return PLUGIN_HANDLED;

  129.         }

  130.        

  131.         // Getting the amount we should change

  132.         new szAmt[16], iAmt, iNegative = 0;

  133.        

  134.         read_argv( 1, szAmt, charsmax(szAmt) );

  135.        

  136.         if( szAmt[0] == '-' )

  137.         {

  138.                 iNegative = 1;

  139.         }

  140.        

  141.         if( is_str_num( szAmt[iNegative] ) )

  142.         {

  143.                 iAmt = str_to_num( szAmt );

  144.         }

  145.  

  146.         else

  147.         {

  148.                 console_print( id, "Invalid amount specified." );

  149.                 return PLUGIN_HANDLED;

  150.         }

  151.  

  152.        

  153.         if( rts_is_authorized( id ) ) // We require the user to be authorized.

  154.         {

  155.                 cs_set_user_deaths( id, cs_get_user_deaths( id ) + iAmt );

  156.                 rts_update_score( id ); // RTS will update its internal score tracking.

  157.         }                                                       // It reloads according to cs_get_user_deaths( id ) and therefore implements our change.

  158.        

  159.         else

  160.         {

  161.                 // We could take further action but again, only a showcase. We'll just log.

  162.                 log_amx( "[RTS] Attempted deaths update on player %d but he was not authorized.", id );

  163.         }

  164.        

  165.         msg_score( id ); // This will draw the information on the scoreboard.

  166.        

  167.         console_print( id, "Deaths updated." );

  168.        

  169.         return PLUGIN_HANDLED;

  170. }

  171.  

  172. // This will save the score into the database instantly through RTS. Nothing more, nothing less.

  173. public _save_score( id, level, cid )

  174. {

  175.         if( !cmd_access( id, level, cid, 0 ) )

  176.         {

  177.                 return PLUGIN_HANDLED;

  178.         }

  179.        

  180.         else if( !g_RTSEnabled )

  181.         {

  182.                 console_print( id, "RTS is not currently running." );

  183.                 return PLUGIN_HANDLED;

  184.         }

  185.        

  186.         rts_save_score( id ); // This will instantly save the current score to the database. Should not be necessary most of the time.

  187.        

  188.         console_print( id, "Score saved." );

  189.        

  190.         return PLUGIN_HANDLED;

  191. }

  192.  

  193. /* We'll update the score on the scoreboard since RTS will not do that for us. ;)

  194.  * NOTE: If we do this by using emessages we _DO NOT_ have to notify RTS of changes by calling

  195.  * rts_update_score at any time. Since RTS catches its information through this very message, it updates itself

  196.  * when receiving other plugins score messages (which is achieved by using emessages) */

  197. msg_score( id )

  198. {

  199.         message_begin( MSG_ALL, g_msgid_ScoreInfo );

  200.         write_byte( id );

  201.         write_short( get_user_frags( id ) );

  202.         write_short( cs_get_user_deaths( id ) );

  203.         write_short( 0 );

  204.         write_short( get_user_team( id ) );

  205.         message_end( );

  206. }

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: RTS complement - Mit csinál ?
HozzászólásElküldve:2012.07.25. 09:36 
Offline
Tiszteletbeli

Csatlakozott:2010.02.04. 19:12
Hozzászólások:3528
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 180 alkalommal
admin tud hozzáadni magának ölést, halált és menteni

_________________
http://www.ebateam.eu/


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése: Rendezés 
Új téma nyitása Hozzászólás a témához  [2 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 10 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole