Page 1 of 2
Blinding players and changing models
Posted: Thu Sep 04, 2014 5:56 pm
by BackRaw
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

Posted: Thu Sep 04, 2014 6:13 pm
by Ayuto
Posted: Thu Sep 04, 2014 6:16 pm
by Hedgehog
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')
Posted: Thu Sep 04, 2014 6:17 pm
by BackRaw
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

Posted: Thu Sep 04, 2014 6:19 pm
by BackRaw
Nevermind Ayuto, got it

Posted: Thu Sep 04, 2014 6:27 pm
by Hedgehog
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.
Posted: Fri Sep 05, 2014 12:59 am
by satoon101
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.
Posted: Fri Sep 05, 2014 5:44 am
by BackRaw
Didn't know about setting / getting props! Thanks that helps a lot.
Posted: Thu Sep 11, 2014 9:42 am
by BackRaw
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.
Posted: Thu Sep 11, 2014 5:49 pm
by L'In20Cible
Test it and let us know?
Posted: Fri Sep 12, 2014 7:54 am
by BackRaw
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

Posted: Wed Sep 24, 2014 4:39 pm
by 8guawong
so does it work BackRaw??

Posted: Thu Sep 25, 2014 3:54 am
by 8guawong
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
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!
Posted: Thu Sep 25, 2014 4:24 am
by L'In20Cible
Syntax: Select all
from listeners import LevelInit
@LevelInit
def level_init_listener(map_name):
# ...
Posted: Thu Sep 25, 2014 4:27 am
by satoon101
For reference:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/listeners/__init__.pyFor passed argument reference:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/src/core/addons/sp_addon.cppYou 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
Posted: Thu Sep 25, 2014 4:30 am
by L'In20Cible
satoon101 wrote:*Edit: darn, too slow
But more detailled!!

Posted: Thu Sep 25, 2014 4:54 am
by 8guawong
a big thank you to both of you!
Posted: Tue Oct 07, 2014 10:30 pm
by BackRaw
Forgot to mention, sorry for being so late. PlayerEntity.set_model_index() doesn't do anything lol

Posted: Tue Oct 07, 2014 10:38 pm
by satoon101
What is your test script? I still haven't tested anything myself, but I would like to know what you tried.
Posted: Tue Oct 07, 2014 11:05 pm
by BackRaw
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