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 MenuQuote from: vitovc on Aug 22, 2023, 07:09 PMI have one confusionQuote 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.
Quote from: vitovc on Aug 22, 2023, 07:18 AMMake sure Spectator himself (player who spec) is having same world as spectator's targetIs there any way onPlayerSpectate can wait until the player ( whom i am spectating ) world set to 1 ?
Quote from: Mohamed Boubekri on Aug 19, 2023, 06:26 PMCreate it by yourself, i already give you an idea.I'll surely use my hands with no problem, while I already have function onPlayerSpectate( player, target )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.
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.
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;
}
}
}
}
}
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)
}
I understand it is occuring when 3-4 players join the server
Yes only when they keep join in a row 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 );
}
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.Well maybe this error was unexpected, i mean now it doesn't show any bug and server showed "segmentation fault" and turned off
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 thisforeach(s in str)stdout.writen(s, 'c');
in line 190.
Quote from: habi on Aug 15, 2023, 05:27 PMReplace %s by %d second time: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)local funcname = format("%s_%d_func", ipaddr, GetTickCount() );
local sockname = format("%s_%d_sock", ipaddr, GetTickCount() );
local requestname = format("%s_%d_rqst", ipaddr, GetTickCount() );
throw "JSON Syntax Error near `" + near + "`";
/**
* 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;
}
I was yesterday making a curl module