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 - jWeb

#31
Quote from: KAKAN on Feb 12, 2017, 04:03 AMplayerson.push( player ) instead of ID, is better.

That approach is flawed because of http://forum.vc-mp.org/?topic=2997.0 This implementation was further discussed here http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=2419.0 but doesn't work because the developers failed to understand or know what one of the main questions in that topic meant "Is the Player instance ever changed by the server without notification? So that I can switch the key to the new instance.".



Quote from: ...happymint_ on Feb 12, 2017, 01:41 AMplayers <- {};

function onPlayerJoin( player )
{
players.rawset(player.Name,player);
}

function onPlayerPart( player, reason )
{
players.rawdelete(player.Name);
}

That also is flawed. Not in general. But only for VC:MP scripters. Because you know.

Why? Well, let's say that player 1 changes name from "looser" too "bigger looser" and player 2 changes name from "tiny looser" to "looser". Well then. A simple mistake in forgetting to update a table and your server logic is f*ed. And don't say you won't forget. Because you will. Somehow, somewhere.



And last but not least. Any answer given to you here is a total waste of time. Why? Because you don't understand the differences between tables and arrays. And because again, you're asking the wrong question. You shouldn't strive to understand which one is better. You should strive to understand how they work and then you'll inherently know which one is better for a certain situation.



Quote from: ...happymint_ on Feb 12, 2017, 01:41 AMplayerson <- [];

function onPlayerJoin( player )
{
playerson.push( player.ID );
}

function onPlayerPart( player, reason )
{
playerson.remove( player.ID );
}

This again proves that you don't know how they work. Because if you use push instead of direct indexing then you're going to have to perform a manual search to find a certain ID.

I'm not even sure wtf this question is about anymore. Storing numbers, storing strings or storing players.
#32
This is the n'th topic with this. Everyone that joins this forum seems to have an urge to make a topic about it. As if no one before them ever thought about it and they're the first to have this revelation.

