kieran

Members
  • Content count

    174
  • Joined

  • Last visited

Community Reputation

17 Decent

About kieran

  • Rank
    Mark
  • Birthday August 21

Details

  • Gang
    n/a, I am a cat!
  • Location
    United Rainy Kingdom.
  • Occupation
    Newb scripter.
  • Interests
    I love GUI's and MTA, but I am lazy so don't ask for any help. (I also have a peanut brain haha)

Recent Profile Visitors

725 profile views
  1. I'm using triggerServerEvent to trigger it server side.... In fact there is a problem, it won't do anything so instead of making new topic I'm just gonna be a d**k and revive this Server Client Basically, it triggers the event, but it says it expects element at first argument of setElementModel (Don't worry about the elseif, that was me checking it to see if it registered mouse click and it did). Anyone know what I'm doing wrong? Noticed there isn't a simple easy to read skin shop script on community, so this is basically the main purpose of this script... (Later all skin names, etc will be added)
  2. I had the exact same idea @koragg, decided just to get the text, then check if it's a number, and finally.... It works! now I just gotta make the server side stuff to set skins etc... Thanks for help, and if anyone is getting error with tonumber saying ) expected near =, then try ==
  3. I made a gui for a skin shop, basically it is meant to check number from gridlist column and then use that for setElementModel, problem is that when I click it.... it gives this warning: WARNING:GUI's/clothes_c.lua:28: Bad argument @ 'setElementModel' [Expected element at argument 1, got string '1'] I also want to check players money, so I changed To But it then gave this error, ERROR: GUI's/clothes_c.lua:32: attempt to compare number with nil (Line 32 would be line 7) Thanks for any help!
  4. @MIKI785 I can assure you I copied and pasted it with 0 edits last night, my only explanation is they updated that page today... Anyway thanks, it works great now!
  5. Thank you @MIKI785... And that is straight from wiki, here is the link, look at example 2 and the code I started the topic here with... Apparently it needs changed.
  6. Here is what I thought you meant... function createPlayerList () -- Create the grid list playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Online Players", 0.85 ) if ( column ) then -- If the column has been created, fill it with players for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end end addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList ) function click ( button, state, sx, sy, x, y, z, elem, gui ) -- if state is down ( not to trigger the function twice on mouse button up/down), clicked gui and the element is our player list if ( state == "down" ) and ( source == playerList ) then -- get the player name from the selected row, first column local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) outputChatBox ( playerName ) -- output it to chat box end end It should of worked in the first place, it was taken straight from wiki...
  7. Still doesn't work @Gordon_G
  8. I noticed guiGridListGetItemText on wiki, I put it on my server and gave it a go but it doesn't really output to chat like it says it will Example 2 on wiki function createPlayerList () -- Create the grid list playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then -- If the column has been created, fill it with players for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end end addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList ) function click ( button, state, sx, sy, x, y, z, elem, gui ) -- if state is down ( not to trigger the function twice on mouse button up/down), clicked gui and the element is our player list if ( ( state == "down" ) and ( gui == true ) and ( source == playerList ) ) then -- get the player name from the selected row, first column local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) outputChatBox ( playerName ) -- output it to chat box end end Basically I am trying to use this as an example to teach myself how to use a similar system, the end result I am aiming for is using functions in that simple script to create a skin shop... Once I get it to actually do something I will try that, but for now I am trying simple stuff.
  9. OMG thank you @Uknown. it woked perfectly
  10. That permanently destroys the GUI when I press F1... WARNING:GUI\help.lua:10:Bad argument @ 'destroyElement' [Expected element at argument 1] That's my debugscript 3, I am not really experienced with stuff like for i = 1, #guiElements do local theElement = guiElements[ i ] destroyElement( theElement ) All I know is it basically groups it...
  11. Okay, basically for now only way my GUI works is player logs in, it shows the GUI, then it checks visibility. The thing is I want to make it so my GUI doesn't have to come up for the script to notice an element is there.... Could I do this by simply binding a key to create gui or is it a little more complicated? Here's the current code (Yes I just kept it as is, easier than changing the original working script.) Server function HelpBinds() triggerClientEvent (source,"Help_Panel",getRootElement()) triggerClientEvent (source,"Help_Login",getRootElement()) end addEventHandler("onPlayerLogin", root, HelpBinds) Client local screenW, screenH = guiGetScreenSize() function ShowHelp() guiSetInputEnabled(false) showCursor(true) helpWindow = guiCreateWindow((screenW - 591) / 2, (screenH - 534) / 2, 591, 534, "Information", false) guiWindowSetSizable(helpWindow, false) guiSetAlpha(helpWindow, 0.92) guiSetProperty(helpWindow, "CaptionColour", "FFD7E21C") CloseInfo = guiCreateLabel(230, 499, 196, 35, "F1 to close window", false, helpWindow) guiSetProperty(CloseInfo, "NormalTextColour", "FFFE0000") helphelpTabsPan = guiCreateTabPanel(9, 28, 572, 461, false, helpWindow) helpTabs = guiCreateTab("Tab1", helphelpTabsPan) memo = guiCreateMemo(6, 32, 561, 399, "Line 1. \n\nLine 2.", false, helpTabs) label = guiCreateLabel(13, 10, 544, 26, "Label", false, helpTabs) guiLabelSetColor(label, 255, 100, 25) helpTabs2 = guiCreateTab("Tab2", helphelpTabsPan) memo2 = guiCreateMemo(5, 32, 561, 399, "Line 1 \n/Line 2", false, helpTabs2) label2 = guiCreateLabel(15, 10, 544, 26, "Label", false, helpTabs2) guiLabelSetColor(label2, 255, 100, 25) helpTabs3 = guiCreateTab("Tab3", helphelpTabsPan) memo3 = guiCreateMemo(5, 32, 561, 399, "Line 1.\nLine2.", false, helpTabs3) end addEvent("Help_Login", true) addEventHandler("Help_Login", getRootElement(), ShowHelp) function DestroyGUI() if ( guiGetVisible ( helpWindow ) == false ) then guiSetVisible ( helpWindow, true ) showCursor(true) else guiSetVisible ( helpWindow, false ) showCursor(false) end end function binds() bindKey("f1", "down", DestroyGUI) end addEvent("Help_Panel", true) addEventHandler("Help_Panel", getRootElement(), binds) This works perfect, no problems in the code. But if you test this and remove the event "Help_Login" you will see my issue... It doesn't think a GUI is there, how can you keep a GUI closed for user but still bind it's window to a key?
  12. Thanks @kikos500..... But I wanted it so you didn't have to show GUI to get it visible I'll figure it out haha
  13. Omg I feel so stupid 😂 I was thinking I needed to make event on it but wasn't too sure, thanks! I done it that way because I used GUI editor, it is easier for me as I can just check top to see if I made typos etc. Also buttons tab is so I my list buttons as I have various binds, I was just struggling to bind GUI's, this is the second one I done, so still learning. Sorry for quoting, on tablet and it doesn't like mentions
  14. @kikos500 Nope, doesn't work.... Also the GUI was perfectly fine..... I was just wanting to bind a key to the function when player logged in and then check if the gui was visible, close it, else I wanted to open it.....
  15. I made a simple gui for information etc, trying to bind the F1 key to the gui... Worked fine when I just tried onClientResourceStart and done nothing with key binds, but no debug errors, so I can't see where I gone wrong. helpTabs = {} helphelpTabsPan = {} helpLabel = {} helpButton = {} helpWindow = {} helpMemo = {} --helpState is false. helpState = false function ShowHelp(key, keyState) --Checking if "helpState" is true. if ( keyState == "down" ) and helpState == true then guiSetVisible(helpWindow, false) destroyElement(helpWindow) helpWindow = nil showCursor(false) else if helpState == false then guiSetInputEnabled(false) showCursor(true) --Random GUI crap. local screenW, screenH = guiGetScreenSize() helpWindow = guiCreateWindow((screenW - 591) / 2, (screenH - 534) / 2, 591, 534, "Information", false) guiWindowSetSizable(helpWindow, false) guiSetAlpha(helpWindow, 0.92) guiSetProperty(helpWindow, "CaptionColour", "FFD7E21C") helpButton = guiCreateButton(485, 489, 96, 35, "Close", false, helpWindow) guiSetProperty(helpButton, "NormalTextColour", "FFFE0000") helphelpTabsPan = guiCreateTabPanel(9, 28, 572, 461, false, helpWindow) helpTabs = guiCreateTab("Rules", helphelpTabsPan) memo = guiCreateMemo(6, 32, 561, 399, "Text goes here.", false, helpTabs) label = guiCreateLabel(13, 10, 544, 26, "Label text goes here.", false, helpTabs) guiLabelSetColor(label, 255, 100, 25) helpTabs2 = guiCreateTab("Commands", helphelpTabsPan) memo2 = guiCreateMemo(5, 32, 561, 399, "Text goes here.", false, helpTabs2) label2 = guiCreateLabel(15, 10, 544, 26, "Label text goes here.", false, helpTabs2) guiLabelSetColor(label2, 255, 100, 25) helpTabs3 = guiCreateTab("Buttons", helphelpTabsPan) memo3 = guiCreateMemo(5, 32, 561, 399, "Text goes here.", false, helpTabs3) helpState = true addEventHandler("onClientGUIClick", helpButton,onClickCloseBut) end end end --This closes it, but am I setting "helpState" correctly? function onClickCloseBut(button,state) if(button == "left" and state == "up") then if (source == helpButton) then guiSetVisible(helpWindow, false) destroyElement(helpWindow) helpWindow = nil showCursor(false) helpState = false end end end --KEY BIND. function bindTheKeys () bindKey ( "F1", "down", ShowHelp ) end addEventHandler("onClientPlayerJoin", getRootElement(), bindTheKeys ) Basically this is a lot to read, so top part before guiGetScreenSize and after the GUI stuff is probably where the problem is.... It is obvious but I have never tried binding keys to client before. Thanks for help!