Hello, I'm trying to create an entity that follows a player, I've tried multiple threads for using the "SetParent", but none of the entities are "following" the player, and neither is it being teleported to the Players correct cords. The entity must also trigger "trigger_multiple" too, the flags on the "trigger_multiple" is "1088".
I've tried 0.1 timers between using SetParent and SetParentAttachment etc.
The 1.0 Timer includes me moving in-game too.
PHP Code:
void EntityPlayer(int iClient) {
float fPos[3];
GetClientAbsOrigin(iClient, fPos);
PrintToChatAll("CReating: %i, %f, %f, %f", iClient, fPos[0], fPos[1], fPos[2]);
int iEntity = CreateEntityByName("trigger_multiple");
if (iEntity > 0 && IsValidEntity(iEntity)) {
char[] cBuffer = new char[512];
SetEntityModel(iEntity, "models/error.mdl");
Format(cBuffer, 512, "cclient%i", iClient);
DispatchKeyValue(iClient, "targetname", cBuffer);
SetVariantString("!activator");
AcceptEntityInput(iEntity, "SetParent", iClient);
SetEntityMoveType(iEntity, MOVETYPE_NOCLIP);
if (DispatchSpawn(iEntity)) {
PrintToChatAll("Spawned %i", iEntity);
DataPack pack = new DataPack();
pack.WriteCell(iEntity);
pack.WriteCell(iClient);
CreateTimer(0.1, Timer_Assign, pack);
CreateTimer(1.0, Timer_Entity, iEntity, TIMER_REPEAT);
}
}
}
public Action Timer_Assign(Handle hTimer, DataPack pack) {
PrintToChatAll("Running");
pack.Reset();
int iEntity = pack.ReadCell();
int iClient = pack.ReadCell();
PrintToChatAll("%i, %i", iEntity, iClient);
//AcceptEntityInput(iEntity, "SetParentAttachment", iClient, iEntity);
}
public Action Timer_Entity(Handle hTimer, int iEntity) {
if (IsValidEntity(iEntity)) {
float fPos[3];
GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fPos);
PrintToChatAll("Entity: %i, %f, %f, %f", iEntity, fPos[0], fPos[1], fPos[2]);
}
}
__________________