Admigo Posted March 7, 2012 Share Posted March 7, 2012 Heey all, I want to make a f1 key for making all other players invisible. I made this code(server side): iv = 0 function invis(thePlayer) for index, player in ipairs(getElementsByType("player")) do if (player ~= thePlayer) then if iv == 0 then iv = 1 setPlayerNametagShowing(player, false) setElementAlpha(player, 0) else iv = 0 setPlayerNametagShowing(player, true) setElementAlpha(player, 255) end end end end bindKey("F1","down",invis) But when i pres f1 nothing happens. No errors. Pls help, Thanks Admigo. Link to comment
Castillo Posted March 7, 2012 Share Posted March 7, 2012 iv = 0 function invis() for index, player in ipairs(getElementsByType("player")) do if (player ~= localPlayer) then if (iv == 0) then iv = 1 setPlayerNametagShowing(player, false) setElementAlpha(player, 0) else iv = 0 setPlayerNametagShowing(player, true) setElementAlpha(player, 255) end end end end bindKey("F1","down",invis) Link to comment
Kenix Posted March 7, 2012 Share Posted March 7, 2012 (edited) local bState = { } function fHide( player ) bState[ player ] = not bState[ player ] if bState[ player ] then setPlayerNametagShowing( root, false ) setElementAlpha( root, 0 ) else setPlayerNametagShowing( root, true ) setElementAlpha( root, 255 ) end return true end addEventHandler( 'onPlayerJoin', root, function( ) bindKey( source, 'F1', 'down', fHide ) end ) addEventHandler( 'onResourceStart', resourceRoot, function( ) for _,v in pairs( getElementsByType 'player' ) do bindKey( v, 'F1', 'down', fHide ) end end ) Solidsnake14, He want sync it for all. Edited March 7, 2012 by Guest Link to comment
Castillo Posted March 7, 2012 Share Posted March 7, 2012 Where? If I'm right, he want's the player to be able to show/hide players. Link to comment
Kenix Posted March 7, 2012 Share Posted March 7, 2012 Nope. You do not know, what's the difference from the client and server? Link to comment
Castillo Posted March 7, 2012 Share Posted March 7, 2012 I'm not sure if he want's that, but well, let's wait and see who was right . And yes, I do know what's the difference, do you think I'm stupid? Link to comment
Kenix Posted March 7, 2012 Share Posted March 7, 2012 (edited) If use it in client side it hide all players only for you ( but all can see you ), if server side anybody hide and anybody can't see each other . I think you understand. If you know, you said this words, but you not say. You say it I'm not sure if he want's that, but well, let's wait and see who was right . Edited March 7, 2012 by Guest Link to comment
Admigo Posted March 7, 2012 Author Share Posted March 7, 2012 I want that every player in server can press f1 if the want to hide/show players so it increase fps;) So what code can i use:P Link to comment
Kenix Posted March 7, 2012 Share Posted March 7, 2012 Can you explain? If use it in client side it hide all players only for you ( but all can see you ), if server side anybody hide and anybody can't see each other . What you choice? Client local state function fHide( ) state = not state for _, v in pairs( getElementsByType 'player' ) do if v ~= localPlayer then if state then setPlayerNametagShowing( v, false ) setElementAlpha( v, 0 ) else setPlayerNametagShowing( v, true ) setElementAlpha( v, 255 ) end end end end bindKey( 'F1', 'down',fHide ) Link to comment
Admigo Posted March 7, 2012 Author Share Posted March 7, 2012 @kenix :I tested with a friend but f1 dont work. If i press f1 i can show/hide all players. i need it for [DM]. Link to comment
Kenix Posted March 7, 2012 Share Posted March 7, 2012 (edited) @kenix :I tested with a friend but f1 dont work. If i press f1 i can show/hide all players. i need it for [DM]. Show meta. local state function fHide( ) state = not state for _, v in pairs( getElementsByType 'player' ) do if v ~= localPlayer then if state then setPlayerNametagShowing( v, false ) setElementAlpha( v, 0 ) else setPlayerNametagShowing( v, true ) setElementAlpha( v, 255 ) end end end end bindKey( 'F1', 'down',fHide ) This code hide/show ( all but not you ). Edited March 7, 2012 by Guest Link to comment
Admigo Posted March 7, 2012 Author Share Posted March 7, 2012 I cant test the codes,first i need players to join my server. mtasa://178.238.227.144:22003 Link to comment
Absence2 Posted March 7, 2012 Share Posted March 7, 2012 I cant test the codes,first i need players to join my server. mtasa://178.238.227.144:22003 I tested it on my server as it looked like a neat script, solid's verison works, including Kenix's, make sure you add it clientsided in meta.xml and it will work jus fine Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now