Blinding players and changing models

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Blinding players and changing models

Postby BackRaw » Thu Sep 04, 2014 5:56 pm

Hi,

can we blind players and change their models? I kinda see how Source.Python works right now, and it's awesome! This plugin grows fast :)

EDIT: oh, by the way, is there an event list? I know that Valve events work, but how about es_map_start() and such added by Mattie? Those were pretty useful :)
User avatar
Ayuto
Project Leader
Posts: 2209
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Thu Sep 04, 2014 6:13 pm

Currently there are no events created by Source.Python. The equivalent for es_map_start is the LevelInit decorator or level_init_listener_manager object. https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/listeners/__init__.py#L51

Yes, you can blind players. Just use the fade class. https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/messages/types/fade.py#L16
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Thu Sep 04, 2014 6:16 pm

To set player model add

Code: Select all

[set_model]
name = _ZN11CBaseEntity8SetModelEPKc
convention = THISCALL
arguments = POINTER,STRING
return_type = VOID

to the source-python/data/source-python/entities/virtuals/cstrike/CBaseEntity.ini

Usage is simple:

Syntax: Select all

PlayerEntity(player_index).set_model('model_path')
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Thu Sep 04, 2014 6:17 pm

Cool, Ayuto, thanks! Can you give me an example of how I can use it in a script? would be nice :)

Thank you Hedgehog!! now I can test my plugin :D
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Thu Sep 04, 2014 6:19 pm

Nevermind Ayuto, got it :)
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Thu Sep 04, 2014 6:27 pm

In case you are going to release your plugin please don't include any files that might overwrite or change some of source-python data files...
satoon101 wrote:In the new version, once it has been finalized, more virtual functions will be included in the data already. You shouldn't release a script that adds values like this to source-python's data, this is just as an example.
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Sep 05, 2014 12:59 am

To blind, you can also use the same method as ES' playerlib:

Syntax: Select all

from players.entity import PlayerEntity

player = PlayerEntity(<index>)
# Reset the player flash properties
player.set_prop_int('m_flFlashMaxAlpha', 0)
player.set_prop_int('m_flFlashDuration', 0)
# Set the new flash properties to flash the player
player.set_prop_int('m_flFlashMaxAlpha', <alpha>)
player.set_prop_int('m_flFlashDuration', <duration>)


There are other ways to set the model, too, which do not require signatures, but I won't post them here until I have tested to verify they work.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Sep 05, 2014 5:44 am

Didn't know about setting / getting props! Thanks that helps a lot.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Thu Sep 11, 2014 9:42 am

Would the following also work for setting models?

Syntax: Select all

from engines.server import engine_server
from players.entities import PlayerEntity

player = PlayerEntity(<index>)

model_index = engine_server.precache_model(<path/to/the/mdl/file>)
player.set_model_index(model_index)
Saw the method here http://wiki.sourcepython.com/index.php/entities#get_model_index but I don't know if it applies to players, I guess so, though.
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Sep 11, 2014 5:49 pm

Test it and let us know?
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Sep 12, 2014 7:54 am

L'In20Cible wrote:Test it and let us know?


I'm at work almost all day with a Linux host - plus I don't have a wifi or ethernet connection, I'm bridging my phone's internet connection. So I don't have a LAN network, obviously :)
I'll test it as soon as I get home, since it's friday :D
My Github repositories:

Source.Python: https://github.com/backraw
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Wed Sep 24, 2014 4:39 pm

so does it work BackRaw?? ;)
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Thu Sep 25, 2014 3:54 am

BackRaw wrote:Cool, Ayuto, thanks! Can you give me an example of how I can use it in a script? would be nice :)

Thank you Hedgehog!! now I can test my plugin :D


hi BackRaw could you show me an example of how to use LevelInit decorator or level_init_listener_manager object
so i can replace my script's es_map_start

thanks!
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Sep 25, 2014 4:24 am

Syntax: Select all

from listeners import LevelInit

@LevelInit
def level_init_listener(map_name):
# ...
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Sep 25, 2014 4:27 am

For reference:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/listeners/__init__.py

For passed argument reference:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/src/core/addons/sp_addon.cpp


You can use any of the managers directly:

Syntax: Select all

from listeners import level_init_listener_manager

def load():
level_init_listener_manager.register_listener(
my_level_init_function)

def unload():
level_init_listener_manager.unregister_listener(
my_level_init_function)

def my_level_init_function(mapname):
print(mapname)


You can also use the decorator, which automatically takes care of registering and unregistering:

Syntax: Select all

from listeners import LevelInit

@LevelInit
def my_level_init_function(mapname):
print(mapname)


*Edit: darn, too slow
Image
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Sep 25, 2014 4:30 am

satoon101 wrote:*Edit: darn, too slow
But more detailled!! :D
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Thu Sep 25, 2014 4:54 am

a big thank you to both of you!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Tue Oct 07, 2014 10:30 pm

Forgot to mention, sorry for being so late. PlayerEntity.set_model_index() doesn't do anything lol :D
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Oct 07, 2014 10:38 pm

What is your test script? I still haven't tested anything myself, but I would like to know what you tried.
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Tue Oct 07, 2014 11:05 pm

Well it didn't work when I tested it, now it says that 'set_model_index' isn't an attribute of PlayerEntity lol. What's a player's "ServerEntity" instance? I'm referring to http://wiki.sourcepython.com/index.php/entities#ServerEntity
My Github repositories:

Source.Python: https://github.com/backraw

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 130 guests