-
Posts
2,973 -
Joined
-
Last visited
-
Days Won
3
Everything posted by 50p
-
There is that parameter for triggered function in onVehicleDamage which is "loss". It represents how much damage your car got in this "hit", so just check if the "loss" is larger then some value and you're done. Read the wiki more, it's your best friend, just after google.
-
If setVehicleEngineState() works ok, then you can easily make such script. All you need to do is use that function in a onVehicleDamage event.
-
http://development.mtasa.com/index.php?title=Main_Page
-
jkub, if you use my GUI Classes, don't use :AddOnClick() twice with the same function because it will be triggered twice. Like: button:AddOnClick( A_Function ); button:AddOnClick( A_Function ); function A_Function() triggerServerEvent( "clientRequestBanshee", ...... ); end I don't check if the function you're trying to add is already added. That's why it may call it twice.
-
https://community.multitheftauto.com/index.html?p ... ils&id=222 Maybe this will help.
-
Seems like you trigger event twice. It's not possible that "if - else" statement executes twice by itself. If it was C or C++ and you had "goto" then yes, but it's Lua. This piece of code looks OK to me or you've given us not the info you was meant to.
-
"convenient" (just swap 'n' with 'i' ) I tried to make it as easy as possible because there is lots of people who don't know how to script GUI. Anyway, good luck with scripting.
-
You just have to copy "/classes/" directory with all the file in it into your new resource and and copy specified lines from meta.xml into your new resource meta.xml. I stated which lines you should copy in the meta.xml itself. It says: ... The magic is that you just copy my GUI Classes files (/classes/ dir) to your resource and include them in your new meta.xml so that client knows that the files are used and they will be used... then you can just start scripting with my classes.
-
It's so simple and you still don't understand? Check the topics I gave you the links to in my previous post because I'm 99% sure you didn't even read them. All you need is there and here already Try to read and understand. Also practice by writing scripts. When you don't try writing yourself you will never learn. If you have errors in your scripts, just post here and people will be glad help. When I say it's easiest way of scripting GUI so far then it must be true because if you don't script OOP way then your code can be messy sometimes, especially scripting more complex GUI. I gave you an example, why don't you try it. Download my GUI Classes and give it a go. I also made a few examples in "test.lua" file so you can learn from it too.
-
Server-side: addEvent( "clientRequestsWeapon", true ); addEventHandler( "clientRequestsWeapon", getRootElement(), function( ) local money = getPlayerMoney( client ); if money >= 350 then takePlayerMoney( client, 350 ); giveWeapon( client, 22, 35, true ); else outputChatBox( "Get some money before you buy this shit!!!", client ); end end ) NOTE: Some people don't know that server events triggered by clients have another "hidden" variable which is "client". This variable tells the server which client triggered the event, so you don't have to pass getLocalPlayer() to triggerServerEvent and add that to list of arguments in a function attached to the event. In this case "source" isn't even needed. Client-side: -- add this to a function added to AddOnClick() triggerServerEvent( "clientRequestsWeapon", getRootElement() ); This one line will trigger server event (which is added in the server-side code above). The event has a function attached which will be called by the event. That function will deal with the money and the weapon too. I hope you'll understand now how server and client can "talk" with each other. If you still don't understand.. then I wish you luck in reading wiki. Peace and Love!
-
Yes, getPlayerMoney is server-side only. You must triggerServerEvent which will deal with the money and the weapons because you can't have a gun that only you can see it.. other players wouldn't get any damage. Read a bit more about triggerServerEvent.
-
Maybe in the future I'll take an advantage of arc_'s animation class, so that you could have more functions, like Slide() (to slide gui on your screen), SlideAndFade() (to slide and fade in or fade out on the screen) or Fade() (to fade in or fade out)... But that's far from being done due to lack of time. Anyway, remember, I replaced 2 functions with only 1, so if you call a method without passing any values, it will act like "Get", eg. button = Button:Create( 10, 200, 50, 20 ); -- notice that I didn't pass "relative" param here, because I made it default to false button:Position( ); -- this will return it's position (non-relative values, pixels) button:Position( true ); -- should get position with relative values ( 0 - 1 ) button:Position( 100, 200 ); -- it says for itself, also lack of "relative" param "GUI made easy!"
-
You shouldn't make tags which are the name of player. Your example of: <{TJT}Tim>Police{TJT}Tim> is wrong format of XML. You can't use { or } in XML tags or attributes. Use different way, like: Police or something else.
-
robhol, I don't know if I get you... but have you tried this http://development.mtasa.com/index.php? ... enPoints3D ?
-
jkub, I'd suggest using my GUI Classes which are easy to use and you can easily attach functions to "Click" event. Your code would look like this: function createWindow( ) myWindow = Window:Create( .02, .3, .2, .6, "Test", true ); myWindow:Visible( false ); myWindow:Movable( false ); myWindow:Sizable( false ); myWindow:AddLabel( .1, .1, .28, .1, "colt45", true ); --[[ I made Add... functions for all the gui elements which can be children of the window the names of the functions are easy to remeber, like, AddLabel, AddButton, AddGridList, etc. ]] btnCls = myWindow:AddButton( .25, .9, .5, .05, "Close", true ); -- you see here? simple btnCls:AddOnClick( hide ); -- look how simple it is! end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), createWindow ); function hide( ) myWindow:Visible( false ); showCursor( false ); end Most of the GUI functions from wiki are accessible from my classes. "guiSet" and "guiGet" are removed from the function name, so for instance if you wanted to see if a window is visible you'd use: myWindow:Visible(), if you'd want to set its visibility you'd use myWindow:Visible( true or false )
-
Show us what you tried. We're not going to do it for you because it's simple and sometimes I think you act a fool.
-
Please try this: https://forum.multitheftauto.com/viewtop ... 91&t=24122 It's much easier to make gridlist and click handlers with my classes. Here's how your gridlist would be created: ls = Window:CreateWindow( .... ); -- pass your parameters in place of '....' gridlist = ls:AddGridList( .01, .02, .4, .96, true ); gridlist:AddColumn( "Choose a team:" ); gridlist:AddRow( "LSPD" ); gridlist:AddRow( "Los Banditos" ); gridlist:AddRow( "Grove" ); gridlist:AddRow( "La Costa Nostra" ); gridlist:AddRow( "Ballas" ); gridlist:AddRow( "Medic" ); button = ls:AddButton( .79, .83, .2, .15, "OK", true ); button:ColorOnHover( "0064FFFF" ); -- RRGGBBAA button:AddOnClick( function( ) triggerServerEvent( .... ); -- your params here... end ) Also, check my post here: https://forum.multitheftauto.com/viewtop ... 48#p288402 it shows you how to get text of the selected item in the gridlist. Peace and Love!
-
In your case "content" is vehicle element, it's not a number, string or something that you can save in a file. You can't save vehicle that way. You'd have to save the ID of the car not the "vehicle" element.
-
Make it real then or at least give it a try
-
setTimer() is called whenever you call it not only when resource starts, like every function.
-
Why do you both complicate that simple task. "have a client connected to the server at all times", what for? You probably don't need to get ground Z position if there is no players online, do you? "warp that player to the co-ordinates you want to get the z of, get the z clientside and then send it serverside with a triggerServerEvent" That's almost exactly what I said, almost because there is a client-side function which is very useful which CodeMaster probably know about, that's why he's asking for server-side solution. triggerClientEvent - to get ground position with getGroundPosition triggerServerEvent - to send the Z coord back to the server... "Isn't it easier to just use processLineOfSight between x1, y1, z1 + n and x2, y2, z2 - n?" Why not simply using getGroundPosition()? If you're in the air, say, Z > 500, you'd have to process: z1 + 800 and z2 - 800 (interiors start at around 1000 and the highest distance you can fly is around 700-800).
-
LOL, Will. That really made me laugh! Are you serious? Such table would have to be HUGE and you wouldn't get exact Z coord which can be useful in some cases. Also, it wouuld take you ages to make such table... SA is about 6000x6000 units, that is a big piece of world.
-
Is it triggered for specific player? Or it doesn't work with getRandomPlayer() only? Also, if you could, show us the line where you trigger it.
-
The thing is that server doesn't know client's ground because server doesn't load client's .ipl's. The only way to get ground Z position server-side is triggereClientEvent and triggerServerEvent back.
-
OK, as I said it's not long code so I can do it... I always say "I was born to help other people", but some people are so lazy that I don't even want to help them... Here, make a new file and paste this code into it: addEvent( "test_ClientCreateVehicle", true ) addEventHandler( "test_ClientCreateVehicle", getResourceRootElement( getThisResource() ), function( vehID ) --"client" is a hidden player that triggered server side event local x, y, z = getElementPosition( client ); -- here's the client createVehicle( vehID, x + 5, y, z ); end ) Add new line to meta.xml: <script src="THE_FILE_NAME_YOU_JUST_CREATED.lua" /> And change line where you created car client-side with this: triggerServerEvent( "test_ClientCreateVehicle", getRootElement(), tonumber( gridList:ItemText( rowID, 1 ) ) ); That's all you need. Basically, when you used addEvent() in server-side script you will have a new event that client can trigger and send some data... What you wanted to do was create a car server-side, right? Right, so, you just send an id of the vehicle you want to create (which is taken from the Grid List) and create it with createVehicle(). If you want to know more (it will be useful in the future if you want to extend server's gameplay) about events go to: http://development.mtasa.com/index.php? ... ent_system