scripts to produce player trails and icon above player's head

Please post any questions about developing your plugin here. Please use the search function before posting!
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

scripts to produce player trails and icon above player's head

Postby 8guawong » Mon Nov 10, 2014 6:50 am

User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Nov 10, 2014 3:57 pm

Once the entities_changes branch is finished, the following should work for trails (actually tested with my local version and it does work):

Syntax: Select all

from colors import BLUE
from colors import RED
from engines.precache import Model
from entities.entity import BaseEntity
from entities.helpers import create_entity
from events import Event
from filters.players import PlayerIter


model = Model('materials/sprites/laser.vmt')
teams = {
2: RED,
3: BLUE,
}


@Event
def player_say(game_event):
for index, team in PlayerIter('alive', return_types=['index', 'team']):
create_trail(index, teams[team])


def create_trail(index, color):
entity = BaseEntity(index)
trail = BaseEntity(create_entity('env_spritetrail'))
trail.lifetime = 10
trail.startwidth = 1
trail.endwidth = 1
trail.spritename = model
trail.color = color
origin = entity.origin
origin.z += 10
trail.origin = origin
trail.spawn()
trail.set_parent(entity.pointer, -1)
trail.set_prop_float('m_flTextureRes', 0.05)
trail.show_sprite()



I haven't tested the emote, as of yet.
Image
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Tue Nov 11, 2014 6:37 am

satoon101 wrote:Once the entities_changes branch is finished, the following should work for trails (actually tested with my local version and it does work):

Syntax: Select all

from colors import BLUE
from colors import RED
from engines.precache import Model
from entities.entity import BaseEntity
from entities.helpers import create_entity
from events import Event
from filters.players import PlayerIter


model = Model('materials/sprites/laser.vmt')
teams = {
2: RED,
3: BLUE,
}


@Event
def player_say(game_event):
for index, team in PlayerIter('alive', return_types=['index', 'team']):
create_trail(index, teams[team])


def create_trail(index, color):
entity = BaseEntity(index)
trail = BaseEntity(create_entity('env_spritetrail'))
trail.lifetime = 10
trail.startwidth = 1
trail.endwidth = 1
trail.spritename = model
trail.color = color
origin = entity.origin
origin.z += 10
trail.origin = origin
trail.spawn()
trail.set_parent(entity.pointer, -1)
trail.set_prop_float('m_flTextureRes', 0.05)
trail.show_sprite()



I haven't tested the emote, as of yet.


very cool but if i want to use custom trails do i just replace the

Syntax: Select all

model = Model('materials/sprites/laser.vmt')

for the emote i was thinking it would cool to attach floating admin/vip text over players head ;-)
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Nov 11, 2014 2:36 pm

Yes, you would replace the model to change the trail. Also, since you are just passing the string when setting the spritename, you will need to precache when using a custom material:

Syntax: Select all

model.index
trail.spritename = model


We will work on a fix for this, possibly something like:

Syntax: Select all

trail.spritename = model.path


Also, I should have mentioned this yesterday, but I only tested this on CS:S. I will test on CS:GO, when I get the chance, to verify it works.

*Edit: had to change the model to laserbeam instead of laser on CS:GO, but it works :)
http://cloud-4.steampowered.com/ugc/541884075847249020/C35B4AE88412ACBDF6DE25341473C127A431B480/
Image
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Wed Nov 12, 2014 1:41 am

satoon101 wrote:Yes, you would replace the model to change the trail. Also, since you are just passing the string when setting the spritename, you will need to precache when using a custom material:

Syntax: Select all

model.index
trail.spritename = model


We will work on a fix for this, possibly something like:

Syntax: Select all

trail.spritename = model.path


Also, I should have mentioned this yesterday, but I only tested this on CS:S. I will test on CS:GO, when I get the chance, to verify it works.

*Edit: had to change the model to laserbeam instead of laser on CS:GO, but it works :)
http://cloud-4.steampowered.com/ugc/541884075847249020/C35B4AE88412ACBDF6DE25341473C127A431B480/


coolio
looking foward to the the next SP release

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 136 guests