Jump to content

50p

Retired Staff
  • Posts

    2,973
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by 50p

  1. 50p

    Lua OOP

    That's a separate metatable, check the rest of the code to find its uses.
  2. 50p

    Lua OOP

    There is no need for that anyway. It's good to have some sort of table of "instances" if you need to draw the objects in onClientRender, eg. to draw text, shapes, etc.
  3. 50p

    Lua OOP

    wow so useful EDIT : I was reading that link, when I got a doubt : function Account.withdraw (self, v) self.balance = self.balance - v end "self" is like the word "this" on C#? Second question : function Account:withdraw (v) This is like a inheritance property? function Account:withdraw( v ) -- is almost the same as: function Account.withdraw( acountObject, v ) The difference is that when you call the later one, you have to pass your object to the call, lets say you create an account object: account = Account: new( ); -- default balance of 0 print( account.balance ); -- should print 0 Once you have an object account, you can do either: Account.withdraw( account, 100 ); -- as you can see, you have to pass object argument -- or simply account: withdraw( 100 ); -- this will pass account object to Account.withdraw's first parameter for you Here is a simple color class which I just wrote now for you: Color = { } -- classes are tables Color.__index = Color; function Color: new( r, b, b, a ) local color = { r = r and r or 255, -- set default value to 255 if r is not passed in the call g = g and g or 255, b = b and b or 255, a = a and a or 255, mtaColor = tocolor( r, g, b, a ); } setmetatable( self, color ); return color; end function Color: set( r, g, b, a ) -- first param is the class object (not specified in the params list) = self; same as "this" in C# self.r = r; self.g = g; self.b = b; self.a = a and a or self.a; -- make "alpha" an optional param -- it's same as: if a then self.a = a end self.mtaCol = tocolor( self.r, self.g, self.b, self.a ); -- update mtaCol as well end Here is an example use of this class: myColor = Color: new( 255, 255, 0 ); -- remember alpha is set to 255 by default dxDrawRectangle( 10, 300, 10, 10, tocolor( myColor.r, myColor.g, myColor.b ) ); myColor: set( 200, 200, 200 ); dxDrawRectangle( 10, 350, 10, 10, myColor.mtaCol ); -- here is the same function like above but you have to pass object to the call: function Color.set( col, r, g, b, a ) col.r = r; col.g = g; col.b = b; col.a = a and a or col.a; col.mtaCol = tocolor( r, g, b, col.a ); end --[[ EXAMPLE: Color.set( colorObject, 100, 150, 0 ); or simply: colorObject.set( colorObject, 100, 150, 0 ); BOTH are valid but I never use it any more.. I keep my code cleaner ]] I just hope it helped you a little. I know it seems confusing at first, but if you keep using it and try to learn it, you will get used to it. I've created tens of classes (if not hundreds) already and I can make them in different ways and they will still work because I understand the mechanism behind it. Don't just read the information from the link I gave you. Try to write the code and you will understand it quicker as you go deeper into classes.
  4. 50p

    Lua OOP

    http://www.lua.org/pil/16.html This is where I learnt from to create my bank resource.
  5. Split the string by words. The method you us to split string is OK but it will cut words half way if it's too long or 2 letter words will split and you will end up with 1 letter on 1 line and another on the next line. You can use MTA native split function.
  6. If you use dxDrawText, why don't you use wordBreak parameter?
  7. Make sure your function is exported as an http function.
  8. Since my pictures are too large and the forum doesn't resize them I'll be posting links instead. Here is a little update: http://tinypic.com/view.php?pic=27zx7yq&s=6 I made a resource to load and play camera animations exported from 3DS Max. I could have used 3DS Max native animation files but they are too large for MTA client to download them, besides there is useless information. If I want to play an animations I can do the following: camera = CameraManager: New( ); camera: LoadAnimFile( "round.mtacam" ); camera: PlayAnimation( "around_object" , Vector3: zero( ) ); -- the 2nd parameter is the offset where to play the animation. Vector3:zero() is equivalent to 0, 0, 0 I can also attach animation to elements so that animation follows the element. As you can see in the bottom left corner of MTA window, there is a little axis gizmo to give you easy orientation of the 3d space. I want to add a "move gizmo" so that animations/key frames can be moved within MTA.
  9. Yes. Imagine that you want to create a spawn screen with camera moving around the spawn location, do the camera animation in 3DS Max and export it, then load it to MTA and play it.
  10. This is what I made yesterday. It's a camera animation exporter. It exports the animation to an XML file. Exports things like: camera position, target, rotation (roll) and FOV. Currently working on a resource to play the animations. Since it exports every frame, it will be easy to play the exported animation. Animation has to be baked first so I can play animations by names. Do you like the camera animation during countdown in racing games like Gran Turismo ? I want to let the user to be able to create their own I also want to let the resource create animations too, so you could make "fly through" sort of anims for your maps inside MTA itself. I've learnt a little bit about Bezier Curves yesterday to know how to create curves and I'll let the camera follow the path instead of baked frame animation (like I did in 3DS Max on the screenshot below).I downloaded the Stage resource but it's way too complicated to do any camera animations in it. At least for me.. besides I didn't even know how to save/export the animation to reuse it. Right-click and view in a new tab/window if you can't see the full image.
  11. It says 1.1 will come out on 1st May. Title of the topic says "... 1.0 is out!" Well, rolling11, there is no way of releasing a script without giving a download link. If you're working on a script and want to show the progress then do so by posting screenshots/videos. Otherwise, don't fool people.
  12. Probably because when you created file you didn't want to add it to any resource. Simply, select one of the resources from the drop down list that you want to work on and add the file again.
  13. rolling11, If it's out, post the download link. Otherwise, don't make such posts because the forum will be dirty and people will keep asking for the link, release date, etc. Post screenshots or videos showing the features.
  14. If the window isn't source, it can be something else. The user can't click any GUI therefore can't raise onClientGUIClick event.
  15. Thanks for your comments guys. @Benox.exe It wouldn't be hard to script as long as you know MAX Scripting language I do, well, I'm not a pro but I've built a few tools and macro scripts for personal use (like taking clay renders, removing materials form models, a "spherify" tool (to layout vertices in a round shape - for hi-poly modelling), quick preview (for hi-poly modelling to see models with turbo smooth on, and wireframe off) etc. Everything is possible and not as hard as it seems when you know what you're doing Anyway, event scripting wouldn't be hard but GUI script would be harder to script because I'd have to make a GUI sort of editor (like in UDK) for 3DS Max. Oh, camera animation, I haven't thought of that! It's a great idea! Also, creating custom col shape would be possible since MTA has a createColPolygon function to support this. I would be so much user friendly to just create 2D shape from the top view and actually see the shape instead of trying to imagine it. Could use the resource someone made to animate camera to create cut scenes. It would take 3DS Max camera animation and export it to the format that resource supports or create new resource and its own format @RaceXtreme, Indeed, the hardest part would be to make a Map Importer, since models would have to be exported from GTA3.img first before importing them to 3DS Max, but it's definitely doable! I think Spark tool has a console tool to export models from .img files with commands. Would have to research this one though. The first thing to research would be to find out how KAM's script imports the .dff models which is hard to find out without getting in touch with the creator himself. I figured out how to export models to .dff with his function but still can't figure out how to import. The only downside of having this map editor is testing the maps. I'd have to think of a way of testing maps but still make it convenient for the user. Maybe, export the map as a test map, start the map on the local server and switch the window to the game window, it would all be automatic but I think I'd have to use .NET for this and the user would have to run MTA client, server and 3DS Max at the same time. I don't know how many people can run MTA and 3DS Max at the same time because both of these applications take a lot of RAM. Anyway, the ideas are there, it's just a matter of scripting it! I can see all these tools on the horizon but when will I reach that point, I don't know. "So much to code, so little time." EDIT: Did some testing, looked here and there and found a way to use 3DS Max and Spark tool (GTA archive tool - like IMG Tool) to export models/textures from .img archives With just 1 click I can export vehicle and its texture from gta3.img. Also, found a great framework for MAX Script which adds a Schematic View (that's a node-based control), have a look at sample screenshots from studios like Blur that used it: http://www.lumonix.net/helium.html This could be used for the visual scripting like Kismet in UDK. EDIT 2: I've made a small tool (not fully working yet) to let me create nodes for that Schematic View plugin for 3DS Max. It'll let me create nodes easier.
  16. Yeah, it could be but still, should work with root too.
  17. If MTA element tree works the way the developers say it does then this should hide all gui elements when you click outside GUI elements: addEventHandler( "onClientClick", root, function( btn ) if btn == "left" then guiSetVisible( root, false ); -- this should hide all the GUI visible end end ) If you get an error message then you have to specify which GUI element (window) you want to hide.
  18. 50p

    360* Camera

    Ok no problem. We'll leave it open in case others have the same problem.
  19. 50p

    360* Camera

    Ok, change this line: facing = facing + 0.0002; to this line: facing = facing + speed;
  20. 50p

    md5 + Trigger

    The problem with your code is that you you have 2 variable with the same name. 1st is coming from arguments and the other one is from database. Just change one variable name and you should be fine. If you look closely, you change the value of password (the function argument) with the new password from database (which is already a hash of md5), then you hash its value with md5 (which will give you completely new value), then you compare these 2 different values. This is why it "fails".
  21. 50p

    360* Camera

    I deleted fadeCamera and not working Check the debugscript window. If non of your resources use fadeCamera function then you will always have black screen because that's what happens when you join server that doesn't run any scripts.
  22. 50p

    PHP SDK problem

    Also, according to your PHP script, in Lua the result function: sResult will always be "1". Make sure you return correct value in your PHP script.
  23. 50p

    360* Camera

    onClientPlayerJoin - "This event is triggered when a player joins a server. It is triggered for all players except the local player, as the local player joins the server before their client-side resources are started." I don't know why people don't try to find the correct events... Always use onClientResourceStart if you want something happen for local player when he joins the server.
  24. 50p

    360* Camera

    People, there is more maths required to do the rotation. I don't know what it is like on that server because I haven't got time to check it but if you've used my modshop resource then you'd know how it works. Also, roll parameter in setCameraMatrix function is not the rotation like you all might thing.. It's the angle at which the camera is rotated (rolled) at. Imagine having a camera in your hand, point at something in front of you and move your wrist up and down, then just play what you've recorded. Can you see the difference? And FOV (field of view or field of vision) parameter is how wide you can see. This is a camera lens variable. Read more about it here: http://en.wikipedia.org/wiki/Angle_of_view I modified my old functions for easier use, just copy this entire code and call startRotatingCamera() and stopRotatingCamera() to do what the function names say: function startRotatingCamera( ) addEventHandler( "onClientPreRender", root, rotateCameraAroundPlayer ); end function stopRotatingCamera( ) removeEventHandler( "onClientPreRender", root, rotateCameraAroundPlayer ); end local facing = 0 local distance = 5; -- you can change this to change the distance between camera and the player local height = 1; -- you can change this to change how much higher the camera should be above the player local speed = 0.0002 -- change this to speed up or slow down the camera rotation local gLocalPlayer = getLocalPlayer( ); function rotateCameraAroundPlayer( ) local x, y, z = getElementPosition( gLocalPlayer ) if isPedInVehicle( gLocalPlayer ) then x, y, z = getElementPosition( getPedOccupiedVehicle( gLocalPlayer ) ) end local camX = x + math.cos( facing / math.pi * 180 ) * distance; local camY = y + math.sin( facing / math.pi * 180 ) * distance; setCameraMatrix( camX, camY, z + height, x, y, z ) facing = facing + 0.0002 end
×
×
  • Create New...