-
Posts
6,062 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
Login is not the same as registration. If you are still worried. Open your acl.xml file and search for sebas. If you can't find him there, he is no admin.
-
I had the same results, so nothing has changed. It might even be possible that they are already localized in some unknown way. Just as the predefined source variable is localized when an event has been triggered.
-
@slapz0r Do you want to mute them or mute the audio from other players as well? I haven't done this before, so I do not know the best practice, especially the capability of voice with your gamemode. But let me increase your options: See this event: onPlayerVoiceStart + example on that page. Here you have a list of export functions for the voice resource. See: https://wiki.multitheftauto.com/wiki/Resource:Voice#setPlayerVoiceMuted_2 And https://wiki.multitheftauto.com/wiki/Resource:Voice#setPlayerChannel
-
The _G table keeps track of all global variables. Not just functions and not all functions, as some can be saved in local variables. https://www.Lua.org/pil/14.html Yes, they are `shared` or rather copied. I honestly only localize my own functions. The last time I checked, I didn't notice any optimization by localize MTA functions. Every file has it's own scope, so making use of that is not a bad thing. My main reason for localization: You can use it to distinguish functions used within the file, from functions that are called from other files. The only thing I do with some Lua functions is this: local mathRandom = math.random
-
It took a while before I had time for explaining an enchantment which I created a while back, but I finally wrote a topic for it. Just another enchantment topic/tutorial. This time it is about communication between serverside and clientside.
The context of what will be enchanted
These 2 sides will have communication with each other:
serverside > code that runs in the server application.
Program Files (x86)\MTA San Andreas X.X\server\MTA Server(.exe)clientside > code that runs on all clients/players > game application.
Program Files (x86)\MTA San Andreas X.X\Multi Theft Auto.exeIn most cases there is just 1 server.
And there might be more clients / players connected to that 1 server.If you already know how client/server trigger events work, then it is still worth looking at. It is an enchantment, which means it does things for you, so less code is needed to achieve something complex.
There are some stupid jokes included, which are actually really bad... sorry. It is suppose reduce the cognitive load of the content by letting the reader first visualize the context before explaining it. (it is a method)
-
MTA-Communication-Enhancement This is an enhancement that allows you to communicate between clientside and serverside a bit easier. If you know how to work with events, then you probably do not need this, but it has some nice features which allows you to sit back and write less code + achieve some nice results. Note: It is important to keep in mind that this is an enhancement. Which means it is just an layer on top of the basic functionalities of MTA. And most enhancements come with a cost, in this case that is bit of performance. I will keep the information of topic to the minimal, as I have written most of the information already on the repository. You can find the repository here. Examples Syntax Installation What can you do with it? Calling from clientside to serverside Client callServer("hello") Server function hello () outputChatBox("Hello client!") end Calling from serverside to clientside Server addCommandHandler("callclient", function (player) -- An addCommandHandler is needed, because the client hasn't loaded it's scripts yet. callClient(player, "hello") end, false, false) Client function hello () outputChatBox("Hello server!") end Ok, ok, that was boring. The next one this is a bit nicer! Hello are you there? Just Call-me-back... I miss(ed) you too Callback Client callServer( "callbackMe", "argument", function (argument) -- < This is the callback function outputChatBox(argument) end ) Server function callbackMe (argument) return argument .. " < I looked at it :)" end Callback + internal arguments Sometimes you have arguments that you simply can't send over. > functions Or arguments that shouldn't be send over. > LARGE quantities of database data Internal arguments can be used to pass information to a callback without exposing it to the other side(client/server). Client callServer( "callbackMe", -------------------------------- -- arguments that are send over "argument", -- -------------------------------- function (internalArgument, argument) -- < This is the callback function. outputChatBox(internalArgument) outputChatBox(argument) end, -------------------------------- -- arguments that are not send over "internalArgument" -- < internal argument -- -------------------------------- ) Server function callbackMe (argument) return argument .. " < I looked at it :D" end Ha! Serverside what is that? No need for complicated things! Communicate between clients without writing a single line of serverside. Magic! Note: There is serverside used behind the scenes, you just don't have to write it. Client function smile (player) outputChatBox((isElement(player) and getPlayerName(player) or "[unknown]") .. " has send you a: :)") local x, y, z = getElementPosition(localPlayer) setElementPosition(localPlayer, x, y, z + 100) end addRemoteClientAccessPoint(smile) -- < This function allows other clients to call this function. --------------------------------------- -- -- function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end -- Author: TAPL -- https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName -- -- --------------------------------------- addCommandHandler("smile", function (cmd, playerName) local player = getPlayerFromPartialName(playerName) if player then outputChatBox("Sending smile!") callRemoteClient(player, "smile", player) else outputChatBox("Can't find player!") end end) Turtle, I will wait for you to catch up. So don't worry, you are still cute. Await functions When a player has joined the server, he or she doesn't have download + loaded his scripts yet. This means that you can't deliver your love letter yet and all your work will be for nothing. But what if you don't have to worry about that? You can just wait now! Server addEventHandler("onPlayerJoin", root, function () callClientAwait(source, "testCallClientAwait") end) Client function testCallClientAwait () outputChatBox("Yes this works!") end Security Worried about security issues? Remote calls for C++/MTA functions have been blocked. There is a whitelist feature included, if enabled your code can only remote-call whitelisted functions. (this is disabled by default) Read the docs for that. Here and here
- 4 replies
-
- 10
-
I locked it for you as requested.
-
local pickup[k] = createPickup( i[1], i[2], i[3], i[4], i[5], 0) You shouldn't use the local keyword, when you are not declaring a local variable.
-
@slapz0r hmm try without autoincrement CREATE TABLE IF NOT exists `housing` (`houseID` INT NOT NULL PRIMARY KEY) or maybe this works as well: CREATE TABLE if not exists `housing` ( `houseID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT )
-
@slapz0r Afaik that is the mysql syntax. I can't remember what the syntax was for sql, but probably something like this: https://www.queryexamples.com/sql/table/sql-create-table-with-primary-key-foreign-key-and-autoincrement/ Maybe: `houseID` INT PRIMARY KEY AUTOINCREMENT Or `houseID` AUTOINCREMENT PRIMARY KEY Hmmm, probably trying till you get it right. Still confusing all those different syntaxes... And if that doesn't work out, then you can also manually fix it with a viewer: https://sqlitebrowser.org/ (Stop the resource)
-
@xFabel There is more spam than topic left. I didn't mind to help you, but it seems like you think that your time is much more important than everybody else. So you give me no other option than to lock the topic... which is really a shame.
- 2 replies
-
- shader circle + antialas
- shader
-
(and 1 more)
Tagged with:
-
only on initialization, it is a good idea to send the whole table. Else it is just a waste of data including the risks of de-synchronize the data.
-
This section is for making your server a website. But yes you can also do it locally. Which starts with: local webBrowser = createBrowser(screenWidth, screenHeight, true, false) element createBrowser ( int width, int height, bool isLocal [, bool transparent = false ] ) URL root http://mta/local/ ALL the assets in the meta.xml: <file src="index.html" /> <file src="js/main.js" /> <file src="css/reset.css" /> <file src="css/master.css" /> html, css, js, images, etc.
-
Did you read the wiki page I send you? It explains you very well which URL you have to use. Heading #Specifying_a_file_in_the_meta https://wiki.multitheftauto.com/wiki/Resource_Web_Access#Specifying_a_file_in_the_meta Try it and if it doesn't work, come back with the updated code.
-
You are hosting it at your server, but you are trying to access it with an url for local hosting. For server hosting https://wiki.multitheftauto.com/wiki/Resource_Web_Access
-
Did you send over the file to clientside? <file /> A client-side file. Generally these are images, .txd, .col, .dff or .xml files. They'll be downloaded by clients when the resources is started (or on join) src: client-side file name (can be path too eg. "images/image.png") download: Whether or not to be sent to the client automatically (optional). Default is "true". Using "false" will mean they are not sent on resource start but could later be used by downloadFile. Or did you let the server host it? <html /> src: The filename for the HTTP file (can be a path) default: The html file is one that is shown by default when visiting /resourceName/ on the server. Only one html can be default, the rest are ignored. (true/false) raw: The html file is not parsed by the Lua interpreter and is treated as binary data. Must be used for binary files (images mainly) (true/false) https://wiki.multitheftauto.com/wiki/Meta.xml You must first do one of those two, to make it accessible.
-
@alexaxel705 English only in this section. 2 languages with the same text and one of them English? Sure, that is acceptable.
-
@[M]Province Formatting: outputChatBox("help yourself please")
-
Yes, when that number exceeds around 20. 20 = overall 2 updates per second. Which is not good, because it is not only 2 updates, it is: 2 X playerCount = impact on the server network. 100 = bad 300 = really bad 1000 = I am not joining your server for sure
-
@[M]Province > https://forum.multitheftauto.com/forum/117-скриптинг/ Moved topic.
-
local eventList = {} setTimer( function () if next(eventList) then outputDebugString(inspect(eventList)) eventList = {} end end, 10000, 0 ) addDebugHook( "preEvent", function ( sourceResource, eventName, eventSource, eventClient, luaFilename, luaLineNumber, ... ) local args = { ... } local i = "resource: " .. (sourceResource and getResourceName(sourceResource) or "[unkown] ") .. ", key: " .. tostring(args[1]) .. ", file: " .. tostring(luaFilename) .. ", line-number: " .. tostring(luaLineNumber) eventList[i] = (eventList[i] and eventList[i] + 1) or 1 end, {"onElementDataChange"} ) If this code works, then you can start fixing things. @juaosilv
-
Why? ? The error was only about 1 line of code.
-
["nil/onElementDataChange/elem:vehicle[Police LV]0x11e5"] = 389, ["nil/onElementDataChange/elem:vehicle[Towtruck]0x123a"] = 400, ["nil/onElementDataChange/elem:vehicle[Hustler]0x11e0"] = 310, ["nil/onElementDataChange/elem:vehicle[Police LV]0x11e5"] = 524, ["nil/onElementDataChange/elem:vehicle[Towtruck]0x123a"] = 317, ["nil/onElementDataChange/elem:vehicle[Police LV]0x11e5"] = 956, It looks like it is related to vehicles. Maybe a fuel resource? (Maybe stop that resource and see if it makes any difference) I am currently very busy, so will help later further today.