[CS:S] Trikz

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
ae2x
Junior Member
Posts: 13
Joined: Mon Apr 09, 2018 4:26 pm

[CS:S] Trikz

Postby ae2x » Mon Apr 09, 2018 9:43 pm

Hi guys!

Do anyone intrested remake this eventscripts plugin to Source.Python plugin?

http://addons.eventscripts.com/addons/view/crazytrikz
User avatar
satoon101
Project Leader
Posts: 2582
Joined: Sat Jul 07, 2012 1:59 am

Re: [CS:S] Trikz

Postby satoon101 » Tue Apr 10, 2018 2:29 am

I'm not sure if anyone else is working on this, but I had a little bit of time tonight. This is not finished, and I haven't tested any of it. But, it's a place for someone else to start from. If you are working or want to work on this, feel free to use any, all, or none of the following:

Syntax: Select all

# ============================================================================
# >> IMPORTS
# ============================================================================
# Source.Python
from colors import WHITE
from commands.say import SayCommand
from config.manager import ConfigManager
from engines.server import queue_server_command
from entities.hooks import EntityCondition, EntityPreHook
from events import Event
from filters.players import PlayerIter
from mathlib import NULL_VECTOR, Vector
from menus import SimpleMenu, SimpleOption
from players.dictionary import PlayerDictionary
from players.entity import Player
from plugins.manager import plugin_manager


# ============================================================================
# >> GLOBAL VARIABLES
# ============================================================================
info = plugin_manager.get_plugin_info(__name__)

FADED_WHITE = WHITE.with_alpha(100)


# ============================================================================
# >> CONFIGURATION
# ============================================================================
with ConfigManager(info.name, 'trikz_') as config:
enable_ghost = config.cvar(
'enable_ghost', default=0, description='Enable/disable ghosting option.',
)
enable_flash = config.cvar(
'enable_flash', default=0, description='Enable/disable unlimited flashbangs.',
)
unlimited_health = config.cvar(
'unlimited_health', default=0, description='Enable/disable unlimited health.',
)
auto_respawn = config.cvar(
'auto_respawn', default=0, description='Enable/disable auto-respawning on death.',
)

queue_server_command(
'mp_friendlyfire 0;'
'sv_gravity 800;'
'sv_airaccelerate 250;'
'mp_limitteams 0;'
'mp_enableboost 1;'
)


# ============================================================================
# >> CLASSES
# ============================================================================
class TrikzPlayer(Player):
""""""
def __init__(self, index):
super().__init__(index)
self.flash = False
self.ghost = False
self.reset_player()

def reset_player(self):
self.first_checkpoint = NULL_VECTOR
self.second_checkpoint = NULL_VECTOR

def set_ghost(self):
color, noblock = (FADED_WHITE, True) if self.ghost else (WHITE, False)
self.color = color
self.noblock = noblock

player_dict = PlayerDictionary(factory=TrikzPlayer)


# ============================================================================
# >> GAME EVENTS
# ============================================================================
@Event('player_spawn')
def _player_spawn(game_event):
player = player_dict.from_userid(game_event['userid'])
if bool(enable_ghost):
player.set_ghost()
if bool(unlimited_health):
player.health = 1000


@Event('player_hurt')
def _player_hurt(game_event):
if bool(unlimited_health):
player_dict.from_userid(game_event['userid']).health = 1000


@Event('player_death')
def _player_death(game_event):
if bool(auto_respawn):
player_dict.from_userid(game_event['userid']).spawn()


@Event('weapon_fire')
def _weapon_fire(game_event):
if game_event['weapon'] != 'flashbang':
return

player = player_dict.from_userid(game_event['userid'])
if bool(enable_flash) and player.flash:
player.give_named_item('weapon_flashbang')


# ============================================================================
# >> ENTITY PRE-HOOKS
# ============================================================================
@EntityPreHook(
EntityCondition.equals_entity_classname('flashbang_projectile'), 'detonate'
)
def _pre_flashbang_detonate(stack_data):
return False


# ============================================================================
# >> COMMANDS
# ============================================================================
@SayCommand('!trikz')
def _send_menu(command, index, team_only):
main_menu.send(index)


@SayCommand('!switch')
def _switch_ghost(command, index, team_only):
if not bool(enable_ghost):
player = player_dict[index]
player.ghost ^= True
player.set_ghost()


# ============================================================================
# >> MENU CALLBACKS
# ============================================================================
def _main_menu_callback(menu, index, option):
player = player_dict[index]
if option.value == 1:
if player.get_projectile_count('flashbang') in (0, 1):
player.give_named_item('weapon_flashbang')

elif option.value == 2:
if bool(enable_flash):
player.flash ^= True

