-
Posts
6,069 -
Joined
-
Last visited
-
Days Won
210
Posts posted by IIYAMA
-
-
2 hours ago, SinaAmp said:
I get element data from client side which is static for setting up timer
Isn't that cause of the problem?
Probably, can you show me that clientside part just to be sure?
-
3 hours ago, SinaAmp said:
sorry @IIYAMA but i still got dbExec failed; (1205) Lock wait timeout exceeded; try restarting transaction
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)
-
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
-
2 hours ago, Cronoss said:
I don't know if this is the right topic for a question like this but I don't know where to ask
I want to know what's the difference between saving the data in internal.db (simple script)
function guardarDinero() cuenta = getPlayerAccount(source) setAccountData(cuenta, "dinero", tostring (getPlayerMoney(source))) end addEventHandler("onPlayerQuit", getRootElement(), guardarDinero)
And creating a ".db" archive, using a script like this (script every command for the database):
local db = dbConnect("sqlite", "test.db") function addDATA(sourcePlayer) dbExec (db, "INSERT INTO info (id_player, id_vehicle, color) VALUES(1, 401, ?", color) -------etc
Because I've seen people telling other users that should learn about sql, and that kind of stuff
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.
-
1
-
-
53 minutes ago, SinaAmp said:
nothing changed still got that error
my issue is server freeze but i cant understand whats going on in dbpool
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)
-
2
-
-
12 hours ago, Neto Silva said:
I think it could be is that getHashCodeTwo is returning
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
-
1
-
-
5 hours ago, long_gone said:
float GetCoord(float a) { float base = RsGlobal.maximumWidth > RsGlobal.maximumHeight ? static_cast<float>(RsGlobal.maximumHeight) : static_cast<float>(RsGlobal.maximumWidth); return static_cast<float>(static_cast<int>(a * base / gScreenResolution)); }
i pass 0/0/ and 2084 / 128 for vertices
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.
-
2
-
-
15 hours ago, long_gone said:
(It's working perfectly in fullscreen mode)
With what resolution (math) do you draw your image?
-
13 minutes ago, Cronoss said:
"player's vision" change
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
-
14 minutes ago, SinaAmp said:
@IIYAMA Thank you
I mean database table
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.-
1
-
-
27 minutes ago, SinaAmp said:
@IIYAMA do you know is it better to create table for every resource Separately or set most of the data's in one table for performance?
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.
-
2
-
-
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
-
3
-
-
If the problem is indeed with the size of the marker as Burak said.
And you want to keep your smaller marker,
Spoilerthe following code might help with improving hit registration.
addEventHandler("onColShapeHit", getElementColShape (marker1), skin159)
https://wiki.multitheftauto.com/wiki/GetElementColShape
Else create a new colShape on top of it and use that one for the event:
-
1
-
-
4 minutes ago, SinaAmp said:
thank you
also i have another issue
i dont know why my code doesent work and show any error in debugscript
marker1 = createMarker(163.017578125, -89.5458984375, 1000.8046875,"cylinder",1.0) setElementInterior(marker1, 18) marker2 = createMarker(159.3408203125, -89.36328125, 1000.8046875,"cylinder",1.0) setElementInterior(marker2, 18) marker3 = createMarker(153.2841796875, -78.6357421875, 1000.8046875,"cylinder",1.0) setElementInterior(marker3, 18) function skin159 (theplayer) if getPlayerMoney(theplayer) >= 4999 then takePlayerMoney(theplayer, 5000) outputChatBox("pooletkamshod") end end addEventHandler("onMarkerHit", marker1, skin159)
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.)
-
3
-
-
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.
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)
-
2
-
-
19 minutes ago, Dzsozi (h03) said:
But for sure I have to rework it on client side to make the checks, right? Would it be more efficient?
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
-
1
-
-
7 minutes ago, Dzsozi (h03) said:
So, should I implement your servertimesync resource to my core resources, and make the light checks on client side, using exported servertimesync function?
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.
-
6 hours ago, Dzsozi (h03) said:
Also, I am curious whether I should create this server side or client side. For the first time I did it on client side, but it went out of sync even more and quicker.
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)
-
It is weird that the default argument is set to true for ponds pools though.
Maybe it is not real water, just drawn. As the note on wiki suggest (window is missing though).
-
1 hour ago, ScripterForense said:
Thanks More how can I launch them where the camera is looking?
Please stick with Portuguese, your topic has already been moved to your section, because you couldn't decide which language to use.
-
- Popular Post
- Popular Post
Airplane
This resource adds ambient aircraft to your MTA map. As many as you want, as long as the MTA element stream engine likes it. The aircraft models can be modified in config_s.lua.
The resource was pre-mentioned in the Server time sync resource, because it is was an example resource which made use of serverside time. (And still makes use of) But by posting updates there for a different resource is a bit confusing. It is beyond a test resource now.
Note: you still need to download the server time sync resource for this resource to work. You will be given an option to download server time sync resource, when you the download the resource airplane.The resource doesn't only creates planes, but also helicopters. Which is confusing I know, since the resource name is 'airplane'. But it was already too late for that without losing my version archive.
Version 1.2.0 / 1.1.1 video's
Admin settings
- Quantity aircraft
-
Developermode
- Displaying the airplanes and other useful information.
-
Demomode
- true - Let the resource create the aircraft
- false - Fill in your own aircraft list manually in file: config_s.lua
How the aircraft is adjusted according to the GTA map. The blue crosses are used to display the max ground height of that specific area(200x200). You see that the crosses are placed higher near trees and buildings. The resource will adjust the aircraft height according to this data.
This view is visible when development mode is active and some adjustments in the config_s.lua for the ground height data.
Dataset for the aircraft height is available here: https://wiki.multitheftauto.com/wiki/Dataset-map-heightPro's:
- Low CPU usage after initialization.
- No network usage after initialization. Only the dependency server time sync will use network usage after initialization.
- Not that many lines of code for you have to scan through, if you want to modify the resource.
- Simple to implement.
- If you find a bug, I will be here.
Con's
- No AI implementation. Brain-dead AI.
-
The 'time based driven (animations)' concept is used, not everybody is familiar with that concept. That makes it harder to edit. It basically means that the aircraft animations are unstoppable, since time doesn't stop either.
- Pro: Which nearly nullifies the need of constant network usage between the server and the client.
- All aircraft are indestructible (even if not set to damage proof). (Can also be a pro) But I might add something in the future to counter that... but I first must figure out how that is suppose to work.
- Does not work outside of the GTA map.
Download link:
Resource Airplane
Other downloads:
-
8
-
@TiTawNdo you need more information on this subject? (Or maybe an alternative to XML, depending on the context of the data)
-
@nogisza friendly reminder that your question has been answered.
-
On 11/01/2022 at 11:32, nogisz said:
I saw in other scripts they do this and it just works but in my case it outputs "false". Could anybody help me with this problem?
See this meta.xml tag.
Quote-
<sync_map_element_data /> Controls whether map element data such as "PosX" and "DoubleSided" are transferred to the client. This data is usually not required by most gamemodes or resources. (Map Editor and Interiors require this to be not set to false to work). When set in a gamemode meta.xml, the setting will apply to all maps loaded by that resource.
- false: Disable transfer of map element data for all resources. This can reduce map download times considerably.
- true: Enable transfer of map element data for all resources. (If false and true are set in different resources, true will have priority and all resources will transfer map element data)
https://wiki.multitheftauto.com/wiki/Meta.xml
Set it to true in the gamemode which you are using:
<sync_map_element_data>true</sync_map_element_data>
-
<sync_map_element_data /> Controls whether map element data such as "PosX" and "DoubleSided" are transferred to the client. This data is usually not required by most gamemodes or resources. (Map Editor and Interiors require this to be not set to false to work). When set in a gamemode meta.xml, the setting will apply to all maps loaded by that resource.
How to get the number of players from the server?
in Scripting
Posted
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
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
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:
Under default: