Michael# Posted May 12, 2012 Share Posted May 12, 2012 Answering your first question, you can use onClientRender event and slide the GUI setting up GUI position every frame or you can use interpolateBetween function and onClientRender event. Link to comment
Puma Posted May 12, 2012 Share Posted May 12, 2012 If you use 'onClientRender', like Michael says, it makes the animation a LOT smoother (and nicer) than with a setTimer. Here's an example of how to do it: windowX1, windowY1 = -200, 500 -- start position of the window (not on the screen) windowX2, windowY2 = 200, 500 -- position where window should slide to (on the screen) windowXdifference, windowYdifference = windowX2-windowX1, windowY2-windowY1 -- distance between startposition and position where the window should slide to windowW, windowH = 200, 300 -- width and height of the window slideTime = 500 -- time the slide takes window = guiCreateWindow ( windowX1, windowY1, windowW, windowH, "Your window", false ) -- create the window using the values you just set -------------------------------------------------- function slideMenuIn () renderSlide = true -- set renderSlide variable to true slideMenuInTimer = setTimer ( function() renderSlide = false end, 500, 1 ) -- set a timer that, when slide-time is passed, sets the renderSlide back to false end -- execute this function when the window should be slided in -------------------------------------------------- function render () if renderSlide and slideMenuInTimer and isTimer ( slideMenuInTimer ) then -- if renderSlide variable is true and the timer exists (timer made in slideMenuIn() ) local timeLeft, amountLeft, amount = getTimerDetails ( slideMenuInTimer ) -- timeLeft how much time is left before the timer runs out of time local slideIndex = timeLeft/slideTime -- calculate the index/fraction (part/total) local windowX = windowX1 + windowXdifference * slideIndex local windowY = windowY1 + windowYdifference * slideIndex -- calculate new x- and y-position guiSetPosition ( window, windowX, windowY, false ) -- set window position end end addEventHandler ( "onClientRender", getRootElement(), render ) -- execute function 'render' when a new frame is rendered I hope I explained it well enough. This is how I do it, it works well. I don't know of an easier way. Link to comment
FWCentral Posted May 12, 2012 Author Share Posted May 12, 2012 Thanks i don't need to know about the guiSetPosition anymore thanks though, Does anyone know how to stop adding something to a gridlist if a row with the same name already exists there? Link to comment
CapY Posted May 12, 2012 Share Posted May 12, 2012 If you use 'onClientRender', like Michael says, it makes the animation a LOT smoother (and nicer) than with a setTimer.Here's an example of how to do it: windowX1, windowY1 = -200, 500 -- start position of the window (not on the screen) windowX2, windowY2 = 200, 500 -- position where window should slide to (on the screen) windowXdifference, windowYdifference = windowX2-windowX1, windowY2-windowY1 -- distance between startposition and position where the window should slide to windowW, windowH = 200, 300 -- width and height of the window slideTime = 500 -- time the slide takes window = guiCreateWindow ( windowX1, windowY1, windowW, windowH, "Your window", false ) -- create the window using the values you just set -------------------------------------------------- function slideMenuIn () renderSlide = true -- set renderSlide variable to true slideMenuInTimer = setTimer ( function() renderSlide = false end, 500, 1 ) -- set a timer that, when slide-time is passed, sets the renderSlide back to false end -- execute this function when the window should be slided in -------------------------------------------------- function render () if renderSlide and slideMenuInTimer and isTimer ( slideMenuInTimer ) then -- if renderSlide variable is true and the timer exists (timer made in slideMenuIn() ) local timeLeft, amountLeft, amount = getTimerDetails ( slideMenuInTimer ) -- timeLeft how much time is left before the timer runs out of time local slideIndex = timeLeft/slideTime -- calculate the index/fraction (part/total) local windowX = windowX1 + windowXdifference * slideIndex local windowY = windowY1 + windowYdifference * slideIndex -- calculate new x- and y-position guiSetPosition ( window, windowX, windowY, false ) -- set window position end end addEventHandler ( "onClientRender", getRootElement(), render ) -- execute function 'render' when a new frame is rendered I hope I explained it well enough. This is how I do it, it works well. I don't know of an easier way. Client_anim contains it all, use it. Link to comment
Michael# Posted May 13, 2012 Share Posted May 13, 2012 arc_ animation library have a lot of bugs. Link to comment
FWCentral Posted May 13, 2012 Author Share Posted May 13, 2012 Guys i don‘t need to know about the animation i need to know how to check if there is already a row in the gridlist with the same text in column 1. Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 for i=0, guiGridListGetRowCount(GRIDLIST)do if(guiGridListGetItemText(GRIDLIST,i,1)==THE STRING TO CHECK)then guiGridListRemoveRow(GRIDLIST,i) end end Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 Still doesn't work function updateLocations ( location ) for i=0, guiGridListGetRowCount(locationsList)do if(guiGridListGetItemText(locationsList,i,1)==location)then guiGridListRemoveRow(locationsList,i) local row2 = guiGridListAddRow ( locationsList ) guiGridListSetItemText ( locationsList, row2, 1, location, false, false ) elseif(guiGridListGetItemText(locationsList,i,1)~=location)then local row2 = guiGridListAddRow ( locationsList ) guiGridListSetItemText ( locationsList, row2, 1, location, false, false ) end end end Now it shows it like this; cheese LS LS dwd dwd dwd But there is only one dwd in the DB and 2 LS and one Cheese, But i want it to only show one LS one Cheese and one dwd, For some reason it doesn't and i don't have a clue why its showing 3 dwd's Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 You've added a row even when it's the same text, try this: function updateLocations ( location ) for i=0, guiGridListGetRowCount(locationsList)do if(guiGridListGetItemText(locationsList,i,1)==location)then guiGridListRemoveRow(locationsList,i) elseif(guiGridListGetItemText(locationsList,i,1)~=location)then local row2 = guiGridListAddRow ( locationsList ) guiGridListSetItemText ( locationsList, row2, 1, location, false, false ) end end end Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 Now it only shows one row and none of the others i did already try that mate Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 lol, sorry, When is this script being triggered? Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 When the GUI is created it triggers a server event that returns the locations to that function, The server side all works fine. Then the gui will be destroyed later when its closed, Only reason for this is because i want to keep the GUI up to date each time a player spawns if there is a new location added to the GUI it will show or is there an easier way to do that? Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 Well, I think this would be a good idea then, but it's not as easy as it looks Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 But how hard is it to see if there is already a row with the same name? I wouldn't think it will be the code looks fine i just can't get my head around it Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 wait, so the server sends a table to this function, am I right? Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 No it sends it one by one from a table mate Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 try this: function updateLocations ( location ) for i=0, guiGridListGetRowCount(locationsList)do -- loop through the gridlist if(location~=guiGridListGetItemText(locationsList,i,1))then --if the location name is not inside the gridlist then guiGridListSetItemText ( locationsList, guiGridListAddRow ( locationsList ), 1, location, false, false ) -- add a row and set it by the location name end end end Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 Now it shows it like this; LS cheese LS dwd dwd dwd But there is only one dwd in the DB and 2 LS and one Cheese Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 lol, I thought it would work this time I'll keep thinking Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 (edited) Haha i can't see why it wouldn't its pretty annoying though and ok thanks man function updateLocations ( location ) for i=0, guiGridListGetRowCount(locationsList)do -- loop through the gridlist if(location~=guiGridListGetItemText(locationsList,i,1))then --if the location name is not inside the gridlist then guiGridListSetItemText ( locationsList, guiGridListAddRow ( locationsList ), 1, location, false, false ) -- add a row and set it by the location name outputChatBox("Type: "..type(location).." added : "..location) elseif(location==guiGridListGetItemText(locationsList,i,1))then outputChatBox("Type: "..type(location).." removed : "..location) end end end Using it like this outputs like; Type: string added : LS Type: string added : Cheese Type: string removed : Cheese Type: string removed : LS Type: string added : LS Type: string removed : LS Type: string added : dwd Type: string added : dwd Type: string added : dwd Type: string removed : dwd Edited May 14, 2012 by Guest Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 np, I'll post back or edit this post when I have an idea This is annoying, it looks so easy but complex Link to comment
Guest Guest4401 Posted May 14, 2012 Share Posted May 14, 2012 Dunno if this will be useful or not: function isTextInGridList(gridlist,column,text) if gridlist and column and text then local rows = (guiGridListGetRowCount(gridlist) or 1) for row = 0,rows do if text == guiGridListGetItemText(gridlist, row, column) then return true end end return false end return false end Usage: isTextInGridList(locationsList, 1, "myText") -- returns true if text was found otherwise false Link to comment
FWCentral Posted May 14, 2012 Author Share Posted May 14, 2012 You fucking legend, Thanks Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 nice, that looks better than my scripts, this should work 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