elif option.value == 3:
if bool(enable_ghost):
player.ghost ^= True
player.set_ghost()

elif option.value == 4:
pass

elif option.value == 5:
if player.dead:
player.spawn()


# ============================================================================
# >> MENU DECLARATION
# ============================================================================
main_menu = SimpleMenu(select_callback=_main_menu_callback)
main_menu.append('Trikz Settings Menu')
main_menu.append('-' * 20)
main_menu.append(SimpleOption(1, 'Give Flash (1)'))
main_menu.append(SimpleOption(2, 'Toggle Auto-Flash'))
main_menu.append(SimpleOption(3, 'Toggle Blocking'))
main_menu.append(SimpleOption(4, 'Checkpoints Menu'))
main_menu.append(SimpleOption(5, 'Respawn'))
main_menu.append('-' * 20)
main_menu.append('0. Close')
Image
ae2x
Junior Member
Posts: 13
Joined: Mon Apr 09, 2018 4:26 pm

Re: [CS:S] Trikz

Postby ae2x » Tue Apr 10, 2018 11:14 am

Thats nice sadly i just learning python so im pretty noob atm .. i hope someone take it and remake it
ae2x
Junior Member
Posts: 13
Joined: Mon Apr 09, 2018 4:26 pm

Re: [CS:S] Trikz

Postby ae2x » Wed Apr 11, 2018 7:59 pm

Well if anyone intrested to make it and have time for that please do it :)
ae2x
Junior Member
Posts: 13
Joined: Mon Apr 09, 2018 4:26 pm

Re: [CS:S] Trikz

Postby ae2x » Mon Apr 16, 2018 3:58 pm

Okay lets do this way.. since no one want to make it ill seach private maker who got time .. send me message here if you are intrested!
User avatar
satoon101
Project Leader
Posts: 2582
Joined: Sat Jul 07, 2012 1:59 am

Re: [CS:S] Trikz

Postby satoon101 » Mon Apr 16, 2018 11:49 pm

My script above should do everything except the Checkpoints (if I remember correctly). Though, again, it is untested. I might have some time to work on it this coming weekend if no one else has added anything to it by then.
Image
ae2x
Junior Member
Posts: 13
Joined: Mon Apr 09, 2018 4:26 pm

Re: [CS:S] Trikz

Postby ae2x » Sat Apr 21, 2018 7:38 pm

satoon101 wrote:My script above should do everything except the Checkpoints (if I remember correctly). Though, again, it is untested. I might have some time to work on it this coming weekend if no one else has added anything to it by then.



wow that would be nice .. i tested it it works but flashbangs dont disappear they stay on the ground and need to add text after you push block or autoflash like "Block is On" "Block is OFF"
User avatar
BackRaw
Senior Member
Posts: 507
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: [CS:S] Trikz

Postby BackRaw » Sat Jul 14, 2018 2:56 pm

I can take a look as well next week.
User avatar
BackRaw
Senior Member
Posts: 507
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: [CS:S] Trikz

Postby BackRaw » Thu Jul 19, 2018 9:00 pm

Got it! I used Satoon's script as a template:

Syntax: Select all

# ============================================================================
# >> IMPORTS
# ============================================================================
# Source.Python
# Colors
from colors import ORANGE
from colors import WHITE
# Commands
from commands.say import SayCommand
# Config
from config.manager import ConfigManager
# Core
from core import SOURCE_ENGINE
# Engines
from engines.server import queue_command_string
# Entities
from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
# Events
from events import Event
# Menus
from menus import SimpleMenu
from menus import SimpleOption
# Messages
from messages import SayText2
# Players
from players.dictionary import PlayerDictionary
from players.entity import Player
# Plugins
from plugins.manager import plugin_manager


# ============================================================================
# >> GLOBAL VARIABLES
# ============================================================================
info = plugin_manager.get_plugin_info(__name__)

FADED_WHITE = WHITE.with_alpha(100)


# =============================================================================
# >> MESSAGE COLORS
# =============================================================================
MESSAGE_COLOR_WHITE = '\x01' if SOURCE_ENGINE == 'csgo' else WHITE
MESSAGE_COLOR_ORANGE = '\x10' if SOURCE_ENGINE == 'csgo' else ORANGE


# ============================================================================
# >> CONFIGURATION
# ============================================================================
with ConfigManager(info.name, 'trikz_') as config:
enable_ghost = config.cvar(
'enable_ghost', default=0, description='Enable/disable ghosting option.',
)

enable_flash = config.cvar(
'enable_flash', default=0, description='Enable/disable unlimited flashbangs.',
)

unlimited_health = config.cvar(
'unlimited_health', default=0, description='Enable/disable unlimited health.',
)

auto_respawn = config.cvar(
'auto_respawn', default=0, description='Enable/disable auto-respawning on death.',
)


# ============================================================================
# >> PREPARE CONVARS
# ============================================================================
queue_command_string(
'mp_friendlyfire 0;'
'sv_gravity 800;'
'sv_airaccelerate 250;'
'mp_limitteams 0;'
'mp_enableboost 1;'
)


# ============================================================================
# >> CLASSES
# ============================================================================
class TrikzPlayer(Player):
""""""
def __init__(self, index):
super().__init__(index)
self.flash = False
self.ghost = False

self.reset_player()

def reset_player(self):
self.first_checkpoint = (None, None)
self.second_checkpoint = (None, None)

def set_ghost(self):
self.color, self.noblock = (FADED_WHITE, True) if self.ghost else (WHITE, False)

if self.ghost:
self.tell('You are a ghost again.')
else:
self.tell('You are mortal.')

def tell(self, message):
SayText2(
f'{MESSAGE_COLOR_ORANGE}[{MESSAGE_COLOR_WHITE}{info.verbose_name}{MESSAGE_COLOR_ORANGE}] '
f'{MESSAGE_COLOR_WHITE}{message}'
).send(self.index)


player_dict = PlayerDictionary(factory=TrikzPlayer)


# ============================================================================
# >> GAME EVENTS
# ============================================================================
@Event('player_spawn')
def _player_spawn(game_event):
player = player_dict.from_userid(game_event['userid'])

if bool(enable_ghost):
player.set_ghost()


@Event('player_death')
def _player_death(game_event):
if bool(auto_respawn):
player = player_dict.from_userid(game_event['userid'])

player.spawn()
player.tell('You have been respawned.')


@Event('weapon_fire')
def _weapon_fire(game_event):
if game_event['weapon'] != 'flashbang':
return

player = player_dict.from_userid(game_event['userid'])

if bool(enable_flash) and player.flash:
player.give_named_item('weapon_flashbang')
player.tell('You have received a flashbang grenade.')


# ============================================================================
# >> ENTITY PRE-HOOKS
# ============================================================================
@EntityPreHook(EntityCondition.is_bot_player, 'blind')
@EntityPreHook(EntityCondition.is_human_player, 'blind')
def _pre_blind(stack_data):
return False


@EntityPreHook(EntityCondition.is_bot_player, 'deafen')
@EntityPreHook(EntityCondition.is_human_player, 'deafen')
def _pre_blind(stack_data):
return False


@EntityPreHook(EntityCondition.is_bot_player, 'on_take_damage')
@EntityPreHook(EntityCondition.is_human_player, 'on_take_damage')
def _pre_take_damage(stack_data):
if bool(unlimited_health):
return False


# ============================================================================
# >> SAY COMMANDS
# ============================================================================
@SayCommand('!trikz')
def _send_menu(command, index, team_only):
main_menu.send(index)


@SayCommand('!switch')
def _switch_ghost(command, index, team_only):
if not bool(enable_ghost):
player = player_dict[index]

player.ghost ^= True
player.set_ghost()


# ============================================================================
# >> CHECKPOINTS MENU CALLBACKS
# ============================================================================
def _save_checkpoint(player, attr):
if player.ground_entity != -1:
setattr(player, attr, (player.origin, player.view_angle))
player.tell(f"Your {attr.replace('_', ' ')} has been saved.")
else:
player.tell('You must be standing on the ground!')


def _option_save_first_checkpoint_selected(player):
_save_checkpoint(player, 'first_checkpoint')


def _option_save_second_checkpoint_selected(player):
_save_checkpoint(player, 'second_checkpoint')


def _move_to_checkpoint(player, attr):
vector, angles = getattr(player, attr)

if vector is not None and angles is not None:
player.origin = vector
player.view_angle = angles
player.tell(f"You have been moved back to your {attr.replace('_', ' ')}.")

else:
player.tell(f"You have not saved your {attr.replace('_', ' ')}.")


def _option_move_to_first_checkpoint_selected(player):
_move_to_checkpoint(player, 'first_checkpoint')


def _option_move_to_second_checkpoint_selected(player):
_move_to_checkpoint(player, 'second_checkpoint')


def _checkpoints_menu_callback(menu, index, option):
player = player_dict[index]

option.value(player)
menu.send(index)


# ============================================================================
# >> CHECKPOINTS MENU DECLARATION
# ============================================================================
checkpoints_menu = SimpleMenu(select_callback=_checkpoints_menu_callback)

