• forcing target of a swep to execute a console command on their client
    2 replies, posted
I'm trying to make a gun that forces the person who gets shot to execute a command on their client side console. Im basically updating the TTT thriller (Original addon dev here: https://steamcommunity.com/sharedfiles/filedetails/?id=794651430) and making it so you can see yourself dance, from what i know there is 2 ways to do this. i can either use calcview or i can force the target to go into third person using the thirdperson_toggle command. My original idea was to do this: Player:ConCommand("thirdperson_toggle") but the code identifies the target as an ent not as a player and my fear is that in using this the person using the gun gets put into third person, using calcview would also do a similar effect i fear and whilst calcview is probably easier i have no idea how to use it. code below:    bullet.Callback = function(att, tr)                         if SERVER or (CLIENT and IsFirstTimePredicted()) then                            local ent = tr.Entity                               if SERVER and ent:IsPlayer() then ent:EmitSound("thrilcut.wav") ent:GodEnable() local timerName = "reDance" .. math.random(1,10000) timer.Create( timerName, 1, 14, function()   local danceChange = math.random(1, 2)   if danceChange == 1 then     ent:DoAnimationEvent( ACT_GMOD_GESTURE_TAUNT_ZOMBIE, 1641 )   else     ent:DoAnimationEvent( ACT_GMOD_TAUNT_DANCE, 1642 )   end   if !ent:IsFrozen() then ent:Freeze(true) end end) ent:Freeze(true) timer.Simple( 14, function()  if ent:Alive() then ent:GodDisable() ent:Freeze(false) local totalHealth = ent:Health() local inflictWep = ents.Create('weapon_ttt_thriller') ent:TakeDamage( totalHealth, att, inflictWep ) timer.Simple( 2, function() if ent:IsFrozen() then ent:Freeze(false) end end) end end)                                 end                            end                         end    self.Owner:FireBullets( bullet )    if SERVER then      self:TakePrimaryAmmo( 1 )    end end ps: i am a complete noob when it comes to lua in general as this is my first time using it, if there is a simple answer that i am missing then i apologise
Just to give you some help, players inherit the entity class, so players are entities but not all entities are players. The second if check verifies that the entity is indeed a player, so you can call player functions on the entity such as Player/DoAnimationEvent which is already being used in the code you provided.
Thank you so much! was looking at google for ages to try and find out On a side note, just to verify i should be able to just do the player:concommand without having to do anything special?
Sorry, you need to Log In to post a reply to this thread.