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

Topics - EK.IceFlake

#41
I suggest you make some kind of HTTP module using Curl and Websocket++ or something. It'd be very useful for, for example, Discord integrations. The one I had (with the official squirrel module) used 2 text files for communicating with a node.js discord bot which must be run seperately.
#42
I tried the following code to test something:
SqCore.On().PlayerMessage.Connect(function (player, message)
{
    return false;
});

But it doesn't suppress the message. In the official plugin, this would successfully suppress a message:
function onPlayerMessage(player, text)
{
    return false;
}
#43
Bug Reports / Passing 'this' to Connect
May 02, 2017, 12:33 PM
I tried a script that saves a player's variables to the database when they disconnect.
UXPlayer.newmember("Login", function ()
{
//...
    this.On.Destroyed.Connect(this, function (header, payload)
    {
        Exec("Saving " + this.Name + " to database", function ()
        {
            ::UXPlayerVars.apply(function (v)
            {
                switch (typeof v)
                {
                    case "string": SQLd.Exec("insert or replace into players_vars ([name], [indx], varchar(24) [value]) values ('" + ::SQLite.Escape(this.Name) + "', '" + ::SQLite.Escape(v) + "', '" + this[v] + "');"); break;
                    case "integer": SQLd.Exec("insert or replace into players_vars ([name], [indx], integer [value]) values ('" + ::SQLite.Escape(this.Name) + "', '" + ::SQLite.Escape(v) + "', " + this[v] + ");"); break;
                    case "float": SQLd.Exec("insert or replace into players_vars ([name], [indx], float [value]) values ('" + ::SQLite.Escape(this.Name) + "', '" + ::SQLite.Escape(v) + "', " + this[v] + ");"); break;
                    default: throw "Invalid parameter type";
                }
                return v;
            });
        });
    });
});

And it gives me this error:
[ERR] Squirrel exception caught while destroying player
[ERR] the index 'Name' does not exist
[
=>Location: unknown
=>Line: unknown
=>Function: unknown
]
[INF] Traceback:
[
]
[INF] Locals:
[
]
How should I figure the out the player?
(:edit: I've noticed that this is vulnerable to an SQL injection attack since I didn't escape the value, only the player's name and the variable's name. Let's forget that for now since I solved it)
#44
Support / 127 on trying to load plugin
Apr 24, 2017, 12:24 PM
I'm trying to load a plugin I made
#define WIN32

#include "main.h"

#include "SqImports.h"

HSQAPI hSQ;
HSQUIRRELVM hVM;

PluginFuncs * hFunctions;

bool bServerRunning = false;

void OutputMessage(const char * msg)
{
#ifdef WIN32
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);

CONSOLE_SCREEN_BUFFER_INFO csbBefore;
GetConsoleScreenBufferInfo(hstdout, &csbBefore);
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
printf("[MODULE] ");

SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
printf("%s\n", msg);

SetConsoleTextAttribute(hstdout, csbBefore.wAttributes);
#else
printf("%c[0;32m[MODULE]%c[0;37m %s\n", 27, 27, msg);
#endif
}

void OnSquirrelScriptLoad()
{
size_t nSize;
int32_t nSqID = hFunctions->FindPlugin("SQHost2");
if (nSqID != -1)
{
void **SqExports = hFunctions->GetPluginExports(nSqID, &nSize);

if (SqExports != NULL && nSize > 0)
{
SquirrelImports ** SqDerefFunctions = (SquirrelImports **)SqExports;
SquirrelImports * SqFunctions = (SquirrelImports *)(*SqDerefFunctions);

if (SqFunctions)
{
hSQ = *(SqFunctions->GetSquirrelAPI());
hVM = *(SqFunctions->GetSquirrelVM());
}
}
else
{
OutputMessage("Failed to attach to SQHost2");
}
}
}

void OnServerShutdown()
{
OutputMessage("Closing Dixord connections");
}


uint8_t OnServerInitialize()
{
OutputMessage("Initialized Dixord by Ice Flake");

return true;
}

uint8_t OnPluginCommand(uint32_t nCommandIdentifier, const char* sMessage)
{
switch (nCommandIdentifier)
{
case 0x7D6E22D8:
OnSquirrelScriptLoad();
break;
}

return true;
}

extern "C" unsigned int VcmpPluginInit(PluginFuncs* h_Functions, PluginCallbacks* h_Callbacks, PluginInfo* h_Info)
{
h_Info->pluginVersion = 0x1000;
strncpy(h_Info->name, "Dixord", sizeof(h_Info->name));

h_Info->apiMajorVersion = PLUGIN_API_MAJOR;
h_Info->apiMinorVersion = PLUGIN_API_MINOR;

hFunctions = h_Functions;

h_Callbacks->OnServerInitialise = OnServerInitialize;
h_Callbacks->OnPluginCommand = OnPluginCommand;
h_Callbacks->OnServerShutdown = OnServerShutdown;

return 1;
}
(where main.h and SQImports.h are the same as here)

I compiled it using VS 2015 community and it gives me the following error:
Plugin error >> GetProcAddress() 'plugins/dixord04rel64.dll' failed: Code 127
Failed to load plugin: dixord04rel64

Why does this occur?
#45
I requested some information from a server:
<?php

const cloudwards_servers = ["178.32.116.43"];

const 
masterlist "http&#58;//master.vc-mp.org/servers/";

class 
Server
{
    public 
$ip             "0.0.0.0";
    public 
$port           0;

    public 
$version        "Unknown";
    public 
$passworded     false;
    public 
$players        0;
    public 
$max_players    0;

    public 
$success        false;


    public function 
__construct($ip$port)
    {
        
//Create stream

        
$ip_array explode("."$ip);
        
array_map("intval"$ip_array);

        
$client stream_socket_client("udp&#58;//{$ip}:{$port}");

        
stream_set_timeout($client1);

        
//Send request

        
if ($client === false) return;

        
$message    "";

        
$message   .= "MP04";                  //Magic

        
$message   .= chr($ip_array[0]);       //IP byte 0
        
$message   .= chr($ip_array[1]);       //IP byte 1
        
$message   .= chr($ip_array[2]);       //IP byte 2
        
$message   .= chr($ip_array[3]);       //IP byte 3
        
        
$message   .= chr($port 0xFF);       //Port byte 0
        
$message   .= chr($port >> 0xFF);  //Port byte 1
        
        
$message   .= "i";                     //Opcode information

        
fwrite($client$message);

        
//Receive information

        
$header fread($client42);
        
        if (
strlen($header) < 42) return;

        
$magic    substr($header04);       //Magic

        
$ip       "";                          //IP
        
$ip      .= ord(substr($header41));  //IP byte 0
        
$ip      .= ".";                         //IP byte seperator
        
$ip      .= ord(substr($header51));  //IP byte 1
        
$ip      .= ".";                         //IP byte seperator
        
$ip      .= ord(substr($header61));  //IP byte 2
        
$ip      .= ".";                         //IP byte seperator
        
$ip      .= ord(substr($header71));  //IP byte 3

        
$port_1   ord(substr($header81));  //Port byte 0
        
$port_2   ord(substr($header91));  //Port byte 1
        
        
$opcode   substr(101);
    }
}

$server = new Server("46.105.184.128""8194");
And it doesn't feel like replying for some reason, since strlen($header) returns 0.

What am I doing wrong here?
#46
Snippet Showroom / dump function
Mar 17, 2017, 01:45 PM
Here's a simple function to help you debug
function dump(var, indent=0)
{
    if (indent == 0)
    {
        print("[unknown]: " + typeof var + " " + var);
        dump(var, indent + 1);
    }
    else
    {
        foreach (idx, value in var)
        {
            local isindexable = function(v) try { v.len(); return true; } catch (e) return false;
            local indents = "";
            for (local i = 0; i < indent; ++i) indents += "    ";
            print(indents + idx + ": " + typeof value + " " + value);
            if (isindexable(value)) dump(value, indent + 1);
        }
    }
}
Usage: dump(variable);
Example:
dump(["Hello", {Hello = "World"}, ["Hello", "World"], "World"]);Outputs:
[SCRIPT]  [unknown]: array (array : 0x000001CB2C3ADF00)
[SCRIPT]      0: string Hello
[SCRIPT]          0: integer 72
[SCRIPT]          1: integer 101
[SCRIPT]          2: integer 108
[SCRIPT]          3: integer 108
[SCRIPT]          4: integer 111
[SCRIPT]      1: table (table : 0x000001CB2C3AC320)
[SCRIPT]          Hello: string World
[SCRIPT]              0: integer 87
[SCRIPT]              1: integer 111
[SCRIPT]              2: integer 114
[SCRIPT]              3: integer 108
[SCRIPT]              4: integer 100
[SCRIPT]      2: array (array : 0x000001CB2C3AE2C0)
[SCRIPT]          0: string Hello
[SCRIPT]              0: integer 72
[SCRIPT]              1: integer 101
[SCRIPT]              2: integer 108
[SCRIPT]              3: integer 108
[SCRIPT]              4: integer 111
[SCRIPT]          1: string World
[SCRIPT]              0: integer 87
[SCRIPT]              1: integer 111
[SCRIPT]              2: integer 114
[SCRIPT]              3: integer 108
[SCRIPT]              4: integer 100
[SCRIPT]      3: string World
[SCRIPT]          0: integer 87
[SCRIPT]          1: integer 111
[SCRIPT]          2: integer 114
[SCRIPT]          3: integer 108
[SCRIPT]          4: integer 100
#47
Bug Reports / BindFail not getting called
Mar 05, 2017, 04:10 PM
I have this code
SqCmd.Manager().BindFail(this, function (type, msg)
{
    print("!Fail");
    switch (type)
    {
        case ECMDERR.UNKNOWN_COMMAND:
            Cmd.get_invoker().Message(MessageType.Error, "Unknown command.");
            break;
        case ECMDERR.EXECUTION_FAILED:
            Cmd.get_invoker().Message(MessageType.Error, "Internal: Execution failed.");
            break;
        default:
            Cmd.get_invoker().Message(MessageType.Error, "Unknown error.");
            break;
    }
});
However, when I type a command that doesn't exist (and there is no command yet, so no commands exist), it doesn't call the function, and consequently, neither prints '!Fail' nor shows the message (player.Message is overwritten with a custom function, which is the reason for the MessageType argument). What should I do in this case?
#48
I'm trying to create a select query
SQLd <- SQLite.Connection("sqli.db");...
local stmt = SQLd.Query("select * from [players] where lower(name) = '" + SQLite.Escape(player.Name.tolower()) + "'");
But I get this error:
[ERR] Unable to prepare statement. Invalid query string

Why does this occur?
#49
SLC's Squirrel Plugin / Custom documentation
Mar 03, 2017, 06:56 AM
Well... since SLC can't keep up with documenting and developing at the same time, I decided to make my own documentation and post what I discover there.
http://sqmod.iceflake.cf/

It currently has an introduction and a 'getting started' page.
Feel free to contact me for any mistakes, if you find them.
#50
I was trying to use the Timer function, however, it returned an index doesn't exist error.
local timer = SqTime.Timer();I tried dumping SqTime, and this is what I got:
[USR] _typename: (function : 0x000001C4C98AE720)
[USR] __overload_Set2: (function : 0x000001C4C9882CE0)
[USR] GlobalDelimiter: :
[USR] __overload_Set4: (function : 0x000001C4C9883DC0)
[USR] AddSeconds: (function : 0x000001C4C9882A60)
[USR] AndSeconds: (function : 0x000001C4C98835A0)
[USR] AddMillis: (function : 0x000001C4C9883000)
[USR] __overload_constructor1: (function : 0x000001C4C985A490)
[USR] __overload_constructor0: (function : 0x000001C4C985C380)
[USR] __getTable: (table : 0x000001C4C988CFF0)
[USR] __overload_Set3: (function : 0x000001C4C9882EC0)
[USR] AndMinutes: (function : 0x000001C4C9883B40)
[USR] __overload_Set1: (function : 0x000001C4C9882C40)
[USR] cmp: (function : 0x000001C4C9883460)
[USR] AndMilliseconds: (function : 0x000001C4C9883D20)
[USR] AndMillis: (function : 0x000001C4C9882E20)
[USR] AndHours: (function : 0x000001C4C98829C0)
[USR] __setTable: (table : 0x000001C4C988BC10)
[USR] __overload_constructor3: (function : 0x000001C4C985A7F0)
[USR] AddMilliseconds: (function : 0x000001C4C9882B00)
[USR] constructor: (function : 0x000001C4C98824C0)
[USR] AddHours: (function : 0x000001C4C9882920)
[USR] weakref: (function : 0x000001C4C985A520)
[USR] __overload_constructor4: (function : 0x000001C4C98AE690)
[USR] Set: (function : 0x000001C4C9882060)
[USR] AddMinutes: (function : 0x000001C4C9882D80)
[USR] __overload_constructor2: (function : 0x000001C4C985A760)
#51
I was trying to make a barebones script, and I got this error when trying to create a database connection on preload
[DBG] Signaling outside plug-ins to register their API
[SQMOD] Registered: Squirrel SQLite Module
[SQMOD] Registered: Squirrel MySQL Module
[DBG] Attempting to compile the specified scripts
[DBG] Compiled script: Q:\etsx\main.nut
[ERR] the index 'BindPreLoad' does not exist
[
=>Location: sqli.nut
=>Line: 1
=>Function: main
]
[INF] Traceback:
[
=> [1] sqli.nut (1) [main]
=> [2] NATIVE (-1) [dofile]
=> [3] Q:\etsx\main.nut (1) [main]
]
[INF] Locals:
[
=> [1] ARRAY [vargv] : ...
=> [1] TABLE [this] : ...
=> [3] ARRAY [vargv] : ...
=> [3] TABLE [this] : ...
]
[ERR] the index 'BindPreLoad' does not exist
[
=>Location: Q:\etsx\main.nut
=>Line: 1
=>Function: main
]
[INF] Traceback:
[
=> [1] Q:\etsx\main.nut (1) [main]
]
[INF] Locals:
[
=> [1] ARRAY [vargv] : ...
=> [1] TABLE [this] : ...
]
[FTL] Unable to execute: Q:\etsx\main.nut
[SQMOD] Unable to load the plug-in resources properly
One or more plugins failed to initialise, quitting.

[DBG] Signaling outside plug-ins to release their resources
[SQMOD] Terminating: Squirrel SQLite Module
[SQMOD] Terminating: Squirrel MySQL Module
[DBG] Clearing the entity containers
[DBG] Terminating routines an commands
[DBG] Releasing any final resources and all loaded scripts
[DBG] Signaling outside plug-ins the virtual machine is closing
[DBG] Signaling outside plug-ins to release the virtual machine
[SQMOD] Squirrel plug-in was successfully terminated

Here's the code:
SqCore.BindPreLoad(this, function(payload)
{
    print("Creating SQLite connection...");
    SQLd <- SQLite.Connection("sqli.db");
    print("OK");
});
#52
Description
When I have an active (as in not =null-ed) listbox and I get disconnected from the server, even without the game actually closing (for example, /disconnect), I get a crash.
=null-ing on Script::ScriptUnload doesn't work.

Reproducible
Always

What you were doing when the bug happened
Trying to make a spawnwep GUI system

What you think caused the bug
Forgetting to clean up references to listboxes on exit
#53
Bug Reports / 126: mod_mysql not found
Mar 01, 2017, 12:12 PM
Well... I'm getting a 126 error.
That's supposed to mean that the file is not found.
However, the file exists.
I'm on Windows, so case sensitivity is not an issue.
Plugin error >> LoadLibrary() 'plugins/mod_mysql64.dll' failed: Code 126
Failed to load plugin: mod_mysql64
:edit: After copying it again, I'm getting a 193.
Plugin error >> LoadLibrary() 'plugins/mod_mysql64.dll' failed: Code 193
Failed to load plugin: mod_mysql64

:edit: Getting a 126 again after copying the standalone version
#54
Well... I have this code
CPlayer.Account <-
{

};

dAccount <-
{
    function _set(obj, val)
    {
        print(obj + ":" + val);
    }
    function _get(obj)
    {
        print(obj);
        return null;
    }
}

CPlayer.Account.setdelegate(dAccount);

function onPlayerJoin(player)
{
    player.Account.TestVal = "000";
    print(player.Account.TestVal);
}
which I wrote to try and create an account system.
However, for some reason, this line:
    player.Account.TestVal = "000";
is returning a native stack overflow. I'm using the VCMP squirrel plugin.
It doesn't return the error if I don't have the _get function.

How should I resolve this?
#55
Well... if you're new to VCMP and want to figure out which server to play, just use this list.
Checklist:
Freedom of speech
No 'association punishment'
Human rights
Organized administration
All rules objective
All rules enforced

Report VKs official server:
Freedom of speech... No (Advertising rule)
No 'association punishment'... OK
Human rights... OK
Organized administration... OK
All rules objective... No (Advertising rule, scamming rule and attacking the forum/server rule)
All rules enforced... OK

Report Elite Killerz | Estate city server:
Freedom of speech... OK
No 'association punishment'... OK
Human rights... OK
Organized administration... OK
All rules objective... OK
All rules enforced... OK

Report European City
Freedom of speech... No (Advertising rule)
No 'association punishment'... No (ON clan banned)
Human rights... No (FPS adjusting rule and VPN/Proxy usage rule)
Organized administration... Unknown
All rules objective... No (FPS adjusting rule, VPN/Proxy usage rule, Attacks on server rule)
All rules enforced... OK

Report littlewhitey's VC-MP Server
Freedom of speech... No (Advertising rule)
No 'association punishment'... Unknown
Human rights... OK
Organized administration... Unknown
All rules objective... OK
All rules enforced... OK

And in case this gets locked, you can use this link: https://server.elitekillerz.net/threads/flake-server-inspection-report.16/
#56
Snippet Showroom / SQLi library
Feb 23, 2017, 03:40 PM
To solve the political war between MySQL and SQLite, and to make life easier, I've made the SQLi library. The SQLi library is a cross-database (mysql or sqlite) abstracted library for using either MySQL or SQLite, with minimal differences between them both.
Here is the code to place in sqli.nut: http://pastebin.com/GPJNsdDP (also available as a module: http://pastebin.com/KVA5nENk)
Here is how to use it.
First, you instantiate an instance (this is one of the places where there is a difference between MySQL and SQLite). For example:
Inst <- mysqli("localhost:1444", "nub", "t0p532r37", "nubdb");or
Inst <- sqlitei("nub.sqli");Now, for doing a query, you'll call Inst.exec (which will throw an error describing what happened if the query fails):
Inst.exec("update players set kills = " + arguments + " where lower(name) = '" + player.Name.tolower() + "'");As you can see, this code is prone to SQL injection. However, this can easily be solved like this:
Inst.exec("update players set kills = ? where lower(name) = '?'", arguments, player.Name.tolower());You could also do multiple queries in a transaction
Inst.transact(["update players set kills = ? where lower(name) = '?'", arguments.tointeger(), player.Name.tolower()], ["update players set score = ? where lower(name) = '?'", arguments, player.Name.tolower()]);When you're doing a select query, this is the format for using its result: result[nRowID]["sColumnName"] (it returns an array which contains tables).
For example:
local result = Inst.exec("select * from players where name = 'EK.IceFlake'");
print(result[0]["Kills"]);
Note that we do not free the query. This is because the query is automatically freed by the exec function.
You can close the connection using:
Inst.close();and create a new connection (which would overwrite the old connection if it is still alive) using:
Inst.connect(host, username, password, database);or
Inst.connect(path);
Here are some MySQL only functions:
Inst.rowsaffected();
Inst.info();
Inst.use(database);
These functions will throw an error if you try to use them on an SQLite instance.

If you plan to switch to another database later on, then as long as you aren't using the MySQL only functions, it'll be as simple as changing the instantiation line and all connect calls.

You'll need the official MySQL plugin and SLC's SQLite plugin.

Make sure to post your suggestions (or bugs, if any) below.
#57
General Discussion / Cloudwards hosting
Feb 19, 2017, 02:18 PM

I would like to announce the official release of the FREE hosting company Cloudwards. We at Cloudwards are providing free web hosting, Teamspeak 3 server hosting, VC:MP server hosting, and IRC bouncer hosting. We utilize top quality equipment to provide you premium services and premium support, all for free. We provide premium support options which include a support forum, live support chat, and support tickets so we can assist you in every way possible. We are a professional company looking to expand VC:MP and allowing those who cannot afford to host to be able to host websites, game servers and voice servers. Our staff includes EK.IceFlake. (myself), =EK=4K., [MKt]Diamond, and [VU_T]Luckshya. We four attempt to get your voice heard in the constantly expanding Internet universe.

For more information regarding our services and to get a free hosting service now, please visit our official website: https://cloudwards.es

Regards,
Flake
Cloudwards founder
#58
General Discussion / [Suggestion] UID3
Feb 08, 2017, 12:06 PM
Well some nerd is ban evading on vks server and making us (the admin team) very angry. I suggest a UID3 which would return a hashed version of the players product key.
#59
Well... I'm having a lot of trouble scripting a split function for my squirrel std library (which I'm using in my general-purpose squirrel implementation)
class estdstring
{
    function split(string, delimeter, maximum = null)
    {
        if (string.find(delimeter) == null) return [string];
        local array = [], currentpos = string.find(delimeter) + delimeter.len(), idx = 1;
        array.push(string.slice(0, currentpos));
        while (true)
        {
            if ((maximum != null && idx > maximum) || string.slice(currentpos).find(delimeter) == null) return array;
            ++idx;
            local lastpos = currentpos;
            currentpos = string.slice(currentpos).find(delimeter) + delimeter.len();
            array.push(string.slice(lastpos, lastpos + currentpos));
        }
    }
}

Do you know of any split implementation (public domain please)? Thanks.
#60
General Discussion / Flakes hosting
Jan 21, 2017, 03:10 PM
Hey, fellahs!
Drake and SLC closed their free hosts, which means most of you are now stranded without anywhere to host your servers on. Well... no worries! Just apply here and you'll get a host you'll love.
[b]Name (doesn't have to match the real name):[/b] Your answer
[b]UID (choose your own. only alphanumerical characters and hyphens):[/b] Your answer
[b]Port (10000-10080):[/b] Your answer
[b]Plugins:[/b] Your answer
[b]Player count:[/b] Your answer
Please make sure you meet the requirements:
  • Some reputation
  • A brain
  • All files in the store folder are licensed under a permissive or copyleft license except if you downloaded them from somewhere and are unable to get them in a permissive or copyleft license
Please note that MySQL databases are currently not supported.

Current servers:

Elite Killerz | Estate city server
EK.IceFlake
193.70.6.2:1204 | elitekillerz.org:1204

Unknown name
Luckshya
193.70.6.2:10000 | elitekillerz.org:10000

Vice City Fun Server
redax
193.70.6.2:10005 | elitekillerz.org:10005