Guest User

Untitled

a guest
Jan 21st, 2023
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. function PlayerSetup(tParams)
  2. {
  3.     local hPlayer = GetPlayerByUserId(tParams.userid);
  4.     // we assign a think function on the player
  5.     hPlayer.GetOrCreatePrivateScriptScope().Think <- function()
  6.     {
  7.         // get ground entity from netprops
  8.         local hEnt = NetProps.GetPropEntity(self,"m_hGroundEntity");
  9.         // if ground entity is a valid npc
  10.         if (hEnt && hEnt.IsNPC() && hEnt.IsAlive())
  11.         {
  12.             // kill npc
  13.             local dmgInfo = CreateDamageInfo(
  14.                 self, null, self.GetOrigin(), self.GetOrigin(), 1e10, DMG_CRUSH);
  15.             hEnt.TakeDamage(dmgInfo);
  16.             DestroyDamageInfo(dmgInfo);
  17.         }
  18.     };
  19.     // run think function
  20.     hPlayer.SetThinkFunction("Think", 0.1);
  21. }
  22. // create a event that triggers when a players joins
  23. ListenToGameEvent("player_join_game", PlayerSetup, "YourContext");
Advertisement
Add Comment
Please, Sign In to add comment