Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Nihongo^

#2
Hi, i just tried this function to reload my script https://forum.vc-mp.org/index.php?topic=9251.msg53101#msg53101

but the problem is its wont save the data after the player rejoin
In this pic i killed my self after reload the script but it didn't save the data "death" in the database
 


P.S I only add onPlayerCommand, getOnlinePlayers,getPlayer(object)  and ignore the rest

"In main.nut"

#3
Hi how do i make limit for pressing "J" button ?

like player can Press only 5 or 4 times for jump or boost


function onKeyDown( player, oldKeys, newKeys )
{
  if( key == J )
    {
      if( player.Vehicle )
      {
        local vPos   = player.Vehicle.Pos;
        vPos.z = vPos.z * 1.5;
      }
    return;
    }
  }
#4
General Discussion / Re: Guys, chatgpt is fun
Aug 23, 2023, 06:41 PM
Yeh but this chat gpt not always gives your 100% correct its only good for examples
#5
Quote from: vitovc on Aug 22, 2023, 07:09 PM
Quote from: Nihongo^ on Aug 22, 2023, 07:51 AMIs there any way onPlayerSpectate can wait until the player ( whom i am spectating ) world set to 1 ?
Events are for not to wait. You can write "timer" yourself to delay spectate act when conditions will be right.
I have one confusion
we can put the player in spec mode with player.SpectateTarget = plr;
What about the "plr" ? ( which goes die )
When he spawns his world change player.world = 2, so how do i tell the script i was spec him

sorry for the such noob question 
#6
Quote from: vitovc on Aug 22, 2023, 07:18 AMMake sure Spectator himself (player who spec) is having same world as spectator's target
Is there any way onPlayerSpectate can wait until the player ( whom i am spectating ) world set to 1 ?
#7
Quote from: Mohamed Boubekri on Aug 19, 2023, 06:26 PMCreate it by yourself, i already give you an idea.

Quote from: Mohamed Boubekri on Aug 19, 2023, 05:49 PM-Try to detect if player is on spectating mode, i mean like a status, then add that line:
Example: if ( status[player.ID].Spec == true ) return player.SpectateTarget = false;
And again try to define the target: player.SpectateTarget = target;

-Also you can hold the target in array, then try to refresh the spectate system after player world changed.

I'll surely use my hands with no problem, while I already have function onPlayerSpectate( player, target )
but it said the world doesn't exist, so just a simple question is that why it saying that world not exist
when the target is already in the spectate
#8
wait,
if (!target) return;
return it and the function won't work -_- i really want a spec system to work when plr world is 2 or wait till plr wait get 1
#9
Quote from: Mohamed Boubekri on Aug 19, 2023, 05:49 PM-Try to detect if player is on spectating mode, i mean like a status, then add that line:
Example: if ( status[player.ID].Spec == true ) return player.SpectateTarget = false;
And again try to define the target: player.SpectateTarget = target;

-Also you can hold the target in array, then try to refresh the spectate system after player world changed.

One of my friend help me with this but it gives error by saying "world doesn't exists"

if(target.World == 1) return true;

function onPlayerSpectate( player, target )
{

if(player.IsSpawned == false || player.World == 1)
{
if(target.World == 1) return true;

else{

for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p.IsSpawned == true && p.World == 1)
{
target = p.ID;
}
}

}
}

}
#10
i have problem in /spec
when player died the spec system stopped working its due to player.world = 2
i used plr.Word =2 for anti spawn killing

so when player spawn spec stop working

how do i make it work again ? as the player.wolrd = 2 take 3 seconds to send the world 1
so i want to it work again without waiting for the plr to set world 1
function AntiSpawn(player)
{
player.World = 2;

NewTimer( "AntiSpawnOff", 5000, 1, player.ID );
Announce( "~o~ SPAWN PROTECTION IS ON !" , player);
player.CanAttack = false;
}

function AntiSpawnOff( player )
{
local plr = FindPlayer(player);
if(plr) {
plr.World = 1;
Announce( "~G~ SPAWN PROTECTION IS OFF !" ,plr );
plr.CanAttack = true;
}
}
function onPlayerSpawn( player )
{
AntiSpawn(player)
}
#11
I understand it is occuring when 3-4 players join the serverYes only when they keep join in a row
here's my function
function onPlayerJoin( player )
{
status[ player.ID ] = Playerstats();
chat[player.ID] = ChatClass()
CheckProxy(player.IP);
CheckTempBan(player);
CheckBan(player.ID);
local nickcheck = IsNum(player.Name)
    if (nickcheck) {
       ServerMessage("[#FF0000]** Auto Kick[#FFFFFF] [ " +player.Name+" ][#FF0000] Reason: [#FFFFFF][Invalid nick numbers not allowed Connect with proper nick ]");
       EchoMessage("** Auto Kick [ " +player.Name+" ] Reason: [ Invalid nick numbers not allowed Connect with proper nick ]");
        KickPlayer( player );
    }
  player.Angle = -12.90654;
 
AddAlias( player );
local country = geoip_country_name_by_addr(player.IP);
if (country != null) // the plugin returned a meaningful result
ServerMessage("[#FFFFFF][ " +player.Name+" ] is connecting from [ " + country + " ] ["+ geoip_country_code_by_addr(player.IP) + "]");
EchoMessage("* [ " + player.Name + " ] is connecting from [ " + country + " ]. [" + geoip_country_code_by_addr(player.IP) + "]");

PlayerInfo(player);
GetSpawnWepData(player);

status[ player.ID ].Timeplayed = time();

   local q = QuerySQL(db, "SELECT Name,Warn FROM Warn WHERE Name='"+player.Name+"'");
if (GetSQLColumnData(q,0) == null)
{
QuerySQL(db, "INSERT INTO Warn (Name, Warn) VALUES ('"+player.Name+"', '0')");}
if (GetSQLColumnData(q,0) == player.Name)
{
QuerySQL(db, "UPDATE Warn SET Warn='0' WHERE Name='" + player.Name + "'");}
FreeSQLQuery( q );
}
#12
Quote from: habi on Aug 18, 2023, 07:36 AMi have no idea why this is caused. To investigate, we need the reply string from proxycheck.io which when passed to JsonParser is throwing the error.
Did you bypassed their daily limit or something so something different is send back as reply?
The inference is the string may not be in the format preferred by JsonParser.
Try to print the string like this
foreach(s in str)stdout.writen(s, 'c'); in line 190.
Well maybe this error was unexpected, i mean now it doesn't show any bug and server showed "segmentation fault" and turned off
its only happen when 5 6 people joined the server at a time
#13
Quote from: habi on Aug 15, 2023, 05:27 PMReplace %s by %d second time:
local funcname = format("%s_%d_func", ipaddr, GetTickCount() );
local sockname = format("%s_%d_sock", ipaddr, GetTickCount() );
local requestname = format("%s_%d_rqst", ipaddr, GetTickCount() );
Thank you, it works. For testing purposes, I repeated the same action that previously led to crashes (joining every time). As a result, it's now causing bugs at line 291 in the JSONParser.nut and then server off (segmentation fault)



Line 291
  throw "JSON Syntax Error near `" + near + "`";
Full code

/**
 * JSON Parser
 *
 * @author Mikhail Yurasov <[email protected]>
 * @package JSONParser
 * @version 1.0.1
 */

/**
 * JSON Parser
 * @package JSONParser
 */
class JSONParser {

  // should be the same for all components within JSONParser package
  static version = "1.0.1";

