how would i script this in SP??

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

how would i script this in SP??

Postby 8guawong » Fri Dec 05, 2014 3:32 pm

Code: Select all

   DispatchKeyValue(sprite, "classname", "env_sprite_oriented");
    DispatchKeyValue(sprite, "spawnflags", "1");
    DispatchKeyValue(sprite, "scale", "0.3");
    DispatchKeyValue(sprite, "rendermode", "1");
    DispatchKeyValue(sprite, "rendercolor", "255 255 255");
    DispatchKeyValue(sprite, "model", OVERLAY);
    if(DispatchSpawn(sprite))    return sprite;

GetClientAbsOrigin(client, origin);
        origin[2] = origin[2] + 90.0;
        TeleportEntity(entity, origin, NULL_VECTOR, NULL_VECTOR);

        SetVariantString("!activator");
        AcceptEntityInput(entity, "SetParent", client);

if(IsValidEntity(entity)) {
        AcceptEntityInput(entity, "Kill");
    }


following is what i have come up with but not sure if it'll work

Syntax: Select all

entity = BaseEntity(index)
sprite = BaseEntity(create_entity('env_sprite_oriented'))
sprite.spawnflags = 10
sprite.scale = 1
sprite.rendermode = 1
sprite.rendercolor = 255 255 255
sprite.model = model

PlayerEntity(index).location[1] + 90
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Fri Dec 05, 2014 5:45 pm

If you're not sure then test it!?

But some pointers:

You aren't spawning your entity. (I think this will be changed in an upcoming version of SP)

Syntax: Select all

spawn_entity(sprite.index)


AFAIK you have to use the edict to set key values:

Syntax: Select all

sprite.edict.set_key_value_int("rendermode", 1)


You can set the location of your sprite using:

Syntax: Select all

player = PlayerEntity(index)
sprite.edict.set_key_value_vector("origin", player.location + Vector(0, 90, 0))
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Dec 06, 2014 4:03 am

We have added an 'origin' property for entities in the entities_changes branch. With it, you can use:

Syntax: Select all

sprite.origin = player.origin + Vector(0, 90, 0)


spawn_entity will be located in entities.helpers, and will likely be wrapped by BaseEntity.spawn (except in the case of PlayerEntity). To set the color, you will simply need to use:

Syntax: Select all

BaseEntity.set_color(Color)

# or
BaseEntity.color = Color

Color in the above example is any Color object including any of our built-in colors:
http://wiki.sourcepython.com/pages/colors
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 10 guests