AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   L4D2 vscript spawn env_spritetrail ,but it does not work (https://forums.alliedmods.net/showthread.php?t=321465)

Xiaoer 02-12-2020 06:53

L4D2 vscript spawn env_spritetrail ,but it does not work
 
i try to spawn a env_spritetrail entity.but i find it is spawned but not work. i try it in hammer with a simple code.
Code:

hPlayer1<-null;
others<-null;
function OnGameEvent_player_say(event)
{
       
        if (GetPlayerFromUserID(event.userid) == null) return;
        local hPlayer = GetPlayerFromUserID(event.userid);
        local sText = event.text;
        if (hPlayer != null)
        {
        hPlayer1=hPlayer;
        local other=null;
        other=Entities.FindByName(other,"truesw")
        local entity_effect=clone Entitysword_effect;
        entity_effect.origin=other.GetOrigin();
        others=g_ModeScript.CreateSingleSimpleEntityFromTable(entity_effect)
        printl(others.GetName());
                DoEntFire("!self", "SetParent", "!activator", 0.1 ,other,others)
AddThinkToEnt(self,"t");
        }
        }
        function t(){

        local sb=null
        sb=Entities.FindByName(sb,"_4_svb")
//The targetname of entity spawned by script
        local other=null;
        other=Entities.FindByName(other,"truesw")
printl(sb.GetOrigin());
printl(other.GetOrigin());
        }
       
        Entitysword_effect <-
{
    classname = "env_spritetrail"
        startwidth ="8.0"
        endwidth ="1.0"
        lifetime= "3"
        renderamt ="255"
        rendercolor= "0 48 96"
        rendermode ="5"
        spritename ="models/SS/sword_trail.vmt"
        targetname="svb"
        origin = Vector(0, 0, 0)

}

printl shows this entity indeed move with its parent. truesw is a prop_dynamic entity,whitch is moving .what the most strange is that i put a env_spritetrail by hammer it is work prefectly,but spawn by script with the same parameter it just does not work. Thank you

Vit_amin 02-12-2020 08:01

Re: L4D2 vscript spawn env_spritetrail ,but it does not work
 
I'll to tried spawn env_spritetrail from VScript but only sprite color doesn't changed

Xiaoer 02-12-2020 09:25

Re: L4D2 vscript spawn env_spritetrail ,but it does not work
 
Quote:

Originally Posted by Vit_amin (Post 2683487)
I'll to tried spawn env_spritetrail from VScript but only sprite color doesn't changed

you mean...it works,just color is not right?:cry: why ...mine doesn't show trail at all...

Vit_amin 02-12-2020 13:45

Re: L4D2 vscript spawn env_spritetrail ,but it does not work
 
Yes, but i using other code

Marttt 02-12-2020 15:51

Re: L4D2 vscript spawn env_spritetrail ,but it does not work
 
Try to convert it into a plugin, or is it mandatory to be a vscript?

Xiaoer 02-12-2020 22:16

Re: L4D2 vscript spawn env_spritetrail ,but it does not work
 
Quote:

Originally Posted by Marttt (Post 2683556)
Try to convert it into a plugin, or is it mandatory to be a vscript?

it is vscript in a mod,plugin can not Put in mod to use, it maybe a bug for vscript

Vit_amin 02-13-2020 16:30

Re: L4D2 vscript spawn env_spritetrail ,but it does not work
 
Paste this to the end script
Code:

__CollectEventCallbacks(this, "OnGameEvent_", "GameEventCallbacks", RegisterScriptGameEventListener)


All times are GMT -4. The time now is 13:58.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.