PDA

View Full Version : func_rotating and sprite_trail


TryNoob
01-07-2012, 05:46
Please help me how to properly install and fasten func_rotating and env_spritetrail (only for one player) ?

Here is my code:

new entRotate[MAXPLAYERS+1];
new trails1[MAXPLAYERS+1];
RotateSprite(client)
{
decl String:name[64];
Format(name, 64, "Trails_%d", GetClientUserId(client));
DispatchKeyValue(client, "targetname", name);

entRotate[client]=CreateEntityByName("func_rotating");
if(IsValidEntity(entRotate[client]))
{
DispatchKeyValue(entRotate[client], "targetname", "func_rot");
DispatchKeyValue(entRotate[client], "spawnflags", "65");
DispatchKeyValue(entRotate[client], "maxspeed", "180");
DispatchKeyValue(entRotate[client], "rendermode", "0");
DispatchKeyValue(entRotate[client], "renderfx", "0");
DispatchKeyValue(entRotate[client], "parentname", name);
DispatchKeyValue(entRotate[client], "rendercolor", "0 0 0");
DispatchKeyValue(entRotate[client], "renderamt", "0");
DispatchSpawn(entRotate[client]);

new Float:pos_rotate[3];
GetClientAbsOrigin(client, pos_rotate);
TeleportEntity(entRotate[client], pos_rotate, NULL_VECTOR, NULL_VECTOR);
SetVariantString(name);
AcceptEntityInput(entRotate[client], "SetParent", entRotate[client], entRotate[client]);
}

trail1[client]=CreateEntityByName("env_spritetrail");
if(IsValidEntity(trail1[client]))
{
SetEntPropFloat(trail1[client], Prop_Send, "m_flTextureRes", 0.05);
DispatchKeyValue(trail1[client], "endwidth", "1.0");
DispatchKeyValue(trail1[client], "startwidth", "8.0");
DispatchKeyValue(trail1[client], "lifetime", "3.0");
DispatchKeyValue(trail1[client], "spritename", "sprites/bluelaser1.vmt");
DispatchKeyValue(trail1[client], "parentname", "func_rot");
DispatchKeyValue(trail1[client], "rendermode", "5");
DispatchKeyValue(trail1[client], "renderamt", "255");
DispatchKeyValue(trail1[client], "rendercolor", "255 150 0");
DispatchSpawn(trail1[client]);

new Float:pos1[3];
GetClientAbsOrigin(client, pos1);
pos1[0] += 50;
pos1[2] += 50;
TeleportEntity(trail1[client], pos1, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(trail1[client], "SetParent", trail1[client], trail1[client]);
}
}

Master53
01-08-2012, 14:39
if your parenting more than 1 entity to a player you shouldn't use targetnames.

try this


//Set String:
SetVariantString("!activator");

//Accept:
AcceptEntityInput(Ent, "SetParent", Client, Ent, 0);
this works when i parent a prop_dynamic as a hat and an env_smokestack to identify admins.

TryNoob
01-10-2012, 05:35
if your parenting more than 1 entity to a player you shouldn't use targetnames.

try this


//Set String:
SetVariantString("!activator");

//Accept:
AcceptEntityInput(Ent, "SetParent", Client, Ent, 0);this works when i parent a prop_dynamic as a hat and an env_smokestack to identify admins.

It did not help :(

schmidt
01-10-2012, 17:27
I've used in my script (http://world-source.ru/load/counter_strike_source/scripts_sourcemod/ws_free_c4/5-1-0-220) func_rotating and it works.

TryNoob
01-17-2012, 12:27
I've used in my script (http://world-source.ru/load/counter_strike_source/scripts_sourcemod/ws_free_c4/5-1-0-220) func_rotating and it works.

Что-то я делаю не так, т.к. к игроку (не к его позиции) прикрепить не получается...

schmidt
01-17-2012, 22:10
Что-то я делаю не так, т.к. к игроку (не к его позиции) прикрепить не получается...

Вот для теста скрипт (проверил, работает) :

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define wS_BEAM "sprites/laserbeam.vmt"

public OnPluginStart()
{
HookEvent("player_say", Say);
}

public OnMapStart()
{
PrecacheModel(wS_BEAM, true);
}

new Float:wS_Pos[3], rt_i;

public Say(Handle:event, const String:name[], bool:dontBroadcast)
{
new i = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:text[5];
GetEventString(event, "text", text, sizeof(text));
if (StrEqual(text, "1"))
{
GetClientAbsOrigin(i, wS_Pos);
wS_Pos[2] += 55.0;
}
else if (StrEqual(text, "2"))
{
CreateEnt();
}
else if (StrEqual(text, "3"))
{
DispatchKeyValue(i, "targetname", "x_player");
SetVariantString("x_player");
AcceptEntityInput(rt_i, "SetParent");
}
}

CreateEnt()
{
rt_i = CreateEntityByName("func_rotating");
if (rt_i < 1)
{
LogError("func_rotating error");
return;
}
new sp_i = CreateEntityByName("env_spritetrail");
if (sp_i < 1)
{
AcceptEntityInput(rt_i, "Kill");
LogError("env_spritetrail error");
return;
}

// func_rotating
DispatchKeyValueVector(rt_i, "origin", wS_Pos);
DispatchKeyValue(rt_i, "targetname", "x_rotating");
DispatchKeyValue(rt_i, "renderfx", "0");
DispatchKeyValue(rt_i, "rendermode", "0");
DispatchKeyValue(rt_i, "renderamt", "255");
DispatchKeyValue(rt_i, "rendercolor", "255 255 255");
DispatchKeyValue(rt_i, "maxspeed", "200");
DispatchKeyValue(rt_i, "friction", "20");
DispatchKeyValue(rt_i, "dmg", "0");
DispatchKeyValue(rt_i, "solid", "0");
DispatchKeyValue(rt_i, "spawnflags", "64");
DispatchSpawn(rt_i);

// env_spritetrail
wS_Pos[0] += 35.0;
DispatchKeyValueVector(sp_i, "origin", wS_Pos);
DispatchKeyValue(sp_i, "lifetime", "1");
DispatchKeyValue(sp_i, "startwidth", "25");
DispatchKeyValue(sp_i, "endwidth", "1");
DispatchKeyValue(sp_i, "spritename", wS_BEAM);
DispatchKeyValue(sp_i, "rendermode", "1");
DispatchKeyValue(sp_i, "rendercolor", "255 0 0");
DispatchKeyValue(sp_i, "renderamt", "255");
DispatchSpawn(sp_i);
SetVariantString("x_rotating");
AcceptEntityInput(sp_i, "SetParent");
AcceptEntityInput(sp_i, "ShowSprite");

AcceptEntityInput(rt_i, "Start");
}

1 - сохраняешь позицию
2 - создаешь на этой позиции две entity
3 - становишься их родителем

TryNoob
01-19-2012, 11:05
Спасибо все работает, но хотелось задать два вопроса:
1) Как работает SetVariantString ?
2) Линии наклоняются в зависимости от того куда смотрит игрок, возможно ли зафиксировать на одной из осей ?