  /**
  * Parse JSON string into data structure
  *
  * @param {string} str
  * @param {function({string} value[, "number"|"string"])|null} converter
  * @return {*}
  */
  function parse(str, converter = null) {

    local state;
    local stack = []
    local container;
    local key;
    local value;

    // actions for string tokens
    local string = {
      go = function () {
        state = "ok";
      },
      firstokey = function () {
        key = value;
        state = "colon";
      },
      okey = function () {
        key = value;
        state = "colon";
      },
      ovalue = function () {
        value = this._convert(value, "string", converter);
        state = "ocomma";
      }.bindenv(this),
      firstavalue = function () {
        value = this._convert(value, "string", converter);
        state = "acomma";
      }.bindenv(this),
      avalue = function () {
        value = this._convert(value, "string", converter);
        state = "acomma";
      }.bindenv(this)
    };

    // the actions for number tokens
    local number = {
      go = function () {
        state = "ok";
      },
      ovalue = function () {
        value = this._convert(value, "number", converter);
        state = "ocomma";
      }.bindenv(this),
      firstavalue = function () {
        value = this._convert(value, "number", converter);
        state = "acomma";
      }.bindenv(this),
      avalue = function () {
        value = this._convert(value, "number", converter);
        state = "acomma";
      }.bindenv(this)
    };

    // action table
    // describes where the state machine will go from each given state
    local action = {

      "{": {
        go = function () {
          stack.push({state = "ok"});
          container = {};
          state = "firstokey";
        },
        ovalue = function () {
          stack.push({container = container, state = "ocomma", key = key});
          container = {};
          state = "firstokey";
        },
        firstavalue = function () {
          stack.push({container = container, state = "acomma"});
          container = {};
          state = "firstokey";
        },
        avalue = function () {
          stack.push({container = container, state = "acomma"});
          container = {};
          state = "firstokey";
        }
      },

      "}" : {
        firstokey = function () {
          local pop = stack.pop();
          value = container;
          container = ("container" in pop) ? pop.container : null;
          key = ("key" in pop) ? pop.key : null;
          state = pop.state;
        },
        ocomma = function () {
          local pop = stack.pop();
          container[key] <- value;
          value = container;
          container = ("container" in pop) ? pop.container : null;
          key = ("key" in pop) ? pop.key : null;
          state = pop.state;
        }
      },

      "[" : {
        go = function () {
          stack.push({state = "ok"});
          container = [];
          state = "firstavalue";
        },
        ovalue = function () {
          stack.push({container = container, state = "ocomma", key = key});
          container = [];
          state = "firstavalue";
        },
        firstavalue = function () {
          stack.push({container = container, state = "acomma"});
          container = [];
          state = "firstavalue";
        },
        avalue = function () {
          stack.push({container = container, state = "acomma"});
          container = [];
          state = "firstavalue";
        }
      },

      "]" : {
        firstavalue = function () {
          local pop = stack.pop();
          value = container;
          container = ("container" in pop) ? pop.container : null;
          key = ("key" in pop) ? pop.key : null;
          state = pop.state;
        },
        acomma = function () {
          local pop = stack.pop();
          container.push(value);
          value = container;
          container = ("container" in pop) ? pop.container : null;
          key = ("key" in pop) ? pop.key : null;
          state = pop.state;
        }
      },

      ":" : {
        colon = function () {
          // Check if the key already exists
          // NOTE previous code used 'if (key in container)...'
          //      but this finds table ('container') member methods too
          local err = false;
          foreach (akey, avalue in container) {
            if (akey == key) err = true;
            break
          }
          if (err) throw "Duplicate key \"" + key + "\"";
          state = "ovalue";
        }
      },

      "," : {
        ocomma = function () {
          container[key] <- value;
          state = "okey";
        },
        acomma = function () {
          container.push(value);
          state = "avalue";
        }
      },

      "true" : {
        go = function () {
          value = true;
          state = "ok";
        },
        ovalue = function () {
          value = true;
          state = "ocomma";
        },
        firstavalue = function () {
          value = true;
          state = "acomma";
        },
        avalue = function () {
          value = true;
          state = "acomma";
        }
      },

      "false" : {
        go = function () {
          value = false;
          state = "ok";
        },
        ovalue = function () {
          value = false;
          state = "ocomma";
        },
        firstavalue = function () {
          value = false;
          state = "acomma";
        },
        avalue = function () {
          value = false;
          state = "acomma";
        }
      },

      "null" : {
        go = function () {
          value = null;
          state = "ok";
        },
        ovalue = function () {
          value = null;
          state = "ocomma";
        },
        firstavalue = function () {
          value = null;
          state = "acomma";
        },
        avalue = function () {
          value = null;
          state = "acomma";
        }
      }
    };

    //

    state = "go";
    stack = [];

    // current tokenizeing position
    local start = 0;

    try {

      local
        result,
        token,
        tokenizer = _JSONTokenizer();

      while (token = tokenizer.nextToken(str, start)) {

        if ("ptfn" == token.type) {
          // punctuation/true/false/null
          action[token.value][state]();
        } else if ("number" == token.type) {
          // number
          value = token.value;
          number[state]();
        } else if ("string" == token.type) {
          // string
          value = tokenizer.unescape(token.value);
          string[state]();
        }

        start += token.length;
      }

    } catch (e) {
      state = e;
    }

    // check is the final state is not ok
    // or if there is somethign left in the str
    if (state != "ok" || regexp("[^\\s]").capture(str, start)) {
      local min = @(a, b) a < b ? a : b;
      local near = str.slice(start, min(str.len(), start + 10));
        throw "JSON Syntax Error near `" + near + "`"; <---- 291
    }

    return value;
  }

#14
Hy habi sorry it has some bugs at line 8



and here's the line 8

local funcname = format("%s_%s_func", ipaddr, GetTickCount() );
#15
I was yesterday making a curl module
Best of luck with your endeavors! also tell us what's the benefits of it ?

I've noticed your diligent work for this community, actively breathing life into it. I genuinely appreciate your dedicated efforts.

In regards to the code, I will review it shortly.