Jaysds1 Posted August 23, 2011 Author Posted August 23, 2011 is it possible to make a console command? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted August 23, 2011 Posted August 23, 2011 addCommandHandler, already does that. The command can be used in the console without the "/". And in the chat box with "/". Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted August 23, 2011 Author Posted August 23, 2011 ok, thanks My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted August 23, 2011 Posted August 23, 2011 You welcome. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted August 30, 2011 Author Posted August 30, 2011 Hi everyone again, I'm having a trouble with this Local chat script, When the person/player presses u, it's suppose to show "Local" instead of "Say" and have the type in, but the keys aren't bind and it doesn't work at all addEventHandler("onPlayerJoin", getRootElement(), function(player) bindKey(player,"u","down",locl) end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function(player) for index, player in pairs(getElementsByType("player")) do unbindKey ( player, "u", "down",locl ) end end) function locl(button,state,_,...) if (button == "left") and (state == "down") then local px,py,pz = getElementPosition(source) local msg = table.concat({...}, " ") local nick = getPlayerName(source) local r,g,b = getTeamColor(getPlayerTeam(source)) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("(Local) "..nick..": "..msg,v,r,g,b,true) end end end end function isPlayerInRangeOfPoint(player,x,y,z,range) local px,py,pz=getElementPosition(player) return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range end My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Cadu12 Posted August 30, 2011 Posted August 30, 2011 Look at line 10. Change to bindKey( player, "u", "down",locl ) Ingame nick: Cadu12
Jaysds1 Posted August 31, 2011 Author Posted August 31, 2011 it doesn't work My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted August 31, 2011 Posted August 31, 2011 The code you copied from another topic was wrong, you forgot functions and changed things wrongly. chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"U","down","chatbox","Local") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"U","down","chatbox","Local") end end) function isPlayerInRangeOfPoint(player,x,y,z,range) local px,py,pz=getElementPosition(player) return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range end function onChat(player,i,...) local px,py,pz=getElementPosition(player) local nick=getPlayerName(player) local msg = table.concat({...}, " ") local r,g,b = getTeamColor(getPlayerTeam(player)) for i,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("(Local) ".. nick ..": "..msg,v,r,g,b,true) end end end addCommandHandler("Local",onChat) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted August 31, 2011 Author Posted August 31, 2011 I never took it from another topic, i was working with Zalmon b4 then I just edited the script and try to make it a bind key, that's all, and it's really mine. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted August 31, 2011 Posted August 31, 2011 Parts of the code we're from another topic (don't discuss, would be useless), and you forgot the function isPlayerInRangeOfPoint. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted September 7, 2011 Author Posted September 7, 2011 Hi everyone, I have a problem with this Save script, it's suppose to save the players username but first it checks to see if there is anything in the value, but it doesn't check and doesn't save the username, Client-side ONLY: if (guiCheckBoxGetSelected(user_safe) == true) then safe = xmlLoadFile("safe.xml") child = xmlFindChild(safe,"Username") if (xmlNodeGetValue(child) ~= nil) then xmlNodeSetValue(child,username) if (xmlNodeGetValue(child1) ~= "") then child2 = xmlFindChild(safe,"Username2") if (xmlNodeGetValue(child2) ~= "") then outputChatBox("*INFO*: THERE IS NO MORE SPACE IN YOUR SAFE DIRECTORY TO SAVE YOUR USERNAME!",getLocalPlayer(),255,0,0) else xmlNodeSetValue(child2,username) end else xmlNodeSetValue(child1,username) end else child1 = xmlFindChild(safe,"Username1") end end My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted September 7, 2011 Posted September 7, 2011 Try: if (guiCheckBoxGetSelected(user_safe) == true) then safe = xmlLoadFile("safe.xml") child = xmlFindChild(safe,"Username",0) if (xmlNodeGetValue(child) ~= nil) then xmlNodeSetValue(child,username) if (xmlNodeGetValue(child1) ~= "") then child2 = xmlFindChild(safe,"Username2",0) if (xmlNodeGetValue(child2) ~= "") then outputChatBox("*INFO*: THERE IS NO MORE SPACE IN YOUR SAFE DIRECTORY TO SAVE YOUR USERNAME!",getLocalPlayer(),255,0,0) else xmlNodeSetValue(child2,username) end else xmlNodeSetValue(child1,username) end else child1 = xmlFindChild(safe,"Username1",0) end end Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Castillo Posted September 7, 2011 Posted September 7, 2011 outputChatBox client side does not require a player argument. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted September 7, 2011 Author Posted September 7, 2011 @JR10 That doesn't work, it doesn't output the errors anymore, but doesn't add the username to the File, Do I need to add the xmlSaveFile() when the is writen? @Solidsnake14 Thanks for telling me EDITED: IT WORKS NOW, THANKS JR10 FOR HELP My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted September 7, 2011 Posted September 7, 2011 You welcome. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted September 13, 2011 Author Posted September 13, 2011 Hi all, Today I'm editing my Login GUI and when the player presses enter the Login GUI is suppose to close, but when I press enter it doesn't close, Here's my script: function finishNow() if (guiGetVisible(logGui) == true) then local username = guiGetText(user_edit) local password = guiGetText(pass_edit) if (username ~= "") and (password ~= "") then triggerServerEvent("log",getRootElement(),username,password,gui) else outputChatBox("*INFO*: Please enter your username and password",getLocalPlayer(),255,0,0) end elseif (guiGetVisible(regGui) == true) then local username = guiGetText(user_edit1) local password = guiGetText(pass_edit1) if (username ~= "") and (password ~= "") then triggerServerEvent("reg",getRootElement(),username,password) else outputChatBox("*INFO*: Please enter a username and password",getLocalPlayer(),255,0,0) end end end addEvent("c1",true) addEventHandler("c1",getRootElement(),function() if (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) addEvent("c2",true) addEventHandler("c2",getRootElement(),function() if (guiGetVisible(regGui) == true) and (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(regGui) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) It basically gets the text in the username and password box and triggers an event, then another event triggers back to the script and unbind the key. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted September 13, 2011 Posted September 13, 2011 I think you are never binding the keys at all. function finishNow() if (guiGetVisible(logGui) == true) then local username = guiGetText(user_edit) local password = guiGetText(pass_edit) if (username ~= "") and (password ~= "") then triggerServerEvent("log",getRootElement(),username,password,gui) else outputChatBox("*INFO*: Please enter your username and password",getLocalPlayer(),255,0,0) end elseif (guiGetVisible(regGui) == true) then local username = guiGetText(user_edit1) local password = guiGetText(pass_edit1) if (username ~= "") and (password ~= "") then triggerServerEvent("reg",getRootElement(),username,password) else outputChatBox("*INFO*: Please enter a username and password",getLocalPlayer(),255,0,0) end end end bindKey("enter","down",finishNow) addEvent("c1",true) addEventHandler("c1",getRootElement(),function() if (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) addEvent("c2",true) addEventHandler("c2",getRootElement(),function() if (guiGetVisible(regGui) == true) and (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(regGui) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted September 13, 2011 Author Posted September 13, 2011 sorry, this is how it looks: addEventHandler("onClientPlayerJoin",getRootElement(),function() bindKey("enter","down",finishNow) end) function finishNow() if (guiGetVisible(logGui) == true) then local username = guiGetText(user_edit) local password = guiGetText(pass_edit) if (username ~= "") and (password ~= "") then triggerServerEvent("log",getRootElement(),username,password,gui) else outputChatBox("*INFO*: Please enter your username and password",getLocalPlayer(),255,0,0) end elseif (guiGetVisible(regGui) == true) then local username = guiGetText(user_edit1) local password = guiGetText(pass_edit1) if (username ~= "") and (password ~= "") then triggerServerEvent("reg",getRootElement(),username,password) else outputChatBox("*INFO*: Please enter a username and password",getLocalPlayer(),255,0,0) end end end addEvent("c1",true) addEventHandler("c1",getRootElement(),function() if (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) addEvent("c2",true) addEventHandler("c2",getRootElement(),function() if (guiGetVisible(regGui) == true) and (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(regGui) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted September 13, 2011 Posted September 13, 2011 Like I told you before, the key is not being binded, because onClientPlayerJoin is only triggered by other players, not the CLIENT, use onClientResourceStart instead. function finishNow() if (guiGetVisible(logGui) == true) then local username = guiGetText(user_edit) local password = guiGetText(pass_edit) if (username ~= "") and (password ~= "") then triggerServerEvent("log",getRootElement(),username,password,gui) else outputChatBox("*INFO*: Please enter your username and password",getLocalPlayer(),255,0,0) end elseif (guiGetVisible(regGui) == true) then local username = guiGetText(user_edit1) local password = guiGetText(pass_edit1) if (username ~= "") and (password ~= "") then triggerServerEvent("reg",getRootElement(),username,password) else outputChatBox("*INFO*: Please enter a username and password",getLocalPlayer(),255,0,0) end end end addEventHandler("onClientResourceStart",resourceRoot,function() bindKey("enter","down",finishNow) end) addEvent("c1",true) addEventHandler("c1",getRootElement(),function() if (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) addEvent("c2",true) addEventHandler("c2",getRootElement(),function() if (guiGetVisible(regGui) == true) and (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then unbindKey("enter","down",finishNow) destroyElement(img) destroyElement(regGui) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted September 13, 2011 Author Posted September 13, 2011 It's still not working, When I put in my username and password then press enter, nothing happens, i think it's the function for some reason. If you don't believe me, then come on to Jay Resources to try. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted September 13, 2011 Posted September 13, 2011 If you have the input enabled, then the binds won't work. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted September 13, 2011 Author Posted September 13, 2011 ok, thanks for teling me that, I'll try now My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Cadu12 Posted September 13, 2011 Posted September 13, 2011 Hmmmm.. at function 2 still working? if so, i tinhk trigger is wrong in finishNow(). triggerServerEvent("reg",getRootElement(),username,password) to triggerServerEvent("reg",getLocalPlayer(),username,password) Ingame nick: Cadu12
Jaysds1 Posted September 13, 2011 Author Posted September 13, 2011 sorry Cadu12, it's to late, Solidsnake is right, if the gui Input Enabled is on then it blocks the bind keys My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted September 13, 2011 Posted September 13, 2011 Use onClientKey instead of bindKey, this way it works with the input too. function finishNow() if (guiGetVisible(logGui) == true) then local username = guiGetText(user_edit) local password = guiGetText(pass_edit) if (username ~= "") and (password ~= "") then triggerServerEvent("log",getRootElement(),username,password,gui) else outputChatBox("*INFO*: Please enter your username and password",getLocalPlayer(),255,0,0) end elseif (guiGetVisible(regGui) == true) then local username = guiGetText(user_edit1) local password = guiGetText(pass_edit1) if (username ~= "") and (password ~= "") then triggerServerEvent("reg",getRootElement(),username,password) else outputChatBox("*INFO*: Please enter a username and password",getLocalPlayer(),255,0,0) end end end addEventHandler("onClientResourceStart",resourceRoot,function() addEventHandler("onClientKey", root, onEnterKeyPressed) end) addEvent("c1",true) addEventHandler("c1",getRootElement(),function() if (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then removeEventHandler("onClientKey", root, onEnterKeyPressed) destroyElement(img) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) addEvent("c2",true) addEventHandler("c2",getRootElement(),function() if (guiGetVisible(regGui) == true) and (guiGetVisible(logGui) == true) and (guiGetVisible(img) == true) then removeEventHandler("onClientKey", root, onEnterKeyPressed) destroyElement(img) destroyElement(regGui) destroyElement(logGui) showCursor(false) guiSetInputEnabled(false) end end) function onEnterKeyPressed(button, press) if (press and button=="enter") then finishNow() end end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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