Advertisement
DeathChaos25

clone

Sep 6th, 2015
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.14 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #define DEBUG
  4.  
  5. #define PLUGIN_AUTHOR "DeathChaos25"
  6. #define PLUGIN_VERSION "1.00"
  7.  
  8. static PreviousAnimation[MAXPLAYERS + 1] = -1;
  9. static CloneModel[MAXPLAYERS + 1] = 0;
  10. new PropOff_nSequence;
  11.  
  12. #include <sourcemod>
  13. #include <sdktools>
  14. #include <sdkhooks>
  15.  
  16. public Plugin myinfo =
  17. {
  18.     name = "[L4D2] Clone",
  19.     author = PLUGIN_AUTHOR,
  20.     description = "",
  21.     version = PLUGIN_VERSION,
  22.     url = ""
  23. };
  24.  
  25. public void OnPluginStart()
  26. {
  27.     PropOff_nSequence = FindSendPropInfo("CTerrorPlayer", "m_nSequence");
  28.     RegConsoleCmd("sm_view", ViewAngles);
  29.     RegConsoleCmd("sm_ang", ChangeAngles);
  30.     RegConsoleCmd("sm_pos", ChangePosition);
  31. }
  32.  
  33. public void OnGameFrame()
  34. {
  35.     for (new client = 1; client <= MaxClients; client++)
  36.     {
  37.         if (IsSurvivor(client) && !IsFakeClient(client) && IsPlayerAlive(client))
  38.         {
  39.             new sequence = GetEntData(client, PropOff_nSequence);
  40.             if (CloneModel[client] <= 0 || !IsValidEntity(CloneModel[client]))
  41.             {
  42.                 decl Float:vAngles[3];
  43.                 decl Float:vOrigin[3];
  44.                 GetClientAbsOrigin(client, vOrigin);
  45.                 GetClientAbsAngles(client, vAngles);
  46.                 decl String:playerModel[128];
  47.                 GetEntPropString(client, Prop_Data, "m_ModelName", playerModel, sizeof(playerModel));
  48.                
  49.                 new clone = CreateEntityByName("prop_dynamic_override");
  50.                 SetEntityModel(clone, playerModel);
  51.                
  52.                 SetEntProp(clone, Prop_Data, "m_CollisionGroup", 2);
  53.                 decl String:sTemp[16];
  54.                 Format(sTemp, sizeof(sTemp), "target%d", client);
  55.                 DispatchKeyValue(client, "targetname", sTemp);
  56.                 SetVariantString(sTemp);
  57.                 AcceptEntityInput(clone, "SetParent", clone, clone, 0);
  58.                
  59.                 SetVariantString("bleedout"); //pistol legL
  60.                 AcceptEntityInput(clone, "SetParentAttachment");
  61.                
  62.                 //TeleportEntity(clone, vOrigin, vAngles, NULL_VECTOR);
  63.                 SetEntPropFloat(clone, Prop_Send, "m_flPlaybackRate", GetEntPropFloat(client, Prop_Send, "m_flPlaybackRate"));
  64.                 SetEntData(clone, PropOff_nSequence, sequence);
  65.                
  66.                 //SetEntProp(client, Prop_Send, "m_bDrawViewmodel", 0);
  67.                 //SetEntityRenderMode(client, RENDER_NONE);
  68.                 CloneModel[client] = clone;
  69.                 //ang -80 0 -90
  70.                 //pos -10 -40 -20
  71.                 new Float:pos[3], Float:ang[3];
  72.                 ang[0] = -80.0;
  73.                 ang[1] = 0.0;
  74.                 ang[2] = -90.0;
  75.                
  76.                 pos[0] = -10.0;
  77.                 pos[1] = -40.0;
  78.                 pos[2] = -20.0;
  79.                 TeleportEntity(CloneModel[client], pos, ang, NULL_VECTOR);
  80.             }
  81.             //float CCSPlayer::GetPlayerMaxSpeed()
  82.            
  83.             if (!PreviousAnimation[client])
  84.             {
  85.                 PreviousAnimation[client] = sequence;
  86.             }
  87.             else if (PreviousAnimation[client] != sequence && PreviousAnimation[client] > 0)
  88.             {
  89.                 new Float:angs[3];
  90.                 GetEntPropVector(client, Prop_Send, "m_angRotation", angs);
  91.                
  92.                 SetEntPropFloat(CloneModel[client], Prop_Send, "m_flPlaybackRate", GetEntPropFloat(client, Prop_Send, "m_flPlaybackRate"));
  93.                 SetEntData(CloneModel[client], PropOff_nSequence, sequence);
  94.                 for (new i = 0; i < 92; i += 4)
  95.                 {
  96.                     new prop = FindSendPropInfo("CTerrorPlayer", "m_flPoseParameter");
  97.                     new prop2 = FindSendPropInfo("CDynamicProp", "m_flPoseParameter");
  98.                     new value = GetEntData(client, prop + (i));
  99.                    
  100.                     SetEntData(CloneModel[client], prop2 + (i), value);
  101.                 }
  102.                 SetEntPropFloat(CloneModel[client], Prop_Send, "m_flCycle", GetEntPropFloat(client, Prop_Send, "m_flCycle"));
  103.             }
  104.         }
  105.     }
  106. }
  107.  
  108. stock bool:IsSurvivor(client)
  109. {
  110.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2;
  111. }
  112.  
  113. SetVector(Float:target[3], Float:x, Float:y, Float:z)
  114. {
  115.     target[0] = x;
  116.     target[1] = y;
  117.     target[2] = z;
  118. }
  119.  
  120. public Action:ViewAngles(client, args)
  121. {
  122.     new Float:angles[3];
  123.     GetEntPropVector(CloneModel[client], Prop_Send, "m_vecAngles", angles);
  124.     PrintToChatAll("%f %f %f", angles[0], angles[1], angles[2]);
  125. }
  126.  
  127. public Action:ChangeAngles(client, args)
  128. {
  129.     new String:buffer[32];
  130.     new Float:x, Float:y, Float:z, Float:ang[3];
  131.    
  132.     GetCmdArg(1, buffer, sizeof(buffer));
  133.     x = StringToFloat(buffer);
  134.    
  135.     GetCmdArg(2, buffer, sizeof(buffer));
  136.     y = StringToFloat(buffer);
  137.    
  138.     GetCmdArg(3, buffer, sizeof(buffer));
  139.     z = StringToFloat(buffer);
  140.    
  141.     SetVector(ang, x, y, z);
  142.    
  143.     if (CloneModel[client] > 0 && IsValidEntS(CloneModel[client], "prop_dynamic_override"))
  144.     {
  145.         TeleportEntity(CloneModel[client], NULL_VECTOR, ang, NULL_VECTOR);
  146.     }
  147. }
  148.  
  149. public Action:ChangePosition(client, args)
  150. {
  151.     new String:buffer[32];
  152.     new Float:x, Float:y, Float:z, Float:ang[3];
  153.    
  154.     GetCmdArg(1, buffer, sizeof(buffer));
  155.     x = StringToFloat(buffer);
  156.    
  157.     GetCmdArg(2, buffer, sizeof(buffer));
  158.     y = StringToFloat(buffer);
  159.    
  160.     GetCmdArg(3, buffer, sizeof(buffer));
  161.     z = StringToFloat(buffer);
  162.    
  163.     SetVector(ang, x, y, z);
  164.    
  165.     if (CloneModel[client] > 0 && IsValidEntS(CloneModel[client], "prop_dynamic_override"))
  166.     {
  167.         TeleportEntity(CloneModel[client], ang, NULL_VECTOR, NULL_VECTOR);
  168.     }
  169. }
  170.  
  171. IsValidEntS(ent, String:classname[64])
  172. {
  173.     if (IsValidEnt(ent))
  174.     {
  175.         decl String:name[64];
  176.         GetEdictClassname(ent, name, 64);
  177.         if (StrEqual(classname, name))
  178.         {
  179.             return true;
  180.         }
  181.     }
  182.     return false;
  183. }
  184.  
  185. IsValidEnt(ent)
  186. {
  187.     if (ent > 0 && IsValidEdict(ent) && IsValidEntity(ent))
  188.     {
  189.         return true;
  190.     }
  191.     return false;
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement