
Antibird
Members-
Posts
177 -
Joined
-
Last visited
Everything posted by Antibird
-
This looks confusing for me, but element data set for some GUI-parent element is shared with every child the parent-element has. If a child element is a parent as well, the whole process keep going down the tree, so it's not only related to "gui-window" type of elements. local window = guiCreateWindow( 100, 200, 100, 100, "testwindow", false ) local button = guiCreateButton( 10, 30, 30, 30, "testbutton", false, window ) local label = guiCreateLabel( 0, 0, 20, 20, "testlabel", false, button ) outputChatBox( "W1: " .. tostring( getElementData( window, "testdata" ) ) ) outputChatBox( "B1: " .. tostring( getElementData( button, "testdata" ) ) ) outputChatBox( "L1: " .. tostring( getElementData( label, "testdata" ) ) ) --all 3 returns false setElementData( window, "testdata", "THEDATA" ) --try changing to "button" --no matter, if 4th (sync) argument is specified outputChatBox( "W2: " .. tostring( getElementData( window, "testdata" ) ) ) outputChatBox( "B2: " .. tostring( getElementData( button, "testdata" ) ) ) outputChatBox( "L2: " .. tostring( getElementData( label, "testdata" ) ) ) --all 3 returns "TESTDATA" string =( Shall this be classified as a bug? Everything seems to be Ok to other (non-GUI) elements, also that's not mentioned on wiki.
-
Then, by some reasons, 'VehicleInfo[idx]' is not a table even while 'VehicleInfo' is.
-
-> if ammount == "nil" then should be like -> if ammount == nil then or even like -> if not ammount then if tonumber(ammount) == "nil" then same way: if not tonumber(ammount) then Means tonumber() can't convert "amount" string into a number, so false is returned and that's what we're checking for using "not".
-
It's math.modf( x ), check the description here: http://www.lua.org/manual/5.1/manual.html#5.6
-
https://wiki.multitheftauto.com/wiki/AddResourceMap + https://wiki.multitheftauto.com/wiki/SaveMapData might do what you're looking for.
-
Not only water, but also clouds and effects like lights, dust, aircraft rotor/helicopter blades etc. And I think It was suggested long ago: http://bugs.mtasa.com/view.php?id=5189 Also, you may find it interesting that there's no such a thing in SA-MP (the weather has no meaning), so I guess it's fixable?
-
Afaik there are no other ways rather than using 2 images in your case.
-
As you said you have a table which contain an undefined number of subtables which contain an undefined number of subtables which contain an undefined number of subtables which contain.. -> Means you need an undefined number of iterations to go through every table you have in the mess. -> Means you need a recursive function - iterator -- or -- an undefined number of non-recursive iterators to solve it. The logic still stays the same I guess: it's to catch every single (sub)table you have and put it into another. Regardless of the recursion level you do the same thing to every subtable (obviously). Just in case you want to see how it can be done without rec., I must say I don't really know any efficient ways. Well, you may transform your table into a string using toJSON() and then use string.gsub() to search for table-specific symbols , like "[ [ ... ] ]" I think, and then transform the table-containing-substring into lua table again and then put it into your "children" table.. Jut in case.. =)
-
How large your initial table is? Did you try to count how long it takes to look through it? For example on my core2Duo 1.66 it's like 15 ms to list through an array of a million of elements. Also I don't think there's a better way to do what you want rather than using "ipairs" iteration. Recursion is your friend in this case =)
-
I've figured out this works fine: m = getElementMatrix( vehicle ) pitch = math.deg( math.asin( m[2][3] ) ) roll = math.deg( -math.atan2( m[1][3], m[3][3] ) ) --I need the minus, you may not yaw = math.deg( math.atan2( m[2][1], m[2][2] ) ) if yaw < 0 then yaw = yaw + 360 end The roll goes [-180, 180]
-
The script is client-side I guess? Do you need to get a vehicle pitch / yaw / roll values?
-
Yep, probably, but on the other hand searching for something is bit easier when each item has it's own ID. if ...[inventory].car_keys then instead of for _, v in ipairs( [inventory] ) do if v.description == "car_keys" then return .... In my opinion.
-
Item 1 becomes an sub - table in [inventory] one. PLAYERS[player].inventory = { { item1 = { description = "some_description", amount = 52, weight = 12 }, { item2 = { description = "item2_description", amount = 4, weight = 52 }, --.... etc .... } Don't know if anybody suggest some other way, but I prefer to use table anywhere they can be applied. Such a structured things are easy to deal with.
-
For myself I'm doing that using MySQL server for storing items. Could of course be Sqlite, it's a nice solution. Still It's up to you how to organize the read/write from/into database. When server is running, I find it more easier to keep data in a table, related to the player, like PLAYERS[player].inventory = { ... } --kind of It's basically what you need: 1. A way to store data 2. A way to read/write 3. Any ways to work with data red Good luck.
-
Hello, I'd like to know if anybody uses the module: https://wiki.multitheftauto.com/wiki/Modules/MySQL, which is said to be a "SQL module by "Multi Thieft Auto", means made by MTA team. First of all, the download link at wiki page is broken: http://files.mtasa.com/apps/1.0/dm/ml_devkit.tar.gz. So I used this link instead: http://files.mtasa.com/apps/1.0-deathmatch/ (ml_devkit.tar.gz, "last modified": 2008-Jan-04 ) I run a server on my laptop under Win7 x32 and every time the server executes mysqlOpen() it crashes regardless of arguments (such as ip for example) I pass to function. I have 2 questions so far: 1. Is the module still supported and supervised by MTA team; 2. If yes - is the crash is because I do something wrong ( or it's a known bug? ) Thankyou. P.S. Just in case you ask "Why don't you use this one?" Yeah, I use that one, but faced one lil problem: #roughly: function sqlconnect() handler = mysql_connect( "args go here" ) outputServerLog( type( handler ) ) --returns "userdata" return handler end Then I call if from another resource to retrieve a handler, but call() function returns a string containing database name only instead. And that is the problem I'd really like to avoid.
-
Probably, probably not. Might be just any kind of output of course.
-
Since server can't check for the client button state, it's probably better to check for combo client-side and then trigger some server event, or anything. Making a list of combos (key1 + key2 / key2 + key3 + key5 / etc) and bind all keys in the list to a function that checks for other combo keys pressed or not (which are related to the pressed one), this may be something you could use.
-
setElementVelocity(), the speedX\Y\Z are related to world.. just try it out yourself ) As for the "wait for 2 seconds.. etc": setTimer( setVehicleFrozen, 2000, 1, vehicle, false ) should work. You use the standart setTimer() function, first goes the function you'd like to execute, then delay (milliseconds), then how many times to repeat execution; after this you pass arguments you'd pass to setVehicleFrozen() itself.
-
IMHO It's better to: 1. Save vehicles current speed 2. Set it to 0 3. Set position 4. Apply saved speed values on vehicle # 1 and 4 in case you want the vehicle to keep moving after entering the portal, otherwise skip them. Still, setVehicleFrozen() serves both for freezing\unfreezing, what is your question about?
-
My fail, fixed in code above. He just copied and stuck with that error. @50p: everything comes of the script kevin11 posted, thePlayer as well. I just tried to explain the errors he had and show a way to avoid. Using 3 variables is only for visibility purposes.
-
Saying shortly: 1. Blender for example (or do you mean not "create", but "use" some custom objects you have? ) 2. see above 3. https://wiki.multitheftauto.com/wiki/EngineImportTXD + https://wiki.multitheftauto.com/wiki/EngineLoadTXD 4. Yes, you can. All the answers can be found at mta wiki page, it's the first place to have a look at if you are looking for anything related to mta scripting. Almost every function is given with an example there.
-
function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local nametagColor = getPlayerNametagColor ( source ) --INCORRECT! Delete it! --It only saves the RED color value in "nametagColor" variable, skipping Green and Blue one, so: local r, g, b = getPlayerNametagColor ( source ) -- is correct --Then, you can't save just 3 variables as a single account data, it requires a workaround: local nametagColor = { r, g, b } --we put everything in a table { }.. local dataToSave = toJSON( nametagColor ) -- .. and then transform the table using [url=https://wiki.multitheftauto.com/wiki/ToJSON]toJSON[/url] function. -- now we've got a table of colors in a string form so we can.. setAccountData ( playeraccount, "nameColor", dataToSave ) -- ..save it eventually end end function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local nametagColor = getAccountData ( playeraccount, "nameColor" ) if ( nametagColor ) then setPlayerNametagColor ( thePlayer, r, g, b ) --INCORRECT! Remove the line! --Look, you don't have "r", "g", "b" declared yet, you only have "nametagColor" one so we make a reverse transformation: .. local colorTable = fromJSON( nametagColor ) --..put out string back into table form using [url=https://wiki.multitheftauto.com/wiki/FromJSON]fromJSON[/url] function.. local r, g, b = unpack( colorTable ) --.. and get all 3 values from it with [url=http://www.lua.org/manual/5.1/manual.html#pdf-unpack]unpack[/url] function -- so now we've got RGB values for using in setPlayerNametagColor() setPlayerNametagColor ( thePlayer, r, g, b ) -- Now it's correct. end end end ( same for onPlayerSpawn() ) Of course this code can be shortened, but you must understand what each line does before trying to optimize. P.S. Yep, sorry. A mistype at line 23.
-
I think he just wants to use a function as an argument for 2 event handlers, so i don't see any other way rather than making the function "non-anonymous", declaring a ( local ) variable for it.
-
There are. It's a matter of scripting only. The first thing comes on my mind is to switch camera back to "normal" view on player press aim button and when he releases - set it to first person again.
-
It's like in single player. An ordinary default camera "attached" to the Cj and following him wherever he moves. setCameraMatrix() makes your camera loose it's target ( your player ), in this case you can't aim with weapon like usually. setCameraTarget() return aiming ability and bounds the camera back to player, into it's "typical", unmodified state.