Bean Posted September 30, 2012 Share Posted September 30, 2012 I'm basically trying to make it so the player can toggle their own radar GUI, here's the code I made, and I'm very, very new to this, if I could possibly get some help here? function toggleradar(command, onoff, thePlayer) if onoff="1" then setPlayerHudComponent(root, "radar", true, thePlayer) outputChatBox("Radar was turned on.") else if onoff="0" then setPlayerHudComponent(root, "radar", false, thePlayer) outputChatBox("Radar was turned off.") else outputChatBox("Syntax: /setradar [1=on], [0=off]" end addCommandHandler("setradar", toggleradar) Link to comment
Mossy Posted September 30, 2012 Share Posted September 30, 2012 (edited) try local toggleradar = createRadarArea ( -2183.5678710938, 705.67950439453, 40, -40, 0, 255, 0, 175 ) -- REPLACE these numbers if needed. local localplayer = getLocalPlayer if onoff="1" then setPlayerHudComponent(root, "radar", true, localplayer) outputChatBox("Radar was turned on.") else if onoff="0" then setPlayerHudComponent(root, "radar", false, localplayer) outputChatBox("Radar was turned off.") else outputChatBox("Syntax: /setradar [1=on], [0=off]" end addCommandHandler("setradar", toggleradar) If localplayer doesn't work replace it with thePlayer and remove local localplayer = getLocalPlayer Edited September 30, 2012 by Guest Link to comment
Jaysds1 Posted September 30, 2012 Share Posted September 30, 2012 'setPlayerHudComponent' doesn't exist, try this: function toggleradar(_, onoff, thePlayer) if onoff=="1" then showPlayerHudComponent("radar", true) outputChatBox("Radar was turned on.") elseif onoff=="0" then showPlayerHudComponent("radar", false) outputChatBox("Radar was turned off.") else outputChatBox("Syntax: /setradar [1=on], [0=off]", end end addCommandHandler("setradar", toggleradar) Link to comment
Dev Posted September 30, 2012 Share Posted September 30, 2012 If you're making is client side then, function toggleRadar( commandName, argument ) if ( argument ~= nil ) then local argument = tostring( argument ) if ( argument == '1' ) then showPlayerHudComponent('radar', true) outputChatBox('Radar was turned on.', 0, 200, 0) elseif ( argument == '0' ) then showPlayerHudComponent('radar', false) outputChatBox('Radar was turned off.', 200, 0, 0) else outputChatBox('SYNTAX: /'.. commandName ..' [ 1/2 ]', 255, 255, 255) end else outputChatBox('SYNTAX: /'.. commandName ..' [ 1/0 ]', 255, 255, 255) end end addCommandHandler('setradar', toggleRadar, false, false ) or if you're making it serverside, function toggleRadar( thePlayer, commandName, argument ) if ( argument ~= nil ) then local argument = tostring( argument ) if ( argument == '1' ) then showPlayerHudComponent(thePlayer, 'radar', true) outputChatBox('Radar was turned on.', thePlayer, 0, 200, 0) elseif ( argument == '0' ) then showPlayerHudComponent(thePlayer, 'radar', false) outputChatBox('Radar was turned off.', thePlayer, 200, 0, 0) else outputChatBox('SYNTAX: /'.. commandName ..' [ 1/2 ]', thePlayer, 255, 255, 255) end else outputChatBox('SYNTAX: /'.. commandName ..' [ 1/0 ]', thePlayer, 255, 255, 255) end end addCommandHandler('setradar', toggleRadar, false, false ) Link to comment
Bean Posted October 2, 2012 Author Share Posted October 2, 2012 Got it working thanks guys. 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