audi868 Posted September 3, 2011 Share Posted September 3, 2011 (edited) Doesn't sets the memo text to the info, root = getRootElement() sx,sy = guiGetScreenSize() addCommandHandler("shop",function() shop = {} shop['window'] = guiCreateWindow((sx/2)-320,(sy/2)-240,640,480,"Shop",false) shop['info1'] = guiCreateMemo(0.3644,0.1812,0.4759,0.3068,"",true,shop['window']) shop['info2'] = guiCreateMemo(0.3644,0.6039,0.4759,0.3068,"",true,shop['window']) loadShop() end ) function itm1(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",1) setElementData(btn,"info",info) end function itm2(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",2) setElementData(btn,"info",info) end function loadShop() itm1(0.1714,0.1787,0.1597,0.0652,"Flip","Flip your car for $500") -- this for test end function getItemInfo() if getElementData(source,"info") then local infoindex = getElementData(source,"infoindex") local info = getElementData(source,"info") local infoMemo = "shop['info"..infoindex.."']" guiSetText(infoMemo,info) end end addEventHandler("onClientMouseEnter",root,getItemInfo) I tried to debug using outputChatBox(info) under getItemInfo works but still doesn't works for the memo Edited September 3, 2011 by Guest Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 You are using a variable as a gui-element, which won't work of course. root = getRootElement() sx,sy = guiGetScreenSize() addCommandHandler("shop",function() shop = {} shop['window'] = guiCreateWindow((sx/2)-320,(sy/2)-240,640,480,"Shop",false) shop['info1'] = guiCreateMemo(0.3644,0.1812,0.4759,0.3068,"",true,shop['window']) shop['info2'] = guiCreateMemo(0.3644,0.6039,0.4759,0.3068,"",true,shop['window']) end ) function itm1(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",1) setElementData(btn,"info",info) end function itm2(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",2) setElementData(btn,"info",info) end function loadShop() itm1(0.1714,0.1787,0.1597,0.0652,"Flip","Flip your car for $500") -- this for test end function getItemInfo() if getElementData(source,"info") then local infoindex = getElementData(source,"infoindex") local info = getElementData(source,"info") local infoMemo = "shop['info"..infoindex.."']" guiSetText(shop['info1'],info) end end addEventHandler("onClientMouseEnter",root,getItemInfo) Not sure if that's waht you wanted. Link to comment
audi868 Posted September 3, 2011 Author Share Posted September 3, 2011 guiSetText(shop['info1'],info) how should I get in which memo would the text be placed then? cuz I have two memos P/S: You are using a variable as a gui-element, which won't work of course. Where so? I mean line? Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 (edited) Ok, I get what you was trying to do now, but your problem was that you put infoMemo as a string. root = getRootElement() sx,sy = guiGetScreenSize() addCommandHandler("shop",function() shop = {} shop['window'] = guiCreateWindow((sx/2)-320,(sy/2)-240,640,480,"Shop",false) shop['info1'] = guiCreateMemo(0.3644,0.1812,0.4759,0.3068,"",true,shop['window']) shop['info2'] = guiCreateMemo(0.3644,0.6039,0.4759,0.3068,"",true,shop['window']) end ) function itm1(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",1) setElementData(btn,"info",info) end function itm2(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",2) setElementData(btn,"info",info) end function loadShop() itm1(0.1714,0.1787,0.1597,0.0652,"Flip","Flip your car for $500") -- this for test end function getItemInfo() if getElementData(source,"info") then local infoindex = getElementData(source,"infoindex") local info = getElementData(source,"info") local infoMemo = shop["info".. infoindex] guiSetText(infoMemo,info) end end addEventHandler("onClientMouseEnter",root,getItemInfo) Should do what you wanted now. Edited September 3, 2011 by Guest Link to comment
audi868 Posted September 3, 2011 Author Share Posted September 3, 2011 Still not working P/S: solved by using guiSetText(shop["info".. infoindex],info) I appreciate your help. Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 That's the same I last posted but without the variable, and my code was working, I tested it. Link to comment
50p Posted September 3, 2011 Share Posted September 3, 2011 function loadShop() itm(0.1714,0.1787,0.1597,0.0652,"Flip","Flip your car for $500") -- this for test end Tell me please where is the itm function in your code? Why didn't you get error message? Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 Oh, my bad, I didn't noticed about that . 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