Advertisement
Guest User

Untitled

a guest
May 25th, 2014
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3. #include <sdktools>
  4. //#include <smlib>
  5.  
  6. #pragma semicolon 1;
  7.  
  8. public Plugin:myinfo =
  9. {
  10. name = "OperationL2P Flash Test",
  11. author = "OperationL2P.com",
  12. description = "",
  13. version = "0.1",
  14. url = ""
  15. };
  16. #define FragColor {225,225,225,255}
  17. #define N MAXPLAYERS+1
  18. new g_BeamSprite = -1;
  19. new g_HaloSprite = -1;
  20. new Float:PositionLast[N][3];
  21. new bool:ClientView[N];
  22. new greyColor[4] = {128, 128, 128, 255};
  23. new Float:ClientAngles[N][3];
  24. new Float:ClientOrigins[N][3];
  25.  
  26. new bool_sentinel[MAXPLAYERS+1];//between tele and explode? branching diagram
  27. new bool_dontStart[MAXPLAYERS+1];
  28. new bool_camDisable[MAXPLAYERS+1];
  29. new Float:ClientTargetAngles[N][3];
  30. new Float:ClientTargetOrigins[N][3];
  31. //BY DEFAULT ARRAYS INITIALIZED TO ZERO;
  32.  
  33. new String:ClientNadeName[N][64];
  34. new BeamSprite;
  35. new Handle:specTimers[MAXPLAYERS+1];
  36. /******
  37. *Load*
  38. *******/
  39. public OnMapStart() BeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt");
  40.  
  41.  
  42. public SaveTargetPosition(client)
  43. {
  44. GetClientEyeAngles(client, Float:ClientTargetAngles[client]);
  45. GetClientAbsOrigin(client, Float:ClientTargetOrigins[client]);
  46. }
  47.  
  48. public LoadTargetPosition(client)
  49. {
  50. TeleportEntity(client, Float:ClientTargetOrigins[client], Float:ClientTargetAngles[client], NULL_VECTOR);/////
  51. PositionLast[client] = ClientTargetOrigins[client];
  52. }
  53.  
  54. public SavePosition(client)
  55. {
  56. GetClientEyeAngles(client, Float:ClientAngles[client]);
  57. GetClientAbsOrigin(client, Float:ClientOrigins[client]);
  58. }
  59.  
  60. public LoadPosition(client)
  61. {
  62. TeleportEntity(client, Float:ClientOrigins[client], Float:ClientAngles[client], NULL_VECTOR);
  63. }
  64.  
  65. public StartView(client)
  66. {
  67. if(!ClientView[client])
  68. {
  69. if(IsClientInGame(client))
  70. {
  71. LoadTargetPosition(client);
  72. }
  73. ClientView[client] = true;
  74. }
  75. }
  76.  
  77. public StopView(client)
  78. {
  79. if(ClientView[client])
  80. {
  81. if(IsClientInGame(client))
  82. {
  83. LoadPosition(client);
  84. }
  85. ClientView[client] = false;
  86. }
  87. }
  88.  
  89. public OnPluginStart()
  90. {
  91. RegConsoleCmd("sm_camera", ToggleViewCmd, "Toggle between regular and projectile view");
  92. HookEvent("weapon_fire", OnShot);
  93. HookEvent("player_spawned", OnPlayerSpawn);
  94. HookEvent("inspect_weapon", OnInspect);
  95. }
  96.  
  97. public OnClientDisconnect(client)
  98. {
  99. StopView(client);
  100. }
  101.  
  102. public IsGrenadeName(const String:name[], const String:postfix[])
  103. {
  104. new String:buffer[64];
  105. Format(buffer, 63, "%s%s", "hegrenade", postfix);
  106. if(StrEqual(name, buffer)) return true;
  107. Format(buffer, 63, "%s%s", "smokegrenade", postfix);
  108. if(StrEqual(name, buffer)) return true;
  109. Format(buffer, 63, "%s%s", "flashbang", postfix);
  110. if(StrEqual(name, buffer)) return true;
  111. else return false;
  112. }
  113.  
  114. public OnEntityCreated(iEntity, const String:classname[])
  115. {
  116. if(IsGrenadeName(classname, "_projectile")) SDKHook(iEntity, SDKHook_SpawnPost, OnEntitySpawned);
  117. }
  118.  
  119. public OnEntitySpawned(iGrenade)
  120. {
  121.  
  122. new client = GetEntPropEnt(iGrenade, Prop_Send, "m_hOwnerEntity");
  123. //Client_ChangeToLastWeapon(client);
  124. if (bool_camDisable[client] == 0){
  125.  
  126. if (!ClientView[client]){
  127. SavePosition(client);
  128. CreateTimer(0.1, StartViewAction, client);
  129. } else {
  130. TeleportEntity(iGrenade, {0,0,0}, NULL_VECTOR, {0,0,0});
  131. }
  132. }
  133. TE_SetupBeamFollow(iGrenade, BeamSprite, 0, Float:20.0, Float:3.0, Float:3.0, 5, FragColor);
  134. TE_SendToAll();
  135. }
  136.  
  137. public Action:StartViewAction(Handle:timer, any:client)
  138. {
  139. StartView(client);
  140. }
  141.  
  142. public Action:StopViewAction(Handle:timer, any:client)
  143. {
  144. StopView(client);
  145. specTimers[client] = INVALID_HANDLE;
  146. }
  147.  
  148. public Action:GiveNade(Handle:timer, any:client)
  149. {
  150. //new String:buffer[128] =
  151. //"give weapon_";
  152. //"weapon_";
  153. //StrCat(buffer, 127, ClientNadeName[client]);
  154. //FakeClientCommand(client, buffer);
  155. //Client_GiveWeapon(client, buffer);
  156. }
  157.  
  158.  
  159. public OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  160. {
  161. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  162. PrintToChatAll("Event: player_spawned");
  163. if(IsClientInGame(client)) SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
  164. }
  165.  
  166. public OnShot(Handle:event, const String:name[], bool:dontBroadcast)
  167. {
  168. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  169. new String:weapon[32];
  170. GetEventString(event, "weapon", String:weapon, 32);
  171. if(
  172. !IsGrenadeName(weapon, "")
  173. && IsClientInGame(client)) SaveTargetPosition(client);
  174. else {
  175. strcopy(ClientNadeName[client], 63, weapon);
  176. CreateTimer(0.2, GiveNade, client);
  177. }
  178. }
  179. public OnInspect(Handle:event, const String:name[], bool:dontBroadcast)
  180. {
  181. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  182. if (ClientView[client])
  183. {
  184. specTimers[client] = CreateTimer(0.1, StopViewAction, client);
  185. }
  186. }
  187. public Action:ToggleViewCmd(client, args)
  188. {
  189. // Client has access to toggle commands
  190. if(IsValidClient(client) && CheckCommandAccess(client, "sm_camera", 0, true))
  191. {
  192. // Toggle projectile view
  193. bool_camDisable[client] = !bool_camDisable[client];
  194.  
  195. // Client just disabled projectile view
  196. if(bool_camDisable[client])
  197. {
  198.  
  199. PrintToChat(client, "%s", "Camera disabled");
  200.  
  201. }
  202. else
  203. {
  204.  
  205. PrintToChat(client, "%s", "Camera enabled");
  206.  
  207. }
  208. }
  209. else
  210. PrintToChat(client, "\x01\x0B\x04[SM]\x01 %t", "access");
  211. return Plugin_Handled;
  212. }
  213.  
  214. /********
  215. *Stocks*
  216. *********/
  217.  
  218. stock IsValidClient(client)
  219. {
  220. if(client > 0 && client <= MAXPLAYERS && IsClientInGame(client))
  221. return true;
  222. return false;
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement