• Help with invisible script/addon
    4 replies, posted
[B][I]Hello,[/I][/B] Well to be [B]fast[/B] and [B]simple[/B] I need help with making so when i type this command [B][U](!avanish)[/U][/B] the player would turn invisible and to undo you have to type [B][U](!aunvanish)[/U][/B] [CODE]/*------------------------------------------------------------------------------ Code ------------------------------------------------------------------------------*/ hook.Add( "OnPlayerChat", "PlayerSayExample", function(ply, text) if ( ply:GetUserGroup() == AVanished.GroupsAllowed and text:lower() == "!avanish" ) then local ply = LocalPlayer() ply:ChatPrint("You have vanished.") return true else ply:ChatPrint("You don't have permission to use this command.") return true end end)[/CODE] If there is anything wrong with the code please alert me. I am here to learn. Besides that do I need to add anything else to work on a server?
You're creating the ply variable INSIDE an if statement, and trying to access it in another section of the statement, in the else part. This won't work due to how scopes work. Also, OnPlayerChat is a clientside hook. You'll probably want to use PlayerSay [CODE] hook.Add( "PlayerSay", "Vanish", function( ply, text, team ) if ( text:lower() == "!avanish" ) then if ( ply:GetUserGroup() == AVanished.GroupsAllowed ) then ply:SetRenderMode( RENDERMODE_TRANSALPHA ) // Based on some old code ply:SetColor( Color( 0, 0, 0, 0 ) ) // Based on some old code ply:ChatPrint("You have vanished.") else ply:ChatPrint("You don't have permission to use this command.") end return "" // Cancels the text "!avanish" from appearing in the chatbox end end ) [/CODE] Tested, this works surprisingly
[QUOTE=MPan1;51520687]You're creating the ply variable INSIDE an if statement, and trying to access it in another section of the statement, in the else part. This won't work due to how scopes work. Also, OnPlayerChat is a clientside hook. You'll probably want to use PlayerSay [CODE] hook.Add( "PlayerSay", "Vanish", function( ply, text, team ) if ( text:lower() == "!avanish" ) then if ( ply:GetUserGroup() == AVanished.GroupsAllowed ) then ply:SetRenderMode( RENDERMODE_TRANSALPHA ) // Based on some old code ply:SetColor( Color( 0, 0, 0, 0 ) ) // Based on some old code ply:ChatPrint("You have vanished.") else ply:ChatPrint("You don't have permission to use this command.") end return "" // Cancels the text "!avanish" from appearing in the chatbox end end ) [/CODE] Tested, this works surprisingly[/QUOTE] So to make they go back to normal I would put on the SetColor 0,0,0,255??
Reset it to 255, 255, 255, 255, and reset the render mode to opaque.
okay thx
Sorry, you need to Log In to post a reply to this thread.