-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
triggerServerEvent is unable to receive data. If you take a look at the syntax of that function, you will see that it only returns a boolean(true/false): https://wiki.multitheftauto.com/wiki/TriggerServerEvent You can make it possible using this library, but that wouldn't create a solid system. The server should be in charge of the hunger and Thirst values. What you want is the following: Server A timer (or multiple timers) This one gets the Hunger and Thirst Updates the Hunger and Thirst (-1) according to your needs. Sets the health or kills the player. triggerClientEvent (or elementdata with https://wiki.multitheftauto.com/wiki/AddElementDataSubscriber + setElementData [syncMode is "subscribe"]) Client Just updates the UI to show the player his hunger and thirst values.
-
And if you use this event? https://wiki.multitheftauto.com/wiki/OnClientSoundFinishedDownload
-
At the side the triggerClient/ServerEvent is locaties. The debug console only shows you errors, warnings by default. If you want more information than that. You will have to add debug lines. (iprint) Those lines will show up as soon as the code execute them. If they are not shown up while they should, that means that there is a mistake before them. If you keep moving them forwards/backwards, you will eventually find the location of the problem. Between showing up and not showing up, is the problem. iprint("A") if false then --[[ <<<< B not is showing up? And A is? Then here is the problem ]] iprint("B") end They are also handy to debug variables, which are often containing incorrect values when there is a bug.
-
Wiki: except the transmission rate of the data contained in the arguments can be limited and other network traffic is not blocked while the data is being transferred. It does 2 things: - It can be limited - It does not block while transferring. If you increase the bandwidth to max 100 MB: 100*1024*1024 You basically undo the first thing. That is fine if you only send a little bit of data. What might lag for some players is the head movement. Which is caused by the non-block transfer thing. - If the player his download is not fast enough, there will be a delay. But there will be no/little lag created for other things, like remote-player movement. (Remote-players = other player elements than yourself in your game) - And if the player download is not fast enough and can't keep up. It will stack all those latent events in a queue, which only gets longer. If you are going to use this function, then I recommend to use getLatentEventStatus for each player to check if the player receives the data. If yes, then send the next update.
-
This update rate is fine, unless you have about/more than ~40 players in your server. Fix for that: Client (set Thirst with sync disabled) Thirst = Thirst - 1 setElementData(localPlayer, "Thirst", Thirst, false) + https://wiki.multitheftauto.com/wiki/TriggerServerEvent (https://wiki.multitheftauto.com/wiki/TriggerLatentServerEvent) + Server (set Thirst with sync disabled) setElementData(client, "Thirst", Thirst, false)
-
It can full fill that part if you want, since MTA has a build in webserver, but you might want to add some serverside stuff for your website as middleware for anti-abuse performance reasons. Anyway I leave an example below for those that are interested. Resource name: webserver Filename: meta.xml <meta> <info version="1.0.0" name="webserver" type="script" description="Web server info" /> <html src="playerCount.html" /> <script src="main_s.lua" type="server" /> <export function="getPlayerCount" http="true" /> </meta> Method: 1 Filename: playerCount.html <* httpWrite( #getElementsByType ( "player" ) ) *> URL: http://127.0.0.1:22005/webserver/playerCount.html Returns: <what ever you want> Method: 2 Filename: main_s.lua function getPlayerCount() return #getElementsByType( "player" ) end URL: http://127.0.0.1:22005/webserver/call/getPlayerCount Returns: JSON Skip login? (it is not recommended to skip for production, use middleware instead for the credentials) Add: <right name="resource.webserver.http" access="true"></right> Under default: <acl name="Default"> <right name="resource.webserver.http" access="true"></right>
-
Probably, can you show me that clientside part just to be sure?
-
You can increase the lock wait timeout: https://stackoverflow.com/questions/6000336/how-to-debug-lock-wait-timeout-exceeded-on-mysql There are multiple reasons why this error can occur, so maybe that will not be enough. Also consider to index your most used columns, like Account: https://www.w3resource.com/mysql/creating-table-advance/create-index.php This will speed up your search queries. But de-increase the speed of removal queries. (which you probably only use when removing accounts)
-
@Vestorn There is a build in method as far as I can remember. But never used it myself. (Maybe somebody else knows) But this is the custom(isable) resource method you can use: https://wiki.multitheftauto.com/wiki/Resource_Web_Access https://wiki.multitheftauto.com/wiki/HttpWrite
-
Account data is a database interface and manager for ONLY account-bounded-data. dbConnect + all other db functions, allows you to create your own database interface and manager. This gives you a lot of freedom, but it also means that you have to write a lot yourself.
-
I updated Burak his example. But I have not refactored the variable names. function AccDatacallback(AccData, player, account, AccName) local result = dbPoll( AccData, 0 ) if AccData and #AccData > 0 then return end local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)", ID, AccName) end function getpaccount (_,account) local AccName = getAccountName(account) setPlayerName(source,tostring(AccName)) dbQuery(AccDatacallback, {source, account, AccName}, db, "SELECT * FROM stats WHERE Account=? LIMIT 1", AccName) end addEventHandler("onPlayerLogin",root, getpaccount) The function was called instead of provided as function. local AccData = dbQuery(AccDatacallback(), db,"SELECT * FROM stats WHERE Account=? LIMIT 1", AccName) This is now moved inside of the call back function. Since the data is not immediately available. if(AccData) then if(#AccData > 0) then return end end local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)",ID, AccName)
-
That might be indeed the case. That 5000ms timer is a bit hacky in my opinion. Just listen in the resource (that has the hashCheck function) to the event: "onClientReceivePermissions" (you can cross listen to events of another resources, as long as the element you are listen to is a parent or the source) The predefined variables of that event will be enough to figure out which resource is ready and which is not. See list of predefined variables: https://wiki.multitheftauto.com/wiki/AddEventHandler
-
It might be a ppi issue. (I am not a shader expert) but let me speculate a bit. Afaik: When playing with border less settings and window mode, the same resolution is returned on https://wiki.multitheftauto.com/wiki/GuiGetScreenSize Not sure if you used that one to create your render target. This might put a difference between the resolution the shader is placing the texture on the screen and the resolution delivered by the texture. If this situation is matching yours, what if you do not scale the texture? But placing it with the exact size. Either by the texture size or by the pixels the shader is about to draw. Anyway, those artifacts are most of the time caused by some sort of scaling.
-
With what resolution (math) do you draw your image?
-
With: https://wiki.multitheftauto.com/wiki/SetCameraMatrix or https://wiki.multitheftauto.com/wiki/GetCamera + https://wiki.multitheftauto.com/wiki/SetElementPosition (https://wiki.multitheftauto.com/wiki/SetElementRotation) See also this useful function for getting the gender of a current skin/model or ped/player. https://wiki.multitheftauto.com/wiki/GetPedGender
-
If you really want to improve performance, you should make use of callbacks. https://wiki.multitheftauto.com/wiki/DbQuery See 3e and 4e example. If not used, your MTA scripts will stop doing anything until there is response from the database. The database and MTA are running on different threads. Those shouldn't wait for each other. If the database thread takes too long, it will create lag in your MTA server, because the server is simply unable to process things.
-
Database table or Lua table? In case of a database, the less data is in a single table, the faster it can find items. But when an index is applied. You probably wouldn't notice the difference for while.
-
@Burak5312 @SinaAmp local SkinData = dbPoll(dbQuery(db,"SELECT * FROM SkinShop WHERE Account=?",accName), -1) if #SkinData > 0 then end The reason why this #SkinData > 0 is used, is because the database query is returning always a table on success. This table contains all results of that query. The # is used for get the length/item count of that table. For example if you have 2 accounts with the same account name. The SkinData table contains 2 items. #SkinData -- results in the value 2. You can add a safety/optimization keyword inside of the query to always return 1 items, which is LIMIT <max items to return>. But not having that inside of the code is not game breaking, but can reduce query execution time. Yet that does not change that SkinData will hold a table value on success. SELECT * FROM SkinShop WHERE Account=? LIMIT 1
-
If the problem is indeed with the size of the marker as Burak said. And you want to keep your smaller marker,
-
Does your code only take money when entering the marker1? And you want all markers to do the same thing? If yes, take a look at this tutorial: (If that is not the case, please be a bit more specific.)
-
inside = createMarker( -1883.283203125, 865.4765625, 35.171875,56.0,"arrow",4.0,0,255,255) -- Removed local inhouse = createMarker( -1883.283203125, 865.4765625, 35.171875,56.0,"arrow",4.0,0,255,255) -- Moved to here. function createmymarker() local inhouse = createMarker( -1883.283203125, 865.4765625, 35.171875,56.0,"arrow",4.0,0,255,255) -- Moved from here. setElementPosition(theplayer,-1883.283203125, 865.4765625, 35.171875) setElementInterior(theplayer, 18) end addEventHandler("onMarkerHit", inhouse, createmymarker) -- Now is the inhouse variable available here and the warning shouldn't show up any more. @SinaAmp local inhouse = createMarker( -1883.283203125, 865.4765625, 35.171875,56.0,"arrow",4.0,0,255,255) function createmymarker() setElementPosition(theplayer,-1883.283203125, 865.4765625, 35.171875) setElementInterior(theplayer, 18) end addEventHandler("onMarkerHit", inhouse, createmymarker)
-
For the overall synchronisation experience of your server, yes. Take a look at your network usage with and without the blink resource running. You know how to do that right? /shownetstat https://wiki.multitheftauto.com/wiki/Client_Commands#shownetstat
-
You can do that, but you can also keep it a separated resource and include it in your core meta.xml. That way you can use it easier in multiple application-suited-resources.
-
Doing it serverside would be a waste of your network usage. How about you use server time to solve your problem? local duration = 1000 local status = (serverTime % duration) > (duration / 2)
