View Single Post
Author Message
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 08-14-2019 , 22:30   Creating an Entity which is Parented to a player and triggers "trigger_multiple"
Reply With Quote #1

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(iClientfPos);
    
PrintToChatAll("CReating: %i, %f, %f, %f"iClientfPos[0], fPos[1], fPos[2]);
    
int iEntity CreateEntityByName("trigger_multiple");
    if (
iEntity && IsValidEntity(iEntity)) {
        
char[] cBuffer = new char[512];
        
SetEntityModel(iEntity"models/error.mdl");

        
Format(cBuffer512"cclient%i"iClient);
        
DispatchKeyValue(iClient"targetname"cBuffer);

        
SetVariantString("!activator");
        
AcceptEntityInput(iEntity"SetParent"iClient);  
        
SetEntityMoveType(iEntityMOVETYPE_NOCLIP);

        if (
DispatchSpawn(iEntity)) {
            
PrintToChatAll("Spawned %i"iEntity);

            
DataPack pack = new DataPack();
            
pack.WriteCell(iEntity);
            
pack.WriteCell(iClient);
            
CreateTimer(0.1Timer_Assignpack);

            
CreateTimer(1.0Timer_EntityiEntityTIMER_REPEAT);
        }
    }
}

public 
Action Timer_Assign(Handle hTimerDataPack pack) {
    
PrintToChatAll("Running");
    
pack.Reset();
    
int iEntity pack.ReadCell();
    
int iClient pack.ReadCell();

    
PrintToChatAll("%i, %i"iEntityiClient);
    
//AcceptEntityInput(iEntity, "SetParentAttachment", iClient, iEntity);
}

public 
Action Timer_Entity(Handle hTimerint iEntity) {
    if (
IsValidEntity(iEntity)) {
        
float fPos[3];
        
GetEntPropVector(iEntityProp_Send"m_vecOrigin"fPos);

        
PrintToChatAll("Entity: %i, %f, %f, %f"iEntityfPos[0], fPos[1], fPos[2]);
    }

__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS

Last edited by OSWO; 08-14-2019 at 22:39.
OSWO is offline