From 91b8bbae4f79089ca9208f48e2cfdbcdac6783d2 Mon Sep 17 00:00:00 2001 From: srpg <44681214+srpg@users.noreply.github.com> Date: Sun, 5 Sep 2021 14:46:44 +0300 Subject: [PATCH 1/5] Fixed typo --- .../source/developing/module_tutorials/plugins.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/source-python/docs/source-python/source/developing/module_tutorials/plugins.rst b/addons/source-python/docs/source-python/source/developing/module_tutorials/plugins.rst index 6fe5efdf7..ca4e93dab 100644 --- a/addons/source-python/docs/source-python/source/developing/module_tutorials/plugins.rst +++ b/addons/source-python/docs/source-python/source/developing/module_tutorials/plugins.rst @@ -266,5 +266,5 @@ Here is the full example code to implement sub-plugins: my_sub_command_manager.unload_plugin(plugin) def unload(): - for plugin in my_plugin_manager.loaded_plugins): + for plugin in my_plugin_manager.loaded_plugins: plugin.unload() From 497bc802698140f50db5173d4ffe556547efd4bc Mon Sep 17 00:00:00 2001 From: srpg <44681214+srpg@users.noreply.github.com> Date: Sun, 29 May 2022 18:56:25 +0300 Subject: [PATCH 2/5] Adds menus tutorial - Have simple, paged and list menu tutorial on how to make the menu. --- .../developing/module_tutorials/menus.rst | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst diff --git a/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst b/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst new file mode 100644 index 000000000..e70e1b1ff --- /dev/null +++ b/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst @@ -0,0 +1,116 @@ +Menus +====== + +This page contains tutorials about the :mod:`menus.radio` package. + + +Creating PagedMenu +-------------------------- + +This is a simple example to create paged menu + +.. code-block:: python + + from commands.say import SayCommand + + from menus import PagedMenu + from menus import PagedOption + + from players.entity import Player + + + # Register menu command + @SayCommand(['menu', '/menu', '!menu']) + def say_command(command, index, teamonly): + # Send the menu + build_paged_menu(index) + return False + + def build_paged_menu(index): + # Create the Paged Menu and set title to My Menu + menu = PagedMenu(title='My Menu') + # Add options from 1 to 20 + for i in range(1, 20): + menu.append(PagedOption(f'{i}', i)) + menu.select_callback=my_select_callback + menu.send(index) + + def my_select_callback(menu, index, option): + # Create player object from index + player = Player(index) + # Print the player name who have selected a menu option + print(f'{player.name} have selected a menu option!') + + +Creating SimpleMenu +-------------------------- + +This is a simple example to create simple menu + +.. code-block:: python + + from commands.say import SayCommand + + from menus import SimpleMenu + from menus import SimpleOption + from menus import Text + + from messages import SayText2 + + from players.entity import Player + + # Register menu command + @SayCommand(['menus', '/menus', '!menus']) + def say_menus_command(command, index, teamonly): + # Send the menu + build_simple_menu(index) + return False + + def build_simple_menu(index): + # Create the SimpleMenu + menu = SimpleMenu + # Add in menu text + menu.append(Text('Do you accept the rules?')) + menu.append(Text(' ')) + # Add in menu options + menu.append(SimpleOption(1, 'Yes', 'yes')) + menu.append(SimpleOption(2, 'No', 'no')) + menu.select_callback=my_menu_select_callback + menu.send(index) + + def my_menu_select_callback(menu, index, option): + choice = option.value + # Create player object from index + player = Player(index) + # Player did select yes option + if choice == 'yes': + SayText2('Thank you for accepting the rules!').send(index) + # Player selected no option + else: + player.kick('You have to accept the rules!') + +Creating ListMenu +-------------------------- + +This is a simple example to create list menu + +.. code-block:: python + + from commands.say import SayCommand + + from menus import ListMenu + from menus import Text + + # Register menu command + @SayCommand(['menus', '/menus', '!menus']) + def say_menus_command(command, index, teamonly): + # Send the menu + build_list_menu(index) + return False + + def build_simple_menu(index): + # Create the ListMenu + menu = ListMenu() + # Add in menu text + menu.append(Text('This is a example text')) + menu.send(index) \ No newline at end of file From 5417152133518e50f9eb787a7c2febeb2c84e107 Mon Sep 17 00:00:00 2001 From: srpg <44681214+srpg@users.noreply.github.com> Date: Wed, 1 Jun 2022 19:13:02 +0300 Subject: [PATCH 3/5] Improved wiki --- .../developing/module_tutorials/menus.rst | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst b/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst index e70e1b1ff..a428eea32 100644 --- a/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst +++ b/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst @@ -1,7 +1,7 @@ Menus ====== -This page contains tutorials about the :mod:`menus.radio` package. +This page contains tutorials about the :mod:`menus` package. Creating PagedMenu @@ -11,6 +11,8 @@ This is a simple example to create paged menu .. code-block:: python + import random + from commands.say import SayCommand from menus import PagedMenu @@ -23,23 +25,25 @@ This is a simple example to create paged menu @SayCommand(['menu', '/menu', '!menu']) def say_command(command, index, teamonly): # Send the menu - build_paged_menu(index) + menu.send(index) return False - def build_paged_menu(index): - # Create the Paged Menu and set title to My Menu - menu = PagedMenu(title='My Menu') - # Add options from 1 to 20 - for i in range(1, 20): - menu.append(PagedOption(f'{i}', i)) - menu.select_callback=my_select_callback - menu.send(index) + menu = PagedMenu(title='Welcome menu', description='Choose an option:', select_callback=my_select_callback) + + # Add options from 1 to 20 + for i in range(1, 20): + menu.append(PagedOption(f'{i}', i)) def my_select_callback(menu, index, option): - # Create player object from index - player = Player(index) - # Print the player name who have selected a menu option - print(f'{player.name} have selected a menu option!') + ''' + Called whenever a selection was made. + ''' + + # Shuffle the menu : D + random.shuffle(menu) + + # Make it sticky + return menu Creating SimpleMenu @@ -49,6 +53,8 @@ This is a simple example to create simple menu .. code-block:: python + import time + from commands.say import SayCommand from menus import SimpleMenu @@ -63,31 +69,29 @@ This is a simple example to create simple menu @SayCommand(['menus', '/menus', '!menus']) def say_menus_command(command, index, teamonly): # Send the menu - build_simple_menu(index) + menu.send(index) return False - def build_simple_menu(index): - # Create the SimpleMenu - menu = SimpleMenu - # Add in menu text - menu.append(Text('Do you accept the rules?')) - menu.append(Text(' ')) - # Add in menu options - menu.append(SimpleOption(1, 'Yes', 'yes')) - menu.append(SimpleOption(2, 'No', 'no')) - menu.select_callback=my_menu_select_callback - menu.send(index) + + menu = SimpleMenu() + # Tell the current time + menu.append(Text(f"Current Time: {time.strftime('%H:%M:%S')}")) + # Add empty line + menu.append(Text(' ')) + menu.append(Text('Do you accept the rules?')) + menu.append(Text(' ')) + # Add in menu options + menu.append(SimpleOption(1, 'Yes', 'yes')) + menu.append(SimpleOption(2, 'No', 'no')) + menu.select_callback=my_menu_select_callback + def my_menu_select_callback(menu, index, option): - choice = option.value - # Create player object from index - player = Player(index) - # Player did select yes option - if choice == 'yes': + if option.value == 'yes': SayText2('Thank you for accepting the rules!').send(index) # Player selected no option else: - player.kick('You have to accept the rules!') + Player(index).kick('You have to accept the rules!') Creating ListMenu -------------------------- @@ -105,12 +109,9 @@ This is a simple example to create list menu @SayCommand(['menus', '/menus', '!menus']) def say_menus_command(command, index, teamonly): # Send the menu - build_list_menu(index) + menu.send(index) return False - def build_simple_menu(index): - # Create the ListMenu - menu = ListMenu() - # Add in menu text - menu.append(Text('This is a example text')) - menu.send(index) \ No newline at end of file + menu = ListMenu() + # Add in menu text + menu.append(Text('This is a example text')) \ No newline at end of file From 3596233ee6a1c7fbfc533682d9f1cbaf8b352ef5 Mon Sep 17 00:00:00 2001 From: srpg <44681214+srpg@users.noreply.github.com> Date: Fri, 3 Jun 2022 16:14:20 +0300 Subject: [PATCH 4/5] More improvements --- .../developing/module_tutorials/menus.rst | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst b/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst index a428eea32..58cc2dd75 100644 --- a/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst +++ b/addons/source-python/docs/source-python/source/developing/module_tutorials/menus.rst @@ -1,4 +1,4 @@ -Menus +menus ====== This page contains tutorials about the :mod:`menus` package. @@ -28,12 +28,6 @@ This is a simple example to create paged menu menu.send(index) return False - menu = PagedMenu(title='Welcome menu', description='Choose an option:', select_callback=my_select_callback) - - # Add options from 1 to 20 - for i in range(1, 20): - menu.append(PagedOption(f'{i}', i)) - def my_select_callback(menu, index, option): ''' Called whenever a selection was made. @@ -45,6 +39,21 @@ This is a simple example to create paged menu # Make it sticky return menu + menu = PagedMenu( + title='Welcome menu', + description='Choose an option:', + select_callback=my_select_callback + ) + + # Add options from 1 to 20 + for i in range(1, 20): + menu.append(PagedOption(f'{i}', i)) + + # Register close button to send back the menu + @menu.register_close_callback + def _on_close_menu(menu, index): + menu.send(index) + Creating SimpleMenu -------------------------- @@ -72,26 +81,35 @@ This is a simple example to create simple menu menu.send(index) return False + def my_menu_select_callback(menu, index, option): + ''' + Called whenever a selection was made. + ''' + + if option.value == 'yes': + SayText2('Thank you for accepting the rules!').send(index) + + # player have selected no option + else: + # Kick player for selecting no option + Player(index).kick('You have to accept the rules!') menu = SimpleMenu() + # Tell the current time menu.append(Text(f"Current Time: {time.strftime('%H:%M:%S')}")) + # Add empty line menu.append(Text(' ')) menu.append(Text('Do you accept the rules?')) menu.append(Text(' ')) + # Add in menu options menu.append(SimpleOption(1, 'Yes', 'yes')) menu.append(SimpleOption(2, 'No', 'no')) - menu.select_callback=my_menu_select_callback + menu.select_callback=my_menu_select_callback - def my_menu_select_callback(menu, index, option): - if option.value == 'yes': - SayText2('Thank you for accepting the rules!').send(index) - # Player selected no option - else: - Player(index).kick('You have to accept the rules!') Creating ListMenu -------------------------- From 11eb03e8b0ade887877f3bbd85a76a0ce4a7df66 Mon Sep 17 00:00:00 2001 From: srpg <44681214+srpg@users.noreply.github.com> Date: Thu, 17 Apr 2025 18:34:22 +0300 Subject: [PATCH 5/5] Updated CSS data --- .../client/orangebox/CBaseClient.ini | 2 +- .../cstrike/CBaseCombatCharacter.ini | 15 +++++ .../orangebox/cstrike/CBaseCombatWeapon.ini | 8 +-- .../orangebox/cstrike/CBaseEntity.ini | 61 +++++++++++++++++++ .../orangebox/cstrike/CBaseGrenade.ini | 4 +- .../orangebox/cstrike/CBasePlayer.ini | 40 ++++++++++-- .../entities/orangebox/cstrike/CCSPlayer.ini | 26 ++------ .../orangebox/cstrike/CBaseEntityOutput.ini | 9 +++ 8 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatCharacter.ini create mode 100644 addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseEntity.ini create mode 100644 addons/source-python/data/source-python/entity_output/orangebox/cstrike/CBaseEntityOutput.ini diff --git a/addons/source-python/data/source-python/client/orangebox/CBaseClient.ini b/addons/source-python/data/source-python/client/orangebox/CBaseClient.ini index 666f18067..a426ba11a 100644 --- a/addons/source-python/data/source-python/client/orangebox/CBaseClient.ini +++ b/addons/source-python/data/source-python/client/orangebox/CBaseClient.ini @@ -3,5 +3,5 @@ [virtual_function] [[set_name]] offset_linux = 57 - offset_windows = 17 + offset_windows = 18 arguments = STRING diff --git a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatCharacter.ini b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatCharacter.ini new file mode 100644 index 000000000..4c30ebf0a --- /dev/null +++ b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatCharacter.ini @@ -0,0 +1,15 @@ +[virtual_function] + + # _ZN20CBaseCombatCharacter18OnTakeDamage_AliveERK15CTakeDamageInfo + [[on_take_damage_alive]] + offset_linux = 279 + offset_windows = 278 + arguments = POINTER + return_type = INT + + # _ZN20CBaseCombatCharacter13Weapon_SwitchEP17CBaseCombatWeaponi + [[weapon_switch]] + offset_linux = 271 + offset_windows = 270 + arguments = POINTER, INT + return_type = BOOL diff --git a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatWeapon.ini b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatWeapon.ini index 3f5922642..b80fbbfca 100644 --- a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatWeapon.ini +++ b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseCombatWeapon.ini @@ -2,10 +2,10 @@ # _ZN17CBaseCombatWeapon13PrimaryAttackEv [[primary_attack]] - offset_linux = 274 - offset_windows = 273 + offset_linux = 280 + offset_windows = 279 # _ZN17CBaseCombatWeapon13SecondaryAttackEv [[secondary_attack]] - offset_linux = 275 - offset_windows = 274 + offset_linux = 281 + offset_windows = 280 diff --git a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseEntity.ini b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseEntity.ini new file mode 100644 index 000000000..1712fbf62 --- /dev/null +++ b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseEntity.ini @@ -0,0 +1,61 @@ +[virtual_function] + + # _ZN11CBaseEntity8SetModelEPKc + [[set_model]] + offset_linux = 27 + offset_windows = 26 + arguments = STRING + + # _ZN11CBaseEntity9SetParentEPS_i + [[set_parent]] + offset_linux = 37 + offset_windows = 36 + arguments = POINTER, INT + + # _ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo + [[on_take_damage]] + offset_linux = 65 + offset_windows = 64 + arguments = POINTER + return_type = INT + + # _ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_ + [[teleport]] + offset_linux = 111 + offset_windows = 110 + arguments = POINTER, POINTER, POINTER + + # _ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob + [[set_transmit]] + offset_linux = 23 + offset_windows = 22 + arguments = POINTER, BOOL + + # _ZN11CBaseEntity10StartTouchEPS_ + [[start_touch]] + offset_linux = 101 + offset_windows = 100 + arguments = POINTER + + # _ZN11CBaseEntity5TouchEPS_ + [[touch]] + offset_linux = 102 + offset_windows = 101 + arguments = POINTER + + # _ZN11CBaseEntity8EndTouchEPS_ + [[end_touch]] + offset_linux = 103 + offset_windows = 102 + arguments = POINTER + + # _ZNK11CBasePlayer25PhysicsSolidMaskForEntityEv + [[get_solid_mask]] + offset_linux = 171 + offset_windows = 170 + return_type = UINT + + +[input] + + dispatch_effect = DispatchEffect diff --git a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseGrenade.ini b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseGrenade.ini index ed2065808..93370d81e 100644 --- a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseGrenade.ini +++ b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBaseGrenade.ini @@ -2,5 +2,5 @@ # _ZN12CBaseGrenade8DetonateEv [[detonate]] - offset_linux = 226 - offset_windows = 225 + offset_linux = 233 + offset_windows = 232 diff --git a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBasePlayer.ini b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBasePlayer.ini index 82be3db76..8e116397b 100644 --- a/addons/source-python/data/source-python/entities/orangebox/cstrike/CBasePlayer.ini +++ b/addons/source-python/data/source-python/entities/orangebox/cstrike/CBasePlayer.ini @@ -1,25 +1,53 @@ +[function] + + [[increment_frag_count]] + identifier_windows = 55 8B EC 8B 45 08 01 81 F8 0C 00 00 + identifier_linux = _ZN11CBasePlayer18IncrementFragCountEi + arguments = INT + + [[increment_death_count]] + identifier_windows = 55 8B EC 8B 45 08 01 81 FC 0C 00 00 + identifier_linux = _ZN11CBasePlayer19IncrementDeathCountEi + arguments = INT + [virtual_function] # _ZN11CBasePlayer10BumpWeaponEP17CBaseCombatWeapon [[bump_weapon]] - offset_linux = 398 - offset_windows = 397 + offset_linux = 405 + offset_windows = 404 arguments = POINTER return_type = BOOL # _ZN11CBasePlayer13GiveNamedItemEPKci [[give_named_item]] - offset_linux = 402 - offset_windows = 401 + offset_linux = 409 + offset_windows = 408 arguments = STRING, INT return_type = POINTER # _ZN11CBasePlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper [[run_command]] - offset_linux = 420 - offset_windows = 419 + offset_linux = 427 + offset_windows = 426 arguments = POINTER, POINTER + # _ZN11CBasePlayer11Weapon_DropEP17CBaseCombatWeaponPK6VectorS4_ + [[drop_weapon]] + offset_linux = 270 + offset_windows = 269 + arguments = POINTER, POINTER, POINTER + + # _ZN11CBasePlayer8PreThinkEv + [[pre_think]] + offset_linux = 339 + offset_windows = 338 + + # _ZN11CBasePlayer9PostThinkEv + [[post_think]] + offset_linux = 340 + offset_windows = 339 + [property] diff --git a/addons/source-python/data/source-python/entities/orangebox/cstrike/CCSPlayer.ini b/addons/source-python/data/source-python/entities/orangebox/cstrike/CCSPlayer.ini index 83d0e60cf..e5427ba3e 100644 --- a/addons/source-python/data/source-python/entities/orangebox/cstrike/CCSPlayer.ini +++ b/addons/source-python/data/source-python/entities/orangebox/cstrike/CCSPlayer.ini @@ -10,7 +10,7 @@ identifier_linux = _ZN9CCSPlayer7AutoBuyEv [[buy_internal]] - identifier_windows = 55 8B EC 83 EC 28 89 4D F8 + identifier_windows = 55 8B EC 83 EC 28 89 4D F8 6A 00 identifier_linux = _ZN9CCSPlayer26HandleCommand_Buy_InternalEPKc arguments = STRING return_type = INT @@ -25,7 +25,7 @@ arguments = FLOAT [[switch_team]] - identifier_windows = 55 8B EC 83 EC 7C 89 4D FC + identifier_windows = 55 8B EC 83 EC 5C 89 4D FC identifier_linux = _ZN9CCSPlayer10SwitchTeamEi arguments = INT @@ -34,14 +34,14 @@ # _ZN9CCSPlayer12Weapon_EquipEP17CBaseCombatWeapon [[equip_weapon]] - offset_linux = 262 - offset_windows = 261 + offset_linux = 268 + offset_windows = 267 arguments = POINTER # _ZN9CCSPlayer5BlindEfff [[blind]] - offset_linux = 469 - offset_windows = 466 + offset_linux = 479 + offset_windows = 476 arguments = FLOAT, FLOAT, FLOAT @@ -50,20 +50,6 @@ on_rescue_zone_touch = OnRescueZoneTouch -# TODO: Remove when outdated. -[instance_attribute] - - [[mvps]] - offset_windows = 6384 - offset_linux = 6404 - type = INT - - [[clan_tag]] - offset_windows = 5628 - offset_linux = 5648 - type = STRING_ARRAY - - [based_attribute] [[mvps]] diff --git a/addons/source-python/data/source-python/entity_output/orangebox/cstrike/CBaseEntityOutput.ini b/addons/source-python/data/source-python/entity_output/orangebox/cstrike/CBaseEntityOutput.ini new file mode 100644 index 000000000..58a1ffb72 --- /dev/null +++ b/addons/source-python/data/source-python/entity_output/orangebox/cstrike/CBaseEntityOutput.ini @@ -0,0 +1,9 @@ +# ../data/source-python/entity_output/orangebox/CBaseEntityOutput.ini + +binary = server + +[function] + [[fire_output]] + identifier_windows = 55 8B EC 81 EC 2A 2A 2A 2A 53 8B C1 + arguments_linux = POINTER, POINTER, POINTER, FLOAT + arguments_windows = INT, INT, INT, INT, POINTER, POINTER, POINTER, FLOAT