Taalasmaa Posted June 2, 2009 Share Posted June 2, 2009 Hello! I maked vehice shop for my server, but how can I spawn them? Help? I mean how can you make "panel" for example you push "r" and you get list for your vehicles and you can also spawn them.. Help? Thanks if somebody can help with this Link to comment
50p Posted June 2, 2009 Share Posted June 2, 2009 Check these: - createVehicle (creates vehicle, in other words spawns) - GUI Classes (makes scripting GUI easier) - bindKey (binds keys, so that you can show the GUI with keys, e.g. "r") Link to comment
Taalasmaa Posted June 3, 2009 Author Share Posted June 3, 2009 Any clearly? Because there was only how to create vehcile... So how can I make this: You go buy vehicle from my vehicle shop and when you bought vehicle and push "r" there is your vehicle which you did buy and you can spawn it with clicking "spawn" Link to comment
50p Posted June 3, 2009 Share Posted June 3, 2009 (edited) What wasn't clear enough? What didn't I tell you? I've sent you to: - GUI lib which allows you to create GUI elements (Buttons, Windows, etc.) and this is what you need to show the window and button (for instance "Spawn"). -- inside of client-side script (in onClientResourceStart) wnd = Window:Create( 10, 250, 200, 100, "Spawn window" ); btn = wnd:AddButton( 15, 40, 100, 23, "SPAWN" ); btn:AddOnClick( function() -- when button is clicked, tell server about it triggerServerEvent( "YOUR_EVENT_TO_SPAWN_CAR", getLocalPlayer(), 560 ) -- 560 is id of car end) wnd:Visible( false )-- hide the window - createVehicle function which will create vehicle ("Spawn") -- inside of server-side script addEvent( "YOUR_EVENT_TO_SPAWN_CAR", true ) addEventHandler( "YOUR_EVENT_TO_SPAWN_CAR", getRootElement( ), function( ID ) -- ID will be the one you put in client script (eg. 560 - "Sultan") x, y, z = getElementPosition( client ) -- client = player who triggered this event createVehicle( ID, x, y+3, z ); -- create vehicle by player end) - bindKey which will bind a key ("r") to a function which will show the Window. -- inside of client side script (just under wnd:Show( false )) bindKey( "r", "down", function( ) -- this will show window if it's hidden and hide if it's shown wnd:Visible( not wnd:Visible( ) ) end ) THIS IS JUST EXAMPLE I TYPED HERE! IT MAY NOT WORK! IT JUST GIVES YOU AN IDEA HOW IT CAN BE DONE! If you still need to know more just look at the wiki examples/tutorials. http://development.mtasa.com/index.php? ... troduction http://development.mtasa.com/index.php? ... ng_the_GUI Edited June 4, 2009 by Guest Link to comment
Taalasmaa Posted June 4, 2009 Author Share Posted June 4, 2009 I tested your script and it didnt worked.. I tried edit and I tried ALL, but it didnt work.. It gave error.. "attempt to call global 'create' " whats wrong? I TRIED EVERYTHING, maybe you can help.. Its true that I tried to get it work about 3hours... Its awesome if you can help with this. Link to comment
50p Posted June 4, 2009 Share Posted June 4, 2009 - How did you test it? - Where did you put the code? - How does your resource look (empty? added my code to some other resource?)? - Any other errors? - What do you mean everything? Everything you know about but not what you must do. If you wanted to use the code I posted about the GUI then you need my GUI classes as I said before. Link to comment
Gamesnert Posted June 4, 2009 Share Posted June 4, 2009 wnd = Create:Window( 10, 250, 200, 100, "Spawn window" ); Should be... wnd = Window:Create( 10, 250, 200, 100, "Spawn window" ); ... according to the documentation on the GUI Classes wiki page. Link to comment
50p Posted June 4, 2009 Share Posted June 4, 2009 wnd = Create:Window( 10, 250, 200, 100, "Spawn window" ); Should be... wnd = Window:Create( 10, 250, 200, 100, "Spawn window" ); ... according to the documentation on the GUI Classes wiki page. That's right! 50p has to read his own documentation! LOL Even though, I'm pretty sure Talasma ignored the advices and just copied the code like most of beginners would do. Link to comment
Taalasmaa Posted June 4, 2009 Author Share Posted June 4, 2009 It didnt work either. It gave same error I maked "spawner" winzip archive to resources and putted there "spawner.client.lua and spawner.serv.lua and meta.xml" And started server and tried type "start spawner" and it gave this error: "attempt to call global 'window' " hey, whats wrong? I putted these: spawner.client.lua -- inside of client-side script (in onClientResourceStart) wnd = Window:Create( 10, 250, 200, 100, "Spawn window" ); btn = wnd:AddButton( 15, 40, 100, 23, "SPAWN" ); btn:AddOnClick( function() -- when button is clicked, tell server about it triggerServerEvent( "YOUR_EVENT_TO_SPAWN_CAR", getLocalPlayer(), 560 ) -- 560 is id of car end) wnd:Visible( false )-- hide the window spawner.serv.lua -- inside of client side script (just under wnd:Show( false )) bindKey( "r", "down", function( ) -- this will show window if it's hidden and hide if it's shown wnd:Visible( not wnd:Visible( ) ) end ) -- inside of server-side script addEvent( "YOUR_EVENT_TO_SPAWN_CAR", true ) addEventHandler( "YOUR_EVENT_TO_SPAWN_CAR", getRootElement( ), function( ID ) -- ID will be the one you put in client script (eg. 560 - "Sultan") x, y, z = getElementPosition( client ) -- client = player who triggered this event createVehicle( ID, x, y+3, z ); -- create vehicle by player end) and in meta.xml was authors and infos etc... What is going wrong? Link to comment
Gamesnert Posted June 4, 2009 Share Posted June 4, 2009 If it doesn't recognize Window, then you haven't installed GUI classes script correctly. 1. Get one of the 2 links linking to the GUI classes community page 2. Download it 3. Open the zip and extract "classes" folder into your resource 4. Add these lines to the meta.xml for your resource: <script src="classes/GUICollection.lua" type="client" /> <script src="classes/button_class.lua" type="client" /> <script src="classes/checkbox_class.lua" type="client" /> <script src="classes/gridlist_class.lua" type="client" /> <script src="classes/label_class.lua" type="client" /> <script src="classes/memo_class.lua" type="client" /> <script src="classes/progressbar_class.lua" type="client" /> <script src="classes/radiobutton_class.lua" type="client" /> <script src="classes/scrollbar_class.lua" type="client" /> <script src="classes/staticimage_class.lua" type="client" /> <script src="classes/textbox_class.lua" type="client" /> <script src="classes/tabpanel_class.lua" type="client" /> <script src="classes/tab_class.lua" type="client" /> <script src="classes/window_class.lua" type="client" /> 5. Save the meta.xml, restart the resource on the server or start the server. It should work correctly now. Link to comment
Taalasmaa Posted June 4, 2009 Author Share Posted June 4, 2009 Okay did it.. But now is another problem: I started it in console and it worked, but when you are ingame there is "cursor" and you cant do nothing just stay and when you push "r" nothing isnt happening.. When you shut down script cursor is gone and you can play and move.. What is again wrong??? Link to comment
50p Posted June 4, 2009 Share Posted June 4, 2009 In the example I showed you there is nothing linked to cursor but check file "classes/GUICollection.lua" line 23. I used showCursor( true ) to test some things but I may have forgotten to comment this line before release. BTW, post all the content you have in your .lua files. Ech file in [ lua][ /lua] (without spaces) tags. Link to comment
Taalasmaa Posted June 4, 2009 Author Share Posted June 4, 2009 Do I edit [ lua] [/lua ]'s to classes files too? or only spawner files ? Link to comment
50p Posted June 4, 2009 Share Posted June 4, 2009 Use [ lua][ /lua] tags on the forums, here. If you post code on forums it's easier to read when your code is in between the lua tag, so use [ lua]YOUR CODE HERE[ /lua] (WITHOUT SPACES!!) to see this: YOUR CODE HERE Also, I just updated GUI classes resource, so go and download new version (1.0.1): https://community.multitheftauto.com/index.html?p ... ils&id=241 Just download it and replace your old file ("classes/GUICollection.lua") with the new one you download. Link to comment
Taalasmaa Posted June 4, 2009 Author Share Posted June 4, 2009 (edited) okay! there is file. This first file is spawner.client.lua -- inside of client-side script (in onClientResourceStart) wnd = Window:Create( 10, 250, 200, 100, "Spawn window" ); btn = wnd:AddButton( 15, 40, 100, 23, "SPAWN" ); btn:AddOnClick( function() -- when button is clicked, tell server about it triggerServerEvent( "YOUR_EVENT_TO_SPAWN_CAR", getLocalPlayer(), 560 ) -- 560 is id of car end) wnd:Visible( false )-- hide the window --------------------------------------------------------------------------------------- Second file is spawner.serv.lua -- inside of server-side script addEvent( "YOUR_EVENT_TO_SPAWN_CAR", true ) addEventHandler( "YOUR_EVENT_TO_SPAWN_CAR", getRootElement( ), function( ID ) -- ID will be the one you put in client script (eg. 560 - "Sultan") x, y, z = getElementPosition( client ) -- client = player who triggered this event createVehicle( ID, x, y+3, z ); -- create vehicle by player end) -- inside of client side script (just under wnd:Show( false )) bindKey( "o", "down", function( ) -- this will show window if it's hidden and hide if it's shown wnd:Visible( not wnd:Visible( ) ) end ) and meta file also ---------------------------------------------------------------------------------------- And of course there is your glasses files in classes folder Whats wrong? EDIT: Oh I forgot to say that I fixed cursor bug. I just putted "false" Edited June 4, 2009 by Guest Link to comment
50p Posted June 4, 2009 Share Posted June 4, 2009 Look: -- inside of client-side script (in onClientResourceStart) ... "in onClientResourceStart". Where is it? -- inside of client side script (just under wnd:Show( false )) bindKey( "o", "down", function( ) -- this will show window if it's hidden and hide if it's shown wnd:Visible( not wnd:Visible( ) ) end ) Read the first line "inside of client side script (just under wnd:Show( false ))". I'm not here to do everything for you... life is brutal... This is the code you should have in the client-side file: addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), function( ) -- inside of client-side script (in onClientResourceStart) wnd = Window:Create( 10, 250, 200, 100, "Spawn window" ); btn = wnd:AddButton( 15, 40, 100, 23, "SPAWN" ); btn:AddOnClick( function() -- when button is clicked, tell server about it triggerServerEvent( "YOUR_EVENT_TO_SPAWN_CAR", getLocalPlayer(), 560 ) -- 560 is id of car end) wnd:Visible( false )-- hide the window -- HERE: -- inside of client side script (just under wnd:Show( false )) bindKey( "o", "down", function( ) -- this will show window if it's hidden and hide if it's shown wnd:Visible( not wnd:Visible( ) ) end ) end ) BTW, not "my glasses" but "my classes"... this is HUGE difference! Link to comment
Taalasmaa Posted June 4, 2009 Author Share Posted June 4, 2009 Didnt worked. Script starts, but when you push "o" nothing happens Link to comment
50p Posted June 4, 2009 Share Posted June 4, 2009 Errors? Warnings? If not, show us the code... I know you're the beginning beginner and you must have COPIED something wrong... Link to comment
Taalasmaa Posted June 5, 2009 Author Share Posted June 5, 2009 Nope, nothing warning or nothing it just start normal, but nothing happen ingame when you push "o". Link to comment
50p Posted June 5, 2009 Share Posted June 5, 2009 Show the code... You must be copying something wrong... In the mean time LEARN TO SCRIPT! Nobody will do everything for you! You said you made a "shop"... how did you make it if you haven't got any scripting knowledge at all? Why did you lie? Link to comment
Taalasmaa Posted June 5, 2009 Author Share Posted June 5, 2009 Show the code... You must be copying something wrong... In the mean time LEARN TO SCRIPT! Nobody will do everything for you! You said you made a "shop"... how did you make it if you haven't got any scripting knowledge at all? Why did you lie? ... I can script, I know about script.. But I cant do this spawner... My shop is working, but when you blow your vehicle (which you did buy from shop) you cant spawn it again.. And Thats why I need the fucking spawner... I putted this into "spawner.client.lua addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), function( ) -- inside of client-side script (in onClientResourceStart) wnd = Window:Create( 10, 250, 200, 100, "Spawn window" ); btn = wnd:AddButton( 15, 40, 100, 23, "SPAWN" ); btn:AddOnClick( function() -- when button is clicked, tell server about it triggerServerEvent( "YOUR_EVENT_TO_SPAWN_CAR", getLocalPlayer(), 560 ) -- 560 is id of car end) wnd:Visible( false )-- hide the window -- HERE: -- inside of client side script (just under wnd:Show( false )) bindKey( "o", "down", function( ) -- this will show window if it's hidden and hide if it's shown wnd:Visible( not wnd:Visible( ) ) end ) end ) and this I putted to to server side lua -- inside of server-side script addEvent( "YOUR_EVENT_TO_SPAWN_CAR", true ) addEventHandler( "YOUR_EVENT_TO_SPAWN_CAR", getRootElement( ), function( ID ) -- ID will be the one you put in client script (eg. 560 - "Sultan") x, y, z = getElementPosition( client ) -- client = player who triggered this event createVehicle( ID, x, y+3, z ); -- create vehicle by player end) And in meta file is correctly and its start correctly (script) How hard is it understand that script is installed correctly.. Link to comment
Mr.Hankey Posted June 5, 2009 Share Posted June 5, 2009 In your serverside script the variable "client" is not declared... You should rather use "source" as the local player (the client) is passed as the root element (source variable) for your event Link to comment
50p Posted June 5, 2009 Share Posted June 5, 2009 In your serverside script the variable "client" is not declared...You should rather use "source" as the local player (the client) is passed as the root element (source variable) for your event Since when client is not declared? It's custom event and can be triggered by players (clients) and client is another "secret" variable telling which player triggered this event. Or was it added in 1.0? Also, what has got this (server-side script) to do with client-side bindKey which shows window? addEventHandler check this out. I couldn't believe it didn't work, so I just wanted to know what is the EXACT content of the files (server-side and client-side). I copied what Talasma posted to the files Talasma said and it worked just fine. I mean what he said didn't work, it worked, that is, "pressing O doesn't show window". (Sorry for the speedometer underneath, I just use the same coords for everything I test.) BTW, you could add this line to show/hide cursor when "o" is pressed (UNDER wnd:Visible( not wnd:Visible( ) )): showCursor( wnd:Visible( ) ) Link to comment
Taalasmaa Posted June 5, 2009 Author Share Posted June 5, 2009 But when you tested that spawner did you have vehicle shop? Because I dont get it work.. Edit: Oh and how can you add houses (which you can buy) I tried kihc system, but didnt worked.. Does it happen with mapeditor? Link to comment
knash94 Posted June 5, 2009 Share Posted June 5, 2009 But when you tested that spawner did you have vehicle shop? Because I dont get it work.. Edit: Oh and how can you add houses (which you can buy) I tried kihc system, but didnt worked.. Does it happen with mapeditor? With KIHC u have to be named as the admin account and you need "ban" on your admin acl. I had this problem b4 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