Results 1 to 9 of 9

Thread: Some latest updates

  1. #1
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    208
    Thanks
    58
    Thanked 180 Times in 93 Posts

    Some latest updates

    You may notice some updates in my git lately, so gonna explain some of them.

    You can now choose between my and orignal MySQL variant:

    Click image for larger version. 

Name:	?????? ?????? (1).png 
Views:	114 
Size:	32.7 KB 
ID:	1373

    You can compile without MySQL too, you proably don't want my MySQL variant as it 100% not comptabile with the original one.

    So, what is VoroN's MySQL variant and how do i use it?

    I decided to rewrite MySQL because the original one didn't work properly for me anymore, with some lates mysql server updates, it statred leak the memory.
    This variant is only suitable (for now atleast) for local MySQL sessions and not good for remote ones. It's based on native function callbacks and args and doesn't requeire izno's wrapper.
    Also it has only 2 connections (synchronous and async). In case your really want to use it, here is how:

    First, init your connections in your gametype.gsc:
    PHP Code:
    mysql_initialize("localhost""root""yourpass""yourdb"3306);
    async_mysql_initialize("localhost""root""yourpass""yourdb"3306); 
    You can init only sync/async too, ifor example if you plan to use async only.

    That's all, you don't have to do anything anymore. now you can use your queries:

    I'd recommend to pick a little wrapper i made to simplify the queries.

    Here it is:

    PHP Code:
    getRows(result)
    {
        
    rowcount mysql_num_rows(result);

        
    fields = [];

        
    field mysql_fetch_field(result);

        while (
    isDefined(field))
        {
            
    fields[fields.size] = field;
            
    field mysql_fetch_field(result);
        }

        
    rows = [];

        for (
    0rowcounti++)
        {
            
    row mysql_fetch_row(result);
            
    rows[rows.size] = [];

            for(
    0fields.sizej++)
                
    rows[rows.size 1][j] = row[j];
        }

        return 
    rows;
    }

    getAsyncRows(task)
    {
        
    rowcount async_mysql_num_rows(task);

        
    fields = [];

        
    field async_mysql_fetch_field(task);

        while (
    isDefined(field))
        {
            
    fields[fields.size] = field;
            
    field async_mysql_fetch_field(task);
        }

        
    rows = [];

        for (
    0rowcounti++)
        {
            
    row async_mysql_fetch_row(task);
            
    rows[rows.size] = [];

            for(
    0fields.sizej++)
                
    rows[rows.size 1][j] = row[j];
        }

        return 
    rows;
    }

    fetchSingleRowArray(result)
    {
        if (!
    isDefined(result))
            return [];

        
    result mysql_store_result(result);
        
    row mysql_fetch_row(result);
        
    mysql_free_result(result);

        if (
    isDefined(row))
            return 
    row;
        else
            return [];
    }

    fetchAsyncSingleRowArray(task)
    {
        if (!
    isDefined(task))
            return [];

        
    row async_mysql_fetch_row(task);
        
    async_mysql_free_task(task);

        if (
    isDefined(row))
            return 
    row;
        else
            return [];
    }

    fetchRowArray(result)
    {
        if (!
    isDefined(result))
            return [];

        
    result mysql_store_result(result);
        
    rows getRows(result);
        
    mysql_free_result(result);

        if (
    isDefined(rows))
            return 
    rows;
        else
            return [];
    }

    fetchAsyncRowArray(task)
    {
        if (!
    isDefined(task))
            return [];

        
    rows getAsyncRows(task);
        
    async_mysql_free_task(task);

        if (
    isDefined(rows))
            return 
    rows;
        else
            return [];

    If you know that your query will be a single row e.g row[0] only, or you only need to pick that one, then you can use singlerowarray.

    How to use synchronous queries:

    PHP Code:
    result mysql_query("SELECT NOW()"); // query
    row maps\mp\gametypes\_mysql::fetchSingleRowArray(result); // get rows using wrapper, single row only
    printf("Result: %\n"row[0]) // print the result 
    Don't forget that heavy synchronous queries may lag the server, use async ones for those.

    How to use async queries:

    PHP Code:
    async_mysql_create_query("SELECT NOW()", ::callbackFunc"bla");

    callbackFunc(taskarg)
    {
        
    row novoselscripts\_mysql::fetchAsyncSingleRowArray(task); // get rows using wrapper, single row only
        
    printf("Result: %\n"row[0]) // print the result

    You can pass only one argument to the callback function, you don't have to pass a dummy arg if there are none though, also if there are no callback
    e.g you only want to save something to your db:

    PHP Code:
    async_mysql_create_query("SELECT NOW()"); 
    That will work, that result will be automatically freed. You can also use
    PHP Code:
    async_mysql_create_query_nosave 
    but there are really no difference.

    Also, passing arguments can only be int, float, vector and string, you can't pass arrays or entities.
    For entities, if you want to use 'self' inside the callback function, use:

    PHP Code:
     self async_mysql_create_entity_query("SELECT NOW()", ::callbackFunc"bla"); 
    That's all of the basics, should be pretty simple. Now some further changes:

    lookAtKiller() function:

    Still quite experimental, an attempt to create a tf2 like killer camera, but not very successful.
    Join DeathRun.. if you are interested to see how it looks/works.

    Force client downloads:

    Enabled by default, clients with cl_allowDownload 0 will be switched to 1 on connect.

    Disable rcon access completely:

    Disabled by default, set sv_allowRcon to 0 for that.

    Bult in va() fix:

    In case you want to use original/unpatched binary.

    Removed additional iwd verification:

    This is still questionable, but looks like there is some possibility to abuse that and make the server lag, but i'm not 100% sure.
    This was also removed in cod4x. It still DOES NOT allow clients with modified/missing iwds' so idk. Quite experimental for now.

    Get/set weapon cookcable:

    Switch your grenades cookable/uncookable on the fly.

    Tell me if you have any bugs/issues with the stuff above.
    sudo apt-get rekt

  2. The Following 5 Users Say Thank You to voron00 For This Useful Post:

    kubislav23 (24th October 2017),kung foo man (23rd October 2017),Lonsofore (27th October 2017),Ni3ls (23rd October 2017),Whiskas (23rd October 2017)

  3. #2
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    81
    Thanks
    64
    Thanked 19 Times in 16 Posts
    Could you show us an example of weapon cookable? Should it be executed on weapon obj?

    Thanks for your work

  4. #3
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    208
    Thanks
    58
    Thanked 180 Times in 93 Posts
    Quote Originally Posted by Whiskas View Post
    Could you show us an example of weapon cookable? Should it be executed on weapon obj?

    Thanks for your work
    It's just another weaponfunction offset from: https://killtube.org/showthread.php?...oveSpeedScale)

    But here's my code:

    PHP Code:
    loadWeaponFunctions()
    {
        
    loadedweapons getLoadedWeapons();

        for (
    0loadedweapons.sizei++)
        {
            
    assert(48); // bugs out after approximately 48 (izno)

            
    if (isDefined(level.weapons[loadedweapons[i]]))
                
    level.weapons[loadedweapons[i]].id i// i = weapon index
        
    }
    }

    getWeaponId(weapon)
    {
        if (
    isDefined(level.weapons[weapon]) && isDefined(level.weapons[weapon].id))
            return 
    level.weapons[weapon].id;
        else
            return -
    1;
    }

    weaponMaxAmmo(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponmaxammo(id);
    }

    weaponClipSize(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponclipsize(id);
    }

    weaponDamage(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweapondamage(id);
    }

    weaponMeleeDamage(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponmeleedamage(id);
    }

    weaponFireTime(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponfiretime(id);
    }

    weaponMeleeTime(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponmeleetime(id);
    }

    weaponReloadTime(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponreloadtime(id);
    }

    weaponReloadEmptyTime(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponreloademptytime(id);
    }

    weaponHitLocMultiplier(weaponhitloc)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponhitlocmultiplier(idhitloc);
    }

    setWepDamage(weapondmg)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweapondamage(iddmg);
    }

    setWepMeleeDamage(weapondmg)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweaponmeleedamage(iddmg);
    }

    setWepFireTime(weapontime)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweaponfiretime(idtime);
    }

    setWepMeleeTime(weapontime)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweaponmeleetime(idtime);
    }

    setWepReloadTime(weapontime)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweaponreloadtime(idtime);
    }

    setWepReloadEmptyTime(weapontime)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweaponreloademptytime(idtime);
    }

    setWepHitLocMultiplier(weaponhitlocmultiplier)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweaponhitlocmultiplier(idhitlocfloat(multiplier));

    There are no cookable since im not using it, but should be quite easy to copy-paste.

    PHP Code:
    weaponCookable(weapon)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    getweaponcookable(id);
    }

    setWepCookable(weaponcookable)
    {
        
    id getWeaponId(weapon);

        if (
    id == -1)
            return 
    0;

        return 
    setweaponcookable(idcookable);

    sudo apt-get rekt

  5. The Following User Says Thank You to voron00 For This Useful Post:

    Whiskas (23rd October 2017)

  6. #4
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    81
    Thanks
    64
    Thanked 19 Times in 16 Posts
    Wow, thanks.

  7. #5
    Brigadier General
    Join Date
    Dec 2012
    Posts
    964
    Thanks
    432
    Thanked 163 Times in 125 Posts
    But this will apply to everybody with that specific weapon right? (all mp44's). It's not possible to apply this only to the weapon I'm holding (just my mp44)?

  8. #6
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    208
    Thanks
    58
    Thanked 180 Times in 93 Posts
    Quote Originally Posted by Ni3ls View Post
    But this will apply to everybody with that specific weapon right? (all mp44's). It's not possible to apply this only to the weapon I'm holding (just my mp44)?
    Ye, not possible.
    sudo apt-get rekt

  9. #7
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    208
    Thanks
    58
    Thanked 180 Times in 93 Posts
    Pushed some experimental stuff to dev branch, might wanna test. Basicly rewrote everything for structures, added custom bot usermove stuff, bots are not lagging anymore, etc, some fixes are still coming up though.
    sudo apt-get rekt

  10. The Following 5 Users Say Thank You to voron00 For This Useful Post:

    kung foo man (16th November 2017),Lonsofore (16th November 2017),Ni3ls (16th November 2017),serthy (16th November 2017),YuriJurek (19th November 2017)

  11. #8
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    208
    Thanks
    58
    Thanked 180 Times in 93 Posts
    Pushed weapondef_t, only a few things are unknown there.
    sudo apt-get rekt

  12. #9
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    208
    Thanks
    58
    Thanked 180 Times in 93 Posts
    The changes seems stable to me, pushed to master.
    sudo apt-get rekt

  13. The Following User Says Thank You to voron00 For This Useful Post:

    kung foo man (7th December 2017)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •