-
Posts
2,973 -
Joined
-
Last visited
-
Days Won
3
Everything posted by 50p
-
Yeah, but from your example it doesn't seem to simplify scripting or keep it in clean. You said at the end it will be easier but not it's not. Before you start making "framework" you should look ahead and organize things to keep it clean from its start rather than when it's finished because you'll have to change lots of things to make it clean afterwards. Also, when giving example on wiki (documenting) you should show the way it is going to be used so that people know how easy it will be to script. Just an advice. PS. Don't call me _50p because I'm 50p I use _ on irc because it doesn't allow me to use digits as the first character of my nickname.
-
I used .NET 2.0 to parse meta.xml to get files included in resource and it's not that hard. Just one loop. If you used C# than take a look at this .NET 2.0 code, robhol: ArrayList files = new ArrayList( ); if( File.Exists( path + @"\meta.xml" ) ) { FileStream fs = new FileStream( path + @"\meta.xml", FileMode.Open ); try { XmlTextReader reader = new XmlTextReader(fs); while (reader.Read()) { reader.MoveToContent(); if (reader.NodeType == XmlNodeType.Element && reader.Name == "script" ) { files.Add(reader.GetAttribute("src")); } } fs.Close(); return files; } catch { } } This is a piece of code that I used to get all the script files included in meta.xml and it's C# .NET 2.0. Don't choose the easiest way because you will never learn harder things. Besides, .NET 2.0 is for wider audience.
-
No, I have 1.1, 2.0 and 3.0 versions of .NET. I've never had 1.5 nor 3.5. If I'd love to compile it I'd download 3.5. I was wondering what you used LINQ for
-
I think, to make things easier and make code look more clean you'd better make classes for "elements" and some base classes for the most events. For instance: local ak47 = Pickups:Create( 30, 0, 0, 3 ); -- ammo would have some default values ak47:OnPickup( function( player ) player:TellMe( "You just picked up AK-47!" ); end ); This way, you just get rid of ChatBox:init(player) or some funky Event.onPickupHit style. You can look up my GUI lib again to see how I made the event handlers (I'm pretty sure you learnt from it how to OOP in Lua). I think MTA should have built-in classes. Like this: local vehicle = Vehicle:Create( 560, 0, 0, 3 ); vehicle:GetName(); -- instead of: getVehicleName( vehicle ); vehicle:Position(); -- instead of: getElementPosition( vehicle ); vehicle:Position( 10, 0, 3 ); -- instead of: setElementPosition( vehicle, 10, 0, 3 ); vehicle:Color( 6, 6 ); -- instead of: getVehicleColor( vehicle ); ------ vehicle:OnEnter( function( player ) player:TellMe( "You entered: "..vehicle:GetName() ); end ); -- instead of: addEventHandler( "onVehicleEnter", getResourceRootElement( getThisResource( ) ), function( player ) if source == vehicle then outputChatBox( "You entered: "..getVehicleName( source ), player ); end end ); I wish I had more time... I'd spend some time on making such classes for every element but I have to catch up with my college work.
-
I just checked and luac.exe does support paths with quotation marks, so the problem must lay somewhere else. Did you release source code for this "tool", robhol?
-
As you all probably know, He doesn't need help and will not post on this forum because he's good enough and doesn't need to ask for help but if he will ask, than quote him and maybe he'll understand that he's ignorant. Be good to me and I'll be good to you, if you aren't good to me than I ain't good to you. Simple as that. So from now on, just ignore his posts.
-
The thing is that to compile lua code with luac.exe you have to pass path to it not as string with quotes (eg. "hell world.lua") but without quotes (eg. hello world.lua). The problem is that the first parameter is file you want to compile (which would be: hello, which doesn't exist) and the second param is the output file (in this case world.lua)... I haven't use this tool (due to .NET 3.5) but I'm pretty sure the problem is in the paths and the compiler probably outputs some errors.
-
or this should work too: spawnPlayer( source, unpack( spawnPoints[ randomSpawn ] ) );
-
Ah, LINQ... so it won't be useful for me. Anyway I think .NET 3.5 is still too new to use it.
-
I haven't tried it but I think you should make applications with .NET 2.0 because not everyone has .NET 3.5 installed. It can be useful for some people : P
-
How did you do that? -- SERVER -- function greetingHandler ( message ) outputChatBox ( message, source ); end addEvent( "onGreeting", true ); addEventHandler( "onGreeting", getRootElement(), greetingHandler ); -- CLIENT -- addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), function ( ) button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Test", true ); addEventHandler( "onClientGUIClick", button, spawner, false ); end ) function spawner ( ) triggerServerEvent ( "onGreeting", getLocalPlayer(), " wowow" ) end
-
1. I don't understand anything... You don't want to use onResourceStart because you want to use onVehicleRespawn which doesn't work when resource start but you want something that works when resource start? What is your problem? 3. Don't understand this neither... "You fix it but can't fix it yourself"? Hmm...
-
bindKey ( player, "lshift", "down", On, element ) What is On and element? Check the bindKey documentation. You can answer all these questions by yourself.
-
You can replace normal models but you can't replace characters nor weapons.
-
http://www.youtube.com/watch?v=DQklrnpVYBs EDIT: Just had some free time and got the coords: X Y Z Rotation 2295.6564941406, -20.267875671387, 26.3359375, 294.56463623047 // bank
-
TXT = dxText:create( txt, screenWidth/2, screenHeight/2 ) TXT:font("pricedown") TXT:type("border", 2, 0, 0, 0, 255) I've never used this lib but that's how OOP works in Lua.
-
Yes GIF works too but if it's an animated GIF then it will stop on the first frame. JPGs are lighter but worse quality. I always used PNG for everything, they also support alpha channel so you don't have solid color background but instead it's transparent.
-
When you're using that GUI Classes and you have a window object (created with Window:Create) then to get actual GUI element to be used with native GUI functions, just use .gui variable of that window object (you can read more about it in "Useful information" section), like so: garageWindow = Window:Create ( .02, .3, .3, .6, "Car Bombs", true ) img = guiCreateStaticImage(.5, .5, .5, .5, "bomb.png", true, garageWindow.gui) -- note the .gui But, you can use the GUI Classes for this as well (sorry for not documented all functions/methods but I don't really have time, even for MTA). To make an image within a window with the GUI Classes you can do this: garageWindow = Window:Create ( .02, .3, .3, .6, "Car Bombs", true ) garageWindow:AddStaticImage( .5, .5, .5, .5, "bomb.png", true ) And again, sorry for unfinished documentation. You can take a look into wndtab_class.lua to find out all methods that you can use with Window and Tab objects (by saying objects I mean GUI element created with classes, in this case garageWindow). Hope that will help.
-
Maybe some other script used showCursor(). I'm not 100% sure but when you use showCursor( true ) in one script then you have to use showCursor( false ) in the same script to hide it, if you won't hide from within the same resource it will not disappear. So that when you use showCursor( true ) in one script then show cursor again from another script, the cursor will not be hidden until both scripts call showCursor( false ). (I remember it was meant to be implemented in 1.0, so if you're on nightlies then you should consider that)
-
You can replace those 2 lines with 1 Logo = guiCreateStaticImage(0, 0, 1, 1, 'serverlogo.bmp', true ) BTW, I wouldn't recommend using BMP since they are quite heavy and is really old. I'd recommend using PNG or JPG.
-
The error basically says pos2z is nil. Check your code where it was assigned a value and make sure it's a number. We can't see when pos2z is assigned a value so we can't tell you why you get an error.
-
I can't remember very well because it was long time ago since I stopped scripting it... I think the problem was with angles when max and min angles change while drifting NE -> N and NW -> N. Test it on an airport.. I can't really remember and can't test it myself due to lack of time, sorry. I hope you'll make some nice script with it.
-
Drifting script was one of my first scripts for MTA (it was being developed looong time ago) but I never finished it. So, maybe you'll want to take a look and finish it. There were some problems with angles when drifting from NorthEast -> North and NorthWest -> North.
-
You have one global variable bind. Whenever a player spawns another player will have the key bound even when he spawns, why? Because that one global variable is 0. You don't have to use that global var to check if the key was bound. You can use isKeyBound() to check if the key "arrow_r" is bound already.. then you can unbindKey if isKeyBound() returned true.
-
This is actually wrong. 1 and 0 are numbers and will always return true. It's not C based language. Lua is different language and 1 and 0 don't count as boolean values. nil and false will always be false, everything else is true, even 0.