checkpoints_menu.append('Trikz Checkpoints Menu')
checkpoints_menu.append('-' * 20)
checkpoints_menu.append(SimpleOption(1, 'Save 1st checkpoint', _option_save_first_checkpoint_selected))
checkpoints_menu.append(SimpleOption(2, 'Back to 1st checkpoint', _option_move_to_first_checkpoint_selected))
checkpoints_menu.append(' ')
checkpoints_menu.append(SimpleOption(3, 'Save 2nd checkpoint', _option_save_second_checkpoint_selected))
checkpoints_menu.append(SimpleOption(4, 'Back to 2nd checkpoint', _option_move_to_second_checkpoint_selected))
checkpoints_menu.append('-' * 20)
checkpoints_menu.append(f"{'9' if SOURCE_ENGINE == 'csgo' else '0'}. Close")


@checkpoints_menu.register_close_callback
def _on_close_checkpoints_menu(menu, index):
main_menu.send(index)


# ============================================================================
# >> MAIN MENU CALLBACKS
# ============================================================================
def _option_flashbang_selected(player):
if not bool(enable_flash):
return

if not player.flash:
return

if player.get_projectile_ammo('flashbang') < 2:
player.give_named_item('weapon_flashbang')
player.tell('You have received a flashbang grenade.')


def _option_auto_flash_selected(player):
if bool(enable_flash):
player.flash ^= True
player.tell(f"Auto-Flash turned {'on' if player.flash else 'off'}.")


def _option_ghost_selected(player):
if bool(enable_ghost):
player.ghost ^= True
player.set_ghost()


def _option_checkpoints_menu_selected(player):
checkpoints_menu.send(player.index)


def _option_respawn_selected(player):
if player.dead:
player.spawn()


def _main_menu_callback(menu, index, option):
player = player_dict[index]

option.value(player)
menu.send(player.index)


# ============================================================================
# >> MAIN MENU DECLARATION
# ============================================================================
main_menu = SimpleMenu(select_callback=_main_menu_callback)

main_menu.append('Trikz Settings Menu')
main_menu.append('-' * 20)
main_menu.append(SimpleOption(1, 'Give Flash (1)', _option_flashbang_selected))
main_menu.append(SimpleOption(2, 'Toggle Auto-Flash', _option_auto_flash_selected))
main_menu.append(SimpleOption(3, 'Toggle Blocking', _option_ghost_selected))
main_menu.append(SimpleOption(4, 'Checkpoints Menu', _option_checkpoints_menu_selected))
main_menu.append(SimpleOption(5, 'Respawn', _option_respawn_selected))
main_menu.append('-' * 20)
main_menu.append(f"{'9' if SOURCE_ENGINE == 'csgo' else '0'}. Close")

The code is (hopefully) mostly straightforward. I haven't commented it, though.

The following info.ini file should be placed right besides the script:

Syntax: Select all

verbose_name = "Trikz: SP"
author = "<You Name>"
description = "<add description>"
version = "0.1"
url = "<url>"
Edit the info therein as you like.

@Satoon I replaced setting the convar values using queue_command_string(), because I encountered an issue with these lines that are in your code:

Syntax: Select all

queue_server_command(
'mp_friendlyfire 0;'
'sv_gravity 800;'
'sv_airaccelerate 250;'
'mp_limitteams 0;'
'mp_enableboost 1;'
)

Loading the script like that produces the following error on Windows, and if I remember correctly, on Linux also:

Code: Select all

ValueError: Unable to find command 'mp_friendlyfire 0;sv_gravity 800;sv_airaccelerate 250;mp_limitteams 0;mp_enableboost 1;'.
Is this behavior expected?
ae2x
Junior Member
Posts: 13
Joined: Mon Apr 09, 2018 4:26 pm

Re: [CS:S] Trikz

Postby ae2x » Sat Sep 22, 2018 12:47 pm

That is good work but it still not working on counter strike source even that i changed csgo to css
User avatar
BackRaw
Senior Member
Posts: 507
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: [CS:S] Trikz

Postby BackRaw » Mon Oct 15, 2018 1:36 pm

You shouldn't need to change anything. I'll look into CS:S later on today.

What is not working exactly? Is there an error message printed in the server console?
ae2x
Junior Member
Posts: 13
Joined: Mon Apr 09, 2018 4:26 pm

Re: [CS:S] Trikz

Postby ae2x » Tue Oct 30, 2018 6:20 pm

BackRaw wrote:You shouldn't need to change anything. I'll look into CS:S later on today.

What is not working exactly? Is there an error message printed in the server console?



well i tryed bouth without changes and with changes but still didnt work .. the menu not working if you press give flash it wont give it only checkpoint worked .. and it was bugged to.

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 1 guest