Kenix Posted April 6, 2011 Author Posted April 6, 2011 With: function getSkillFunc(player,Levelids) if ( Levelids ) then local skillsID = tonumber( Levelids ) triggerClientEvent(player, "selectSkill", getRootElement() ,skillsID) return true else return false end end And this: addEvent("selectSkill",true) addEventHandler( "selectSkill", getRootElement(), function(skillsID) if (tonumber(skillsID)) then guiGridListSetItemText(GUIEditor_Grid[211],tonumber(skillsID),5,"purchased",false,false) guiGridListSetItemColor (GUIEditor_Grid[211],tonumber(skillsID),5,0,255,0) outputChatBox("text change "..tonumber(skillsID)) end end ) it works perfectly, take a look at this screenshot. http://img855.imageshack.us/i/mtascreen ... 82115.png/ THX MAN !!!! http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Kenix Posted April 6, 2011 Author Posted April 6, 2011 I have a new question:) Added: Damn I have not done something when you buy the window closes because it is not clear whether or not I bought a GUI and I have not seen appearing a text in gridList sorry guys, I sometimes stupid ... days were difficult after closing it all disappears(something that was added to the text), I made a script: addEvent("selectSkill",true) addEventHandler( "selectSkill", getRootElement(), function(skillsID) if (tonumber(skillsID)) then guiGridListSetItemText(MainGrid,tonumber(skillsID),5,"purchased",false,false) guiGridListSetItemColor (MainGrid,tonumber(skillsID),5,0,255,0) local datasSk = setElementData(getLocalPlayer(),"SkillBuy",skillsID) outputChatBox("set data skill "..tostring(skillsID).." , "..tostring(datasSk)) outputChatBox("text change "..tonumber(skillsID)) end end ) he says set data skill 0 , false function startShowingShopLevelMenu() showCursor(true) GUIEditor_Window = {} GUIEditor_Grid = {} MainWindowLevel = guiCreateWindow(0.2234,0.0586,0.5969,0.9102,"New Skills Shop",true) MainButton = guiCreateButton(0.1289,0.9418,0.6974,0.0370,"Buy Skill",true,MainWindowLevel) MainGrid = guiCreateGridList(0.0419,0.0354,0.9058,0.8970,true,MainWindowLevel) guiGridListSetSelectionMode(MainGrid,1) guiGridListAddColumn(MainGrid,"ID",0.2) guiGridListAddColumn(MainGrid,"Name",0.2) guiGridListAddColumn(MainGrid,"$",0.2) guiGridListAddColumn(MainGrid,"Level",0.2) guiGridListAddColumn(MainGrid,"Status",0.2) if ( skillsID ) then if getElementData(getLocalPlayer(),"SkillBuy") == tonumber(skillsID) then outputChatBox("get element data") local textAddSkill = guiGridListSetItemText(MainGrid,tonumber(skillsID),5,"purchased",false,false) local textAddSkill2 = guiGridListSetItemColor (MainGrid,tonumber(skillsID),5,0,255,0) outputChatBox("text add "..tostring(textAddSkill).." , "..tostring(textAddSkill2)) end end addEventHandler ("onClientGUIClick", MainButton, onClientPlayerSkillBuy) for i,v in ipairs (skillsLevelsTable) do local row21 = guiGridListAddRow (MainGrid) guiGridListSetItemText (MainGrid, row21, 1, v[1], false, true) guiGridListSetItemText (MainGrid, row21, 2, v[2], false, true) guiGridListSetItemText (MainGrid, row21, 3, v[3], false, true) guiGridListSetItemText (MainGrid, row21, 4, v[4], false, true) guiGridListSetItemText (MainGrid, row21, 5, v[5], false, true) guiGridListSetItemText (MainGrid, row21, 6, v[6], false, true) end end http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 6, 2011 Moderators Posted April 6, 2011 I really don't know but maybe try this: addEvent("selectSkill",true) addEventHandler( "selectSkill", getLocalPlayer(), function(skillsID) if (tonumber(skillsID)) then guiGridListSetItemText(MainGrid,tonumber(skillsID),5,"purchased",false,false) guiGridListSetItemColor (MainGrid,tonumber(skillsID),5,0,255,0) local datasSk = setElementData(getLocalPlayer(),"SkillBuy",skillsID) outputChatBox("set data skill "..tostring(skillsID).." , "..tostring(datasSk)) outputChatBox("text change "..tonumber(skillsID)) end end ) The rEvolution is coming ...
Kenix Posted April 7, 2011 Author Posted April 7, 2011 is not set Text in gridList http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Castillo Posted April 7, 2011 Posted April 7, 2011 Hi volk, could you please explain what do you want to do? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Kenix Posted April 7, 2011 Author Posted April 7, 2011 (edited) Hi volk, could you please explain what do you want to do? Hi man see when you close it then it disappears from gridList and I want to do after buying it persisted gridList (get/set ElementData) Edit: before (open and buy) after(close and open) Edited April 7, 2011 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Castillo Posted April 7, 2011 Posted April 7, 2011 make a table and then load from it? btw, why do you clean the grid list every time? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Kenix Posted April 7, 2011 Author Posted April 7, 2011 make a table and then load from it?btw, why do you clean the grid list every time? I have no line in the script to clean it at the expense of the tables I do not know, I just want to do what you are buying the ability and it is stored in gridList. maybe something I can not do. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 7, 2011 Moderators Posted April 7, 2011 Solidsnake ( and me ) think that you create the gui every times ( when you want to show it ) So just use this function 1 time ( startShowingShopLevelMenu ) Then use guiSetVisible( MainWindowLevel , true ) to show it again. The rEvolution is coming ...
Kenix Posted April 8, 2011 Author Posted April 8, 2011 Solidsnake ( and me ) think that you create the gui every times ( when you want to show it )So just use this function 1 time ( startShowingShopLevelMenu ) Then use guiSetVisible( MainWindowLevel , true ) to show it again. try this? addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) startShowingShopLevelMenu() elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end) end) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
proracer Posted April 8, 2011 Posted April 8, 2011 You can use setAccountData and setElementData to save it and then when he joins again use getAccountData with setElementData.
Kenix Posted April 8, 2011 Author Posted April 8, 2011 You can use setAccountData and setElementData to save it and then when he joins again use getAccountData with setElementData. I know it but because the text still does not appear even if I use set/get elementdata and on set/getAcountData it will be realized when it is completed and I am 100% sure that the text does not appear because it is not right if ( skillsID ) then if getElementData(getLocalPlayer(),"SkillBuy") == tonumber(skillsID) then outputChatBox("get element data") local textAddSkill = guiGridListSetItemText(MainGrid,tonumber(skillsID),5,"purchased",false,false) local textAddSkill2 = guiGridListSetItemColor (MainGrid,tonumber(skillsID),5,0,255,0) outputChatBox("text add "..tostring(textAddSkill).." , "..tostring(textAddSkill2)) end end http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 9, 2011 Moderators Posted April 9, 2011 Solidsnake ( and me ) think that you create the gui every times ( when you want to show it )So just use this function 1 time ( startShowingShopLevelMenu ) Then use guiSetVisible( MainWindowLevel , true ) to show it again. try this? addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) startShowingShopLevelMenu() elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end) end) No because you create again the gui when you want to show it. Create this gui when the player join, then you will only use guiSetVisible: addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() startShowingShopLevelMenu() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end ) end) Ok ? The rEvolution is coming ...
Kenix Posted April 9, 2011 Author Posted April 9, 2011 Solidsnake ( and me ) think that you create the gui every times ( when you want to show it )So just use this function 1 time ( startShowingShopLevelMenu ) Then use guiSetVisible( MainWindowLevel , true ) to show it again. try this? addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) startShowingShopLevelMenu() elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end) end) No because you create again the gui when you want to show it. Create this gui when the player join, then you will only use guiSetVisible: addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() startShowingShopLevelMenu() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end ) end) Ok ? so now the text is saved but I would like to see the text appearing on the button and not when join to the server. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 9, 2011 Moderators Posted April 9, 2011 function startShowingShopLevelMenu() -- blablabla guiSetVisible(MainWindowLevel, false ) end The rEvolution is coming ...
Kenix Posted April 10, 2011 Author Posted April 10, 2011 not work http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 10, 2011 Moderators Posted April 10, 2011 Show me your startShowingShopLevelMenu function please The rEvolution is coming ...
Kenix Posted April 10, 2011 Author Posted April 10, 2011 (edited) function startShowingShopLevelMenu() showCursor(true) MainWindowLevel = guiCreateWindow(0.2234,0.0586,0.5969,0.9102,"New Skills Shop",true) MainButton = guiCreateButton(0.1289,0.9418,0.6974,0.0370,"Buy Skill",true,MainWindowLevel) MainGrid = guiCreateGridList(0.0419,0.0354,0.9058,0.8970,true,MainWindowLevel) guiGridListSetSelectionMode(MainGrid,1) guiGridListAddColumn(MainGrid,"ID",0.2) guiGridListAddColumn(MainGrid,"Name",0.2) guiGridListAddColumn(MainGrid,"$",0.2) guiGridListAddColumn(MainGrid,"Level",0.2) guiGridListAddColumn(MainGrid,"Status",0.2) if ( skillsID ) then if getElementData(getLocalPlayer(),"SkillBuy") == tonumber(skillsID) then outputChatBox("get element data") local textAddSkill = guiGridListSetItemText(MainGrid,tonumber(skillsID),5,"purchased",false,false) local textAddSkill2 = guiGridListSetItemColor (MainGrid,tonumber(skillsID),5,0,255,0) outputChatBox("text add "..tostring(textAddSkill).." , "..tostring(textAddSkill2)) end end guiSetVisible(MainWindowLevel, false ) addEventHandler ("onClientGUIClick", MainButton, onClientPlayerSkillBuy) for i,v in ipairs (skillsLevelsTable) do local row21 = guiGridListAddRow (MainGrid) guiGridListSetItemText (MainGrid, row21, 1, v[1], false, true) guiGridListSetItemText (MainGrid, row21, 2, v[2], false, true) guiGridListSetItemText (MainGrid, row21, 3, v[3], false, true) guiGridListSetItemText (MainGrid, row21, 4, v[4], false, true) guiGridListSetItemText (MainGrid, row21, 5, v[5], false, true) guiGridListSetItemText (MainGrid, row21, 6, v[6], false, true) end end Edited April 10, 2011 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 10, 2011 Moderators Posted April 10, 2011 I was sure of it ! You didn't make this: function startShowingShopLevelMenu() -- blablabla guiSetVisible(MainWindowLevel, false ) end So this is the code with the setElementVisible at the end like I said function startShowingShopLevelMenu() showCursor(true) GUIEditor_Window = {} GUIEditor_Grid = {} MainWindowLevel = guiCreateWindow(0.2234,0.0586,0.5969,0.9102,"New Skills Shop",true) MainButton = guiCreateButton(0.1289,0.9418,0.6974,0.0370,"Buy Skill",true,MainWindowLevel) MainGrid = guiCreateGridList(0.0419,0.0354,0.9058,0.8970,true,MainWindowLevel) guiGridListSetSelectionMode(MainGrid,1) guiGridListAddColumn(MainGrid,"ID",0.2) guiGridListAddColumn(MainGrid,"Name",0.2) guiGridListAddColumn(MainGrid,"$",0.2) guiGridListAddColumn(MainGrid,"Level",0.2) guiGridListAddColumn(MainGrid,"Status",0.2) if ( skillsID ) then if getElementData(getLocalPlayer(),"SkillBuy") == tonumber(skillsID) then outputChatBox("get element data") local textAddSkill = guiGridListSetItemText(MainGrid,tonumber(skillsID),5,"purchased",false,false) local textAddSkill2 = guiGridListSetItemColor (MainGrid,tonumber(skillsID),5,0,255,0) outputChatBox("text add "..tostring(textAddSkill).." , "..tostring(textAddSkill2)) end end guiSetVisible(MainWindowLevel, false ) addEventHandler ("onClientGUIClick", MainButton, onClientPlayerSkillBuy) for i,v in ipairs (skillsLevelsTable) do local row21 = guiGridListAddRow (MainGrid) guiGridListSetItemText (MainGrid, row21, 1, v[1], false, true) guiGridListSetItemText (MainGrid, row21, 2, v[2], false, true) guiGridListSetItemText (MainGrid, row21, 3, v[3], false, true) guiGridListSetItemText (MainGrid, row21, 4, v[4], false, true) guiGridListSetItemText (MainGrid, row21, 5, v[5], false, true) guiGridListSetItemText (MainGrid, row21, 6, v[6], false, true) end guiSetVisible( MainWindowLevel , false ) end The rEvolution is coming ...
Kenix Posted April 10, 2011 Author Posted April 10, 2011 not open He could not open if guiSetVisible (MainWindowLevel, true) instead of the function() I do not know what to do help local getVS = guiGetVisible(MainWindowLevel) addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) showCursor(true) outputChatBox("open "..tostring(getVS)) -- Write open false Wtf elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) outputChatBox("close") end end) end) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 10, 2011 Moderators Posted April 10, 2011 You doesn't help me because when I give you a code, you don't keep it addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() startShowingShopLevelMenu() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end ) end) And this time keep all codes if you are another problem The rEvolution is coming ...
Kenix Posted April 10, 2011 Author Posted April 10, 2011 You doesn't help me because when I give you a code, you don't keep it addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() startShowingShopLevelMenu() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end ) end) And this time keep all codes if you are another problem this code works I wrote to you earlier but I want to do that at the start of the resource does not display but only after bind F2 http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators Citizen Posted April 10, 2011 Moderators Posted April 10, 2011 I KNOW !!! This !!! addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() startShowingShopLevelMenu() bindKey ( "F2", "down", function( ) if (guiGetVisible(MainWindowLevel) == false) then guiSetVisible(MainWindowLevel,true) elseif (guiGetVisible(MainWindowLevel) == true) then guiSetVisible(MainWindowLevel,false) showCursor(false) end end ) end) AND THIS ! function startShowingShopLevelMenu() showCursor(true) GUIEditor_Window = {} GUIEditor_Grid = {} MainWindowLevel = guiCreateWindow(0.2234,0.0586,0.5969,0.9102,"New Skills Shop",true) MainButton = guiCreateButton(0.1289,0.9418,0.6974,0.0370,"Buy Skill",true,MainWindowLevel) MainGrid = guiCreateGridList(0.0419,0.0354,0.9058,0.8970,true,MainWindowLevel) guiGridListSetSelectionMode(MainGrid,1) guiGridListAddColumn(MainGrid,"ID",0.2) guiGridListAddColumn(MainGrid,"Name",0.2) guiGridListAddColumn(MainGrid,"$",0.2) guiGridListAddColumn(MainGrid,"Level",0.2) guiGridListAddColumn(MainGrid,"Status",0.2) if ( skillsID ) then if getElementData(getLocalPlayer(),"SkillBuy") == tonumber(skillsID) then outputChatBox("get element data") local textAddSkill = guiGridListSetItemText(MainGrid,tonumber(skillsID),5,"purchased",false,false) local textAddSkill2 = guiGridListSetItemColor (MainGrid,tonumber(skillsID),5,0,255,0) outputChatBox("text add "..tostring(textAddSkill).." , "..tostring(textAddSkill2)) end end guiSetVisible(MainWindowLevel, false ) addEventHandler ("onClientGUIClick", MainButton, onClientPlayerSkillBuy) for i,v in ipairs (skillsLevelsTable) do local row21 = guiGridListAddRow (MainGrid) guiGridListSetItemText (MainGrid, row21, 1, v[1], false, true) guiGridListSetItemText (MainGrid, row21, 2, v[2], false, true) guiGridListSetItemText (MainGrid, row21, 3, v[3], false, true) guiGridListSetItemText (MainGrid, row21, 4, v[4], false, true) guiGridListSetItemText (MainGrid, row21, 5, v[5], false, true) guiGridListSetItemText (MainGrid, row21, 6, v[6], false, true) end guiSetVisible( MainWindowLevel , false ) end Sorry for SHIFT but I already answered to your question 2 times. This code create the gui and hide it at the start and then just use F2 The rEvolution is coming ...
AGENT_STEELMEAT Posted April 11, 2011 Posted April 11, 2011 It's better to destroy the GUI when not in use, rather than show/hide it constantly. Just sayin'
Castillo Posted April 11, 2011 Posted April 11, 2011 John_Michael, please read the post(s) again, the show/hide function is done to don't have to re-make the GUI, since he will lose any changes done to the grid-list. 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