bartje01 Posted November 7, 2010 Posted November 7, 2010 Hey guys. my gui is workign a bit now function buyweapon(playerSource, commandName) local buyweapon = guiCreateWindow ( 0.3398, 0.2333, 0.3297, 0.6500, "Weapon Shop", true ) local buyweapondeagle = guiCreateButton ( 0.2915, 0.0369, 0.4242, 0.0641, "Deagle", true ) local buyweapontec-9 = guiCreateButton ( 0.2938, 0.1058, 0.4265, 0.0609, "Tec-9", true ) guiSetVisible ( buyweapon, true ) guiSetVisible ( buyweapondeagle, true ) guiSetVisible ( buyweapontec-9, true ) end addCommandHandler("buyweapons", buyweapon) With only the guiSetVisible ( buyweapon, true ) it works But with the other two the gui won't show up anymore. Help please
Castillo Posted November 7, 2010 Posted November 7, 2010 you're doing it wrong, i recommend to read this: https://wiki.multitheftauto.com/wiki/Introduction_to_Scripting_the_GUI function buyweapon(playerSource, commandName) local buyweapon = guiCreateWindow ( 0.3398, 0.2333, 0.3297, 0.6500, "Weapon Shop", true ) local buyweapondeagle = guiCreateButton ( 0.2915, 0.0369, 0.4242, 0.0641, "Deagle", true, buyWeapon ) local buyweapontec-9 = guiCreateButton ( 0.2938, 0.1058, 0.4265, 0.0609, "Tec-9", true, buyWeapon ) guiSetVisible ( buyweapon, true ) end addCommandHandler("buyweapons", buyweapon)
Castillo Posted November 7, 2010 Posted November 7, 2010 type /debugscript 3 in-game and tell us if there are errors, if there are post them here. P.S: please use 1 topic for all the problems of same script!
bartje01 Posted November 7, 2010 Author Posted November 7, 2010 ERROR:freerpg/script/lua.133:attempt to call global 'guiCreateWindow' (a nil value)
Castillo Posted November 7, 2010 Posted November 7, 2010 you are doing the script server side not client side!
bartje01 Posted November 7, 2010 Author Posted November 7, 2010 This is my client.lua function buyweapon(playerSource, commandName) local buyweapon = guiCreateWindow ( 0.3398, 0.2333, 0.3297, 0.6500, "Weapon Shop", true ) local buyweapondeagle = guiCreateButton ( 0.2915, 0.0369, 0.4242, 0.0641, "Deagle", true, buyWeapon ) local buyweapontec-9 = guiCreateButton ( 0.2938, 0.1058, 0.4265, 0.0609, "Tec-9", true, buyWeapon ) guiSetVisible ( buyweapon, true ) end addCommandHandler("buyweapons", buyweapon)
Castillo Posted November 7, 2010 Posted November 7, 2010 there is no reason to say a nil value about guiCreateWindow..
dzek (varez) Posted November 7, 2010 Posted November 7, 2010 can you zip and upload whole resource somewhere? if u scared about it being stolen - you can send it to me via pm
Castillo Posted November 7, 2010 Posted November 7, 2010 function buyweapon(playerSource, commandName) local buyweapon = guiCreateWindow ( 0.3398, 0.2333, 0.3297, 0.6500, "Weapon Shop", true ) local buyweapondeagle = guiCreateButton ( 0.2915, 0.0369, 0.4242, 0.0641, "Deagle", true, buyWeapon ) local buyweapontec9 = guiCreateButton ( 0.2938, 0.1058, 0.4265, 0.0609, "Tec-9", true, buyWeapon ) guiSetVisible ( buyweapon, true ) end addCommandHandler("buyweapons", buyweapon) this code works fine at my server. btw: you added at buyweapontec9 you did buyweapontec-9 and that makes a unexpected simbol.
bartje01 Posted November 7, 2010 Author Posted November 7, 2010 No effect but no errors or warnings eitehr Without the buttons the menu will show up: function buyweapon(playerSource, commandName) local buyweapon = guiCreateWindow ( 0.3398, 0.2333, 0.3297, 0.6500, "Weapon Shop", true ) guiSetVisible ( buyweapon, true ) end addCommandHandler("buyweapons", buyweapon) But with the buttons nothing shows up
dzek (varez) Posted November 7, 2010 Posted November 7, 2010 rest of your script could broke something ERROR:freerpg/script/lua.133:attempt to call global 'guiCreateWindow' (a nil value) post whole script or send it via pm to me or Solid (if he doesnt have anything against pming him)
bartje01 Posted November 7, 2010 Author Posted November 7, 2010 Now why doesn't this work? I want that when you click on the weaponx button the gui dissapears. addEventHandler ("onClientGUIClick",getRootElement(), function(button) if (source == buyweaponx) then guiSetVisible (buyweapon,false) showCursor (false,false) end end) No effect.
dzek (varez) Posted November 7, 2010 Posted November 7, 2010 you have created your gui as "local" maybe instead of asking thousands question read tutorials? https://wiki.multitheftauto.com/wiki/Scr ... troduction https://wiki.multitheftauto.com/wiki/Int ... ng_the_GUI
bartje01 Posted November 7, 2010 Author Posted November 7, 2010 Ye I am really sorry that I'm asking so many questions. But that is the way I learn the best. Tutorials have a low effect on me. Now I do understand that local didn't work. With that tutorial I shouldn't know that. Thanks very much.
dzek (varez) Posted November 7, 2010 Posted November 7, 2010 local thing is one the first things tutorial is explaining. ofc only reading them won't help you to understand, but writing, following and doing modifications to examples in tutorial - will make you know everything.
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