-
Posts
1,461 -
Joined
-
Last visited
-
Days Won
34
Everything posted by DiSaMe
-
Although you can't change weapon properties per player, some effects can be achieved in other ways, and in your particular case, damage could be more or less handled manually: https://wiki.multitheftauto.com/wiki/On ... ayerDamage . By "more or less" I mean, it might become more complicated when vehicle damage and some other stuff comes into play.
-
In 5.1, only metamethod for userdata is mentioned: http://www.lua.org/manual/5.1/manual.html#2.10.1 In 5.2, metamethod is used for both tables and userdata: http://www.lua.org/manual/5.2/manual.html#2.5.1 Which means you can't do it in 5.1.
-
How do you know when you arrive at some destination? Do you calculate the distance in the beginning and then count down while walking? I doubt it, I think you're aware of the distance all the time and only stop when you see that you have arrived at the destination. So peds should work the same way, they must continuously check their position and see if they have arrived or not.
-
@myonlake Not sure what "sorting" you are talking about. Apart from element data not having "sorting" functionality at all, "sorting" here does not make any sense in the first place...
-
MTA streamer can handle up to 65536 objects. SA-MP, on the other hand, has no built-in streamer and its object limit is 1000.
-
triggerClientEvent createObject destroyElement ?
-
Instead of drawing it pixel by pixel you could draw it row by row out of horizontal lines (1 pixel height rectangles) using dxDrawRectangle.
-
... getElementMatrix You can't keep the image at the same position from the vehicle's point of view just by using position. Obviously, rotation makes difference. And matrix is the most straightforward and intuitive way to represent the rotation.
-
You didn't say what the problem is, but it seems like you use the arguments incorrectly. 2nd argument of triggerServerEvent is the source of the event, and function arguments come after it. --client triggerServerEvent("someEvent", someElement, "aaaa", "bbbb") --server function handlerOfSomeEvent(arg1, arg2) -- 'source' is the same as 'someElement' was on the client -- 'arg1' is "aaaa" -- 'arg2' is "bbbb" end
-
toggleControl bindKey setControlState
-
getElementMatrix That's how I made the tags sprayable on vehicles in my Drawtag script.
-
Anubhav, please, stop, that doesn't make any sense...
-
If you want to get the value from the table, then you must store it into the table first object_table = {} --creating and storing the object object_table[some_index] = createObject(...) --destroying the object destroyElement(object_table[some_index]) object_table[some_index] = nil -- although object no longer exists, its identifier value is still there, so we assign nil to remove that value and free the memory
-
Not by using non-existent functions, I guess?
-
isLineOfSightClear processLineOfSight
-
Perhaps because 'setWeaponProperty' is server-sided while "onClientResourceStart" is client-sided?
-
No table? Obviously, there is a table (that's how data is stored in SQL databases), and the error messages say exactly what's wrong: the table has 9 colums, therefore takes 9 values for each row, but the query string passed to 'executeSQLQuery' only has 8 values. Same with another error - there's no column 'huntersReached'. The table in the database is clearly different from the one that is specified in table creation query in this script. Excuse me, but that doesn't make any sense.
-
addEvent addEventHandler triggerServerEvent --or setElementData -- element data is synced if you set it for server-side elements unless you explicitly specify not to sync it Use loops for i = 1, 5 do outputChatBox(tostring(i)) end Outputs: 1 2 3 4 5 The code inside the loop block (therefore 'outputChatBox' too) will be executed 5 times, with different 'i' value every time.
-
Or just draw the chart pixel by pixel into render target.
-
It's not like we can tell the functions if you don't say what exactly you need to do. Gang system doesn't really need functions.
-
Calling 'setElementData' triggers "onElementDataChange"/"onClientElementDataChange". If these events cause 'setElementData' to be called, you get an infinite recursion. You could make a variable that stops the execution of event handler if element data is being reverted. An example: local revertingData addEventHandler("onElementDataChange", root, function(dataname, oldvalue) if revertingData then return end revertingData = true setElementData(source, dataname, oldvalue) revertingData = nil end) 'setElementData' call in this handler will cause the same handler to be called recursively, but the checking of 'revertingData' variable will prevent the subsequent recursive calls.
-
And it still won't work because the parent of all markers is 'ele'. That's it, if you want to abstractly link values, so that knowing one value would allow you to get another, it's better to use tables than parent/child hierarchy.
-
I'm confused. Unclear scripting and wiki guide?
DiSaMe replied to KieronWiltshire's topic in Scripting
Events have 'hidden' variables, one of which is 'source' (more info about them: https://wiki.multitheftauto.com/wiki/Event_system). 'Hidden' variables are actually global variables that are set before the handler is executed and unset after it's done. Every event has source which is an element related to that event (In case of "onPlayerJoin" it's the player who joined), and if there's additional data, it's passed via function parameters. As for "providing parameters" in 'addEventHandler', no, you don't provide parameters when you pass the function as a value. -- this will call 'someFunction' and pass 'someOtherFunction' as an argument: someFunction(someOtherFunction) -- this will use the return value of 'someOtherFunction' as the argument for 'someFunction': someFunction(someOtherFunction(someArgument)) -- this has the same effect as 'someFunction(someOtherFunction(someArgument))': local returnval = someOtherFunction(someArgument) someFunction(returnval) When you pass 'whenPlayerJoins' as an argument to 'addEventHandler', that means MTA will call 'whenPlayerJoins' function every time "onPlayerJoin" event is triggered. The parameters passed to the handler function depend on event. It's not so much different from what you can do in C: void someFunction(int (*funcPtr)(int funcArg)); int (*someOtherFunction)(int funcArg); int main() { someFunction(someOtherFunction); return 0; } (Not sure if syntax in this example is correct) Basically, if you have 'someFunction' and 'someOtherFunction' defined, this will call 'someFunction', passing 'someOtherFunction' as an argument, and if 'someFunction' calls 'funcPtr', it will call the function that was provided. The difference is that C, as a low level language, requires function parameter lists to be predefined and matching (both 'funcPtr' and 'someOtherFunction' accept one integer), while Lua doesn't make it all that strict.