Okay so i'm new to starting gmod servers and i recently bought armor suits which gives you armor health and jump boost and run speed and when you equip it there's no way to drop it so i want to add a command and i have the lua code but i don't know how to create the command so basically
I want to use this command /dropsuit
and i think the lua code is:
OnRemove = function( ply ) // what happens when the suit is removed
ply:SetArmor( 0 )
ply:SetHealth( 100 )
ply:SetJumpPower( 200 )
if that's it
hook.Add("PlayerChat","DropSuit",function(ply, text)
if text == string.ToLower("!dropsuit") then
if ply:GetNWBool("hasSuit") == true then
ply:SetArmor( 0 )
ply:SetHealth( 100 )
ply:SetJumpPower( 200 )
ply:print("You dropped your suit")
end
end
end)
I think this would work, tgis is untested though so anything is possible, also i dont know how to get if player has suit, so you would need to replace ply:GetNWBool("hasSuit") with whatever you use so it workes correctly unless you want players to dropsuit even if they dont have the suit
Where should i put it it worked but im getting script errors i think it needs to go in client only but im not sure how to do that
ofc serverside provide what script errors you're getting exactly
Thanks you it worked!
So i basically got another code that he said was simpler and im wondering im getting script errors do you think you can help me:
DarkRP.defineChatCommand("dropsuit", function( ply, arguments )
local data = Armor:Get( ply.armorSuit )
if ( data ) then
ply:removeArmorSuit();
local trace = {}
trace.start = ply:EyePos()
trace.endpos = trace.start + ply:GetAimVector() * 85
trace.filter = ply
local tr = util.TraceLine(trace)
local entity = ents.Create( data.Entitie );
entity:SetPos( tr.HitPos );
entity:Spawn();
end
end )
Are you able to add a Delay before they drop the suit ThimSTR ?
Sorry, you need to Log In to post a reply to this thread.