И не так важно, но friction ведь нету, есть только fanfriction

Impact123
01-19-2012, 11:09
i'd like to quote asherkin:
This is an English language only forum, include a English translation of your message in your post if you really feel the need to post in a foreign language.

Yours sincerely
Impact

TryNoob
01-19-2012, 12:48
i'd like to quote asherkin:


Yours sincerely
Impact

The question was originally in English, but switched to a more convenient language - what to do? Quote from the English all?

753
01-25-2012, 20:59
brush entities needs model

try

SetEntityMoveType(rt_i, MOVETYPE_PUSH);
PrecacheModel("models/props/cs_office/vending_machine.mdl", true);
SetEntityModel(rt_i, "models/props/cs_office/vending_machine.mdl");
new Float:minbounds[3] = {-5.813004, -4.000000, -5.891006};
new Float:maxbounds[3] = {5.840988, 4.000000, 5.899994};
SetEntPropVector(rt_i, Prop_Send, "m_vecMins", minbounds);
SetEntPropVector(rt_i, Prop_Send, "m_vecMaxs", maxbounds);
SetEntProp(rt_i, Prop_Send, "m_nSolidType", 2);
new enteffects = GetEntProp(rt_i, Prop_Send, "m_fEffects");
enteffects |= 32;
SetEntProp(rt_i, Prop_Send, "m_fEffects", enteffects);
source : https://forums.alliedmods.net/showthread.php?t=129597