• Best way of removing this entity?
    4 replies, posted
Hello, I want to remove the following floating object when the player, switches to a weapon, and I was wondering how I could do this. Screenshot: [url]http://steamcommunity.com/sharedfiles/filedetails/?id=512143425[/url] The code I am trying to use, does not work. [code] hook.Add( "KeyPress", "RemoveEntity", function( ply, key ) if ( ply:GetActiveWeapon():GetClass() == "weapon_sh_tool" ) then if(key == KEY_1 or key == KEY_2 or key == KEY_3 or key == KEY_4)then ents.FindByName("GhostEntity"):Remove() end end end ) [/code] I am using this script to control switching weapons: [url]http://facepunch.com/showthread.php?t=1484243[/url] [editline]4th September 2015[/editline] Anyone got an idea?
Any errors? Optimize the code(I dont know if it affects it) - put spaces between if and the (, same with the end. Plus it checks if you got the toolgun(if I am right) equiped, then the code will be run, else not.
[QUOTE=whitestar;48614932]Any errors? Optimize the code(I dont know if it affects it) - put spaces between if and the (, same with the end. Plus it checks if you got the toolgun(if I am right) equiped, then the code will be run, else not.[/QUOTE] It only checking if I have the custom tool gun is what I want, spaces dont matter
Well in the image you dont have it equipped if I am right.
[QUOTE=whitestar;48614932]Any errors? Optimize the code(I dont know if it affects it) - put spaces between if and the (, same with the end. Plus it checks if you got the toolgun(if I am right) equiped, then the code will be run, else not.[/QUOTE] Its just that the second if doesnt seem to run. [editline]4th September 2015[/editline] [QUOTE=whitestar;48614984]Well in the image you dont have it equipped if I am right.[/QUOTE] yes, that is my issue, when I switch to a weapon, the entity should be removed The code should: check if the player has the custom toolgun. then, check if the player switches to another weapon(I use the keys 1,2,3,4 to switch to the others with my custom script) then, should remove the entity GhostEntity, which is the floating object you see in the image
Sorry, you need to Log In to post a reply to this thread.