Jump to content

IIYAMA

Moderators
  • Posts

    6,069
  • Joined

  • Last visited

  • Days Won

    210

Posts posted by IIYAMA

  1. 5 hours ago, Vestorn said:

    Oh, I don't think that's it. I specifically need to get monitoring of my server on my Web site.

    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>

     

    • Like 1
  2. 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)

  3. 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.

     

     

     

     

    • Thanks 1
  4. 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)
    

     

     

     

     

    • Like 2
  5. 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

     

     

    • Thanks 1
  6. 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.

    • Like 2
  7. 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.

     

     

     

     

    • Like 1
  8. 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.

    • Like 2
  9. @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

     

     

     

     

    • Like 3
  10. If the problem is indeed with the size of the marker as Burak said.

    And you want to keep your smaller marker,

    Spoiler

     the 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:

    https://wiki.multitheftauto.com/wiki/CreateColSphere

     

    • Like 1
  11. 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.)

    • Like 3
  12. 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)

     

    • Like 2
  13. 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.

     

     

  14. 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)

     

  15. 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).

     

  16. 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.

  17. 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>

     

×
×
  • Create New...