So let me repeat my self. NO ONE GIVES A F*! (since we're shouting anyway)
#33
Here you go. The simplest admin implementation I can think of. It uses a .txt file to store and load administrators based on their nicks. Uses a table with name->password as the key->value pair to represent the list of admins and be efficient when searching.

Load/save functions:
// ============================================================================
function LoadAdmins(filepath) {
    local f = file(filepath, "rb+"), t = {};
    while (f.eos() == null) {
        local name = "", pass = "", c = 0;
        for (c = f.readn('c'); c != '|' && f.eos() == null; c = f.readn('c')) {
            name += format("%c", c);
        }
        if (f.eos() != null) break;
        for (c = f.readn('c'); c != '\n' && f.eos() == null; c = f.readn('c')) {
            pass += format("%c", c);
        }
        if (f.eos() != null && c != '\n' && c != '\r') pass += format("%c", c);
        name = strip(name), pass = strip(pass);
        if (name.len() > 0 && pass.len() > 0) t.rawset(name, pass);
    }
    return t;
}

function SaveAdmins(adminlist, filepath) {
    local f = file(filepath, "wb+");
    foreach (name, pass in adminlist) {
        name = strip(name), pass = strip(pass);
        foreach (c in name) f.writen(c, 'c');
        f.writen('|', 'c');
        foreach (c in pass) f.writen(c, 'c');
        f.writen('\n', 'c');
    }
}


Helper functions:
// ============================================================================
function EncryptPassword(password) {
    return password; // INSERT YOUR HASHING METHOD HERE! ex: SHA256(password);
}
function AdminCheck(player) {
    if (player.IsAdmin == true) return true;
    MessagePlayer("You do not have the privilege to perform this action!", player);
    return false;
}

NOTE: I would suggest using the Hashing plugin to encrypt the passwords by updating the EncryptPassword() function accordingly. But that's your choice.

Load and save admins:
// ============================================================================
function onServerStart() {
    g_AdminList <- LoadAdmins("adminlist.txt");
}

function onServerStop() {
    SaveAdmins(g_AdminList, "adminlist.txt");
}

NOTE: Make sure you have a "adminlist.txt" file in the server folder.

And 3 simple commands to manage them:
// ============================================================================
function onPlayerCommand(player, cmd, args) {
    args  = strip(args);
    switch (cmd) {
        // ====================================================================
        case "getadmin": {
            if (player.IsAdmin == true) MessagePlayer("You are already an administrator", player);
            else if (args.len() <= 0) {
                MessagePlayer("Syntax: cmd <password>", player);
                return;
            }
            else if (g_AdminList.rawin(player.Name)) {
                local pass = g_AdminList.rawget(player.Name), args = EncryptPassword(args);
                if (pass != args)
                    MessagePlayer("Wrong administrator password", player);
                else {
                    player.IsAdmin = true;
                    MessagePlayer("You are now recognized as administrator", player);
                }
            }
        } break;
        // ====================================================================
        case "setadmin": {
            if (!AdminCheck(player)) return;
            else if (args.len() <= 0) {
                MessagePlayer("Syntax: cmd <player_id> <password>", player);
                return;
            }
            local sep = args.find(" ");
            if (sep == null) {
                MessagePlayer("Syntax: cmd <player_id> <password>", player);
                return;
            }
            local player_id = null;
            try {
                player_id = args.slice(0, sep).tointeger();
            } catch (e) {
                MessagePlayer("Invalid player id", player);
                return;
            }
            local admin = FindPlayer(player_id)
            if (admin == null) {
                MessagePlayer("No such player on the server", player);
                return;
            }
            local password = null;
            try {
                password = strip(args.slice(sep + 1).tostring());
            } catch(e) {
                MessagePlayer("Invalid or missing password", player);
                return;
            }
            if (password.len() <= 0) {
                MessagePlayer("Invalid or empty password", player);
                return;
            }
            g_AdminList.rawset(admin.Name, EncryptPassword(password));
            admin.IsAdmin = true;
            MessagePlayer("Successfully included (" + admin.Name + ") into administrators", player);
        } break;
        // ====================================================================
        case "unsetadmin": {
            if (!AdminCheck(player)) return;
            else if (args.len() <= 0) {
                MessagePlayer("Syntax: cmd <admin_name>", player);
                return;
            } else if (g_AdminList.rawin(args)) {
                g_AdminList.rawdelete(args);
                local admin = FindPlayer(args);
                if (admin != null) admin.IsAdmin = false;
                MessagePlayer("Successfully excluded (" + admin.Name + ") from administrators", player);
            } else MessagePlayer("No administrator named (" + args + ")", player);
        } break;
    }
}

When a player switches to admin mode. It simple sets the player.IsAdmin property to true. So if (player.IsAdmin == true) then that player is an admin. Other wise it's just a regular player.

I'm not sure how you can get more simple than this.
#34
Quote from: iReaL on Feb 10, 2017, 03:11 PMNot the worst, the worst would be if the admin needs a level ()
I said that it can become more secure with the .uniqueID, .IP, and other commands.

That implies you have a static IP address. And most people don't. As for the UID. Well, that can be stolen and replicated. Thus exposing you even further.
#35
Quote from: iReaL on Feb 10, 2017, 01:39 AMSIMPLE CODE FOR ADMIN XD


    if ( cmd == "YOUR CMD" )
    {
         if ( player.Name == "YOUR NAME FOR ACESS THE COMMAND" )
         {
                The function () // The command
         }
    }   else MessagePlayer( "YOU NO ARE ADMIN", player );


For more security on your server you can change the player.Name to
player.UniqueID , player.IP , player.UniqueID2 , or create one data base XD

So if I join with your name. Does that make me an admin on your server?

And also, how primitive that can be. If I want to use a different nickname, I have to search and edit the scripts and reboot the server.

This is the worst of the worst of the worst examples that could be given for something like this.
#36
General Discussion / Re: [Suggestion] UID3
Feb 08, 2017, 06:14 PM
Quote from: KAKAN on Feb 08, 2017, 05:55 PMThen, the devs should give us some Storage method( take localStorage or sessionStorage in web for ex ) with a limit of about 1MB

The other option would be to allow servers to have a persistent storage database based on SQLite since you can limit the database size and provide a neat way of storing structured data without direct access to the storage disk since everything is isolated in the database.

Actually a feature like that should've been done in the first place.
#37
We don't give commands here. You get the code. If you know to use the code then good for you. Otherwise find another hobby.
#38
General Discussion / Re: [Suggestion] UID3
Feb 08, 2017, 02:14 PM
Quote from: KAKAN on Feb 08, 2017, 01:56 PMcountry ban is the worst thing i can think of.
These guys don't know programming, they're script kiddies, so I was thinking to use client side to save a file on the client( you can use  file class for that), and check if the file exists, if it does, ban that guy and if not, then... Atleast that's what we can do until the devs show up

IO is denied on client for several good reasons. First, the file can easily be removed. Secondly, I can get nasty with it. I can write a file so huge that will occupy the whole system drive. And the user would have no idea why. Thirdly, I could write malicious files to the user's disk. And so on.

Quote from: EK.IceFlake on Feb 08, 2017, 01:53 PMAdd yourself to a whitelist

What if you have a dynamic IP address? Will you white-list that for everyone in a certain country every-time they try to connect? So they're gonna be like "hey man, I wanna play. can you let me?".

Or do you plan on avoiding that issue by creating accounts and white-listing accounts? But doesn't this defeat the purpose of having a UID in the first place?

I mean, you could make the accounts harder to obtain. Such as making registration by invitation only. And also punishing the user who invited a cheater. Making the accounts harder to obtain. Thus making the users think again before cheating or inviting a cheater.

And to that you might respond with "but then you'll have an empty server". Well isn't that the same as banning everyone who's cheating? Without a way for them to come back.

But if you reach that point then that means your server wasn't good enough to convince them to behave in order to obtain the privilege to play on it. So that's your fault.

Quote from: EK.IceFlake on Feb 08, 2017, 01:53 PMAnyways, we are making it harder for hackers to evade, not impossible. Making that impossible is impossible

You're not making i harder as long as it's in control of the client's machine.
#39
General Discussion / Re: [Suggestion] UID3
Feb 08, 2017, 01:49 PM
Quote from: EK.IceFlake on Feb 08, 2017, 01:36 PM
Quote from: jWeb on Feb 08, 2017, 12:57 PM
Quote from: EK.IceFlake on Feb 08, 2017, 12:23 PM
Quote from: KAKAN on Feb 08, 2017, 12:22 PMWhatever you do, the UID packets are sent over the client and I'm sure anyone with a bit of knowledge knows how to block that :D
Lmao the server can reject connection then

You don't block it. You simply change it.
Then you use a country ban as a last resort

And what if he's from your country? Does that mean you banned yourself?
#40
General Discussion / Re: [Suggestion] UID3
Feb 08, 2017, 12:57 PM
Quote from: EK.IceFlake on Feb 08, 2017, 12:23 PM
Quote from: KAKAN on Feb 08, 2017, 12:22 PMWhatever you do, the UID packets are sent over the client and I'm sure anyone with a bit of knowledge knows how to block that :D
Lmao the server can reject connection then

You don't block it. You simply change it.
#41
Support / Re: UUID and UUID2 detailes
Feb 08, 2017, 02:14 AM
Uhm, if you've been banned and just want to get around it then just say so. Don't make up a conspiracy and privacy story.

But no. There's no registry or anything you can remove and be done with it. Probably just some information about the machine hardware (like your mother-board) that get's hashed and sent to the server. There's no persistent data stored on your machine other than the machine itself.
#42
Quote from: The Big V on Feb 07, 2017, 06:58 PMThanks again for the help! One last question, how to open the main.nut file? Like which programme do you use for its opening.

Any text editor works. Even the windows notepad (though not recommended).
#43
Quote from: NicusorN5 on Feb 07, 2017, 06:36 PM player.IsFrozen = toggle

player.IsFrozen = !player.IsFrozen;
#44
Quote from: Thijn on Feb 06, 2017, 05:26 PM2. Dodgy old DLLs, that sounds like trouble.

I'm pretty sure you've witnessed people here literally copying the Visual C++ DLLs and whatever DLLs they come into contact with into either their game-folder or windows folder.

Quote from: Thijn on Feb 06, 2017, 05:26 PM3. Pretty much the same as 1. Except the browser wouldn't even start without it. So he obviously has the needed redistributables.

Again, same as before. And I've also seen people making a total mess from installing these. Wrong architecture, wrong versions and so on.

And to be honest, on rare occasions, I have seen the browser and game trying to start and crashing instead of requiring the exact DLL. From what I could tell. This was from the fact that MSVC does come in several updates, like SP1. Or like the 2013 version is just the SP1 version of the 2012 version. And these redistributables also have updates and patches that correspond with the VS version.

And sometimes, I've seen programs trying to load the initial version while compiled with the updated version and resulting in a crash. Which was fixed immediately as I installed the updated C++ redistributables.

I'm not joking about this. I have experienced it.
#45
Well, if you're having issues with it. Here are some helpful installers that will install everything VC:MP needs to run. They're mostly silent so you don't have to do much when installing.

  • DirectX.exe This is quite obvious what it does. But it installs the necessary DirectX files to run the game.
  • RuntimePack.exe This installs some rare old DLLs that some older programs may need in order to function properly.
  • VisualCplus.exe This one is going to install every Visual C++ Runtime version ever needed. 2005/2008/2010/2012/2013/2015 etc. In both x32 and x64 version. Including updates.

The C++ Runtime pack is going to take a while to finish. But look at the bright side. You don't have to do anything. It installs everything silently so you can go and get a coffee or something.

I normally use them after I install my windows because it's annoying to have to do all of them manually. And everything tends to work fine after that.

They can be downloaded here: https://drive.google.com/open?id=0B4b1YKqY2NtSdHNtR1gwRXZWTnM

Disclaimer: These are actually taken from www.drp.su and they're quite helpful.

Forgot to include direct links if someone is suspicious: