Getting Bored

Started by Mötley, Apr 28, 2016, 12:50 AM

Previous topic - Next topic

Mötley

I had a weird idea later today and that was using hashes with classes and other possibilitys.

Now I really do not know why I really want to do this really badly, I think Its because of how ugly hashes are when data is added to the files "nothing is clean and hard to view".

This will be a simple accounting system that is not to be taken seriously what so ever. Or to be used at all!!, maybe more of a test server for hashing.

I would like to hear what others have to say about this as I think It would be rather interesting to see what hashes can really do.

Do not come to me raging this is something I am doing out of boredom and is not to be taken to seriously as I did not even put this in script help.   This is just something for fun.

any interesting suggestions on what else I should use would be liked :D ;D

Stormeus

Quote from: Mr_Motley on Apr 28, 2016, 12:50 AMNow I really do not know why I really want to do this really badly, I think Its because of how ugly hashes are when data is added to the files "nothing is clean and hard to view".

Isn't this what SQL is for?

Mötley

Yes! :D Weirdly that's where I got the idea from "trying to make hashes as clean as sqlite" ;D

It is more of just a bored project nothing searious

KAKAN

Quote from: Mr_Motley on Apr 28, 2016, 01:17 AMYes! :D Weirdly that's where I got the idea from "trying to make hashes as clean as sqlite" ;D

It is more of just a bored project nothing searious
I want MongoDB :D
oh no

NewK

Quote from: KAKAN on Apr 28, 2016, 06:21 AM
Quote from: Mr_Motley on Apr 28, 2016, 01:17 AMYes! :D Weirdly that's where I got the idea from "trying to make hashes as clean as sqlite" ;D

It is more of just a bored project nothing searious
I want MongoDB :D
You can use it, if you use the Java plugin.

KAKAN

Quote from: NewK on Apr 28, 2016, 09:19 AM
Quote from: KAKAN on Apr 28, 2016, 06:21 AM
Quote from: Mr_Motley on Apr 28, 2016, 01:17 AMYes! :D Weirdly that's where I got the idea from "trying to make hashes as clean as sqlite" ;D

It is more of just a bored project nothing searious
I want MongoDB :D
You can use it, if you use the Java plugin.
I want it in Squirrel :D
I'm pretty new to Java and so, I get a lot of errors with it. I'll try learning Java a lot before using it. So for now, I'm with Squirrel.
oh no

Mötley

I have always noticed that Hashes are not clean,

Example:

HashTable.Dec
HashTable.Del
HashTable.Inc

When using a class to store the data in while a player is on a server, and setting an array and making it null ,
^^^^ The hashing functions listed above are no longer needed as when the player leaves the server the data only needs to be added, even with kills and deaths, no reason to use hash.Inc as what ever data was loaded from the player is already on the server and in the array. so we just add in any data when a player leaves

At the moment I am scripting this in LU as I Like the sound of The bridge lift and seagulls, and VCMP takes a little to long to load to beta test.

Hear Is what I have played with so far,
Do not take it serious as I have not done much with it really

function onScriptLoad()
{
// Load the module which provides SQLite functions
        LoadModule( "lu_hashing" );
         
         dofile("Scripts/Main/Accounts.txt")
// Create an array to store the stats for every player while they are ingame
         stats <- array( GetMaxPlayers(), null );
     
         LoadHashes();
print( " Loaded Hashing Test server " );
     
     return 1;
}
 
function onScriptUnload()
{
SaveHashes();
CloseHashes();
}
 
//--------------------------------------------------
 
function onPlayerCommand( player, command, text )
{
     if ( command == "stats" )
     {
           if ( text )
           {
                local plr = FindPlayer( text );
                 
                 if ( !plr ) MessagePlayer( "Player " + text + " is not online." );
                 else
                 {
                       local plrStats = stats[ plr.ID ];
                     
                       MessagePlayer( plr.Name + "'s stats:", player );
                       MessagePlayer( "Kills: " + plrStats.Kills + ", Deaths: " + plrStats.Deaths, player );
                       MessagePlayer( "Joins: " + plrStats.Joins, player );
                 }
           }
           else MessagePlayer( "Usage: /stats <player>", player );
     }
     
     return 1;
}

The dofile to see beter

//--------------------------------------------
/* Initialize The hashing features */
function CreateHashes()
{
    Stats<- HashTable( "Stats" );
}

function SaveHashes()
{
        Stats.Save( "Hashes/Stats.hsh" );
}

function LoadHashes()
{
        CreateHashes();
        Stats.Load( "Hashes/Stats.hsh" );
}

function CloseHashes()
{
Stats.Close();
Stats<- null;
}
//--------------------------------------------
 
/* Store the player stats while on the server */
class PlayerStats
{
     Kills = 0;
     Deaths = 0;
     Joins = 0;
     PreviousData = false;
}

//--------------------------------------------

function onPlayerJoin( player )
{
     // Create a temporal stat object to store the player stats while they're online
     stats[ player.ID ] = PlayerStats();

local Reg  = Stats.Get( player.Name + "____Joins" );
     
if ( Reg != null )
{
  // Remember that player had previous stats in the hashes
         stats[ player.ID ].PreviousData = true;
         
          // Now we will seek the data that is currently in hashes
  stats[ player.ID ].Kills  = Stats.Get( player.Name + "____Kills" );
          stats[ player.ID ].Deaths = Stats.Get( player.Name + "____Deaths" );
          stats[ player.ID ].Joins  = Stats.Get( player.Name + "____Joins" );
  //This function throws an error and needs to be hear until updated
         stats[ player.ID ].Joins++;
}
}

//--------------------------------------------

/* Save player stats on part */
function onPlayerPart( player, partID )
{     
     // If player had any data in the hashes, update the old stats
     if ( stats[ player.ID ].PreviousData = true )
     {
           Stats.Add( player.Name +  "____Kills",  stats[ player.ID ].Kills );
   Stats.Add( player.Name +  "____Deaths", stats[ player.ID ].Deaths );
           Stats.Add( player.Name +  "____Joins",  stats[ player.ID ].Joins );
           SaveHashes();
}
else
     {
           Stats.Add( player.Name +  "____Kills",  stats[ player.ID ].Kills );
   Stats.Add( player.Name +  "____Deaths", stats[ player.ID ].Deaths );
           Stats.Add( player.Name +  "____Joins",  stats[ player.ID ].Joins );
           SaveHashes();
}

     // Reset the stat array slot
     stats[ player.ID ] = null;
     
     return 1;
}

//--------------------------------------------------
 
/*
     These events will affect the player stats, so we need to grab the
     changes and temporarily save them into the array
*/
 
function onPlayerKill( killer, player, weapon )
{
     stats[ killer.ID ].Kills++;
     stats[ player.ID ].Deaths++;
     
     return 1;
}
 
function onPlayerDeath( player, reason )
{
     stats[ player.ID ].Deaths++;
     
     return 1;
}
 
//--------------------------------------------------

Mötley

I could use some interesting Ideas on Modifying hashes.

Something else I plan to add in for fun is Bitwise Operations

since LU server is 32 bit, i can only use 32 digits long.
I am not sure about the different server packages in VC:MP

I really do not intend to use loop methods.

So any methods or interesting pointers are liked :)

Thijn

So you're basically doing exactly what you would do with SQLite except you're avoiding it. Why? :P

Mötley

#9
Just for fun!! :D.

I know that hashes are very un-professional

Example:: If you were to save all of the data to one hash file and you wanted to manually go threw and change a players level to admin, its just a mess.

I thought on attempting to split the text to something similar to how a sq_lite browser would look rather than being unprofessional.
In the end I guess you could say a look a like of Write Ini and sq_lite.
But that's not a priority at all, I have also thought about salting all of the hash files, but I don't know yet, have not got there yet :P

All I am attempting to do is make hashes very simpler to use ( 100% reason is to see what hashes are really capable of),
I have also notice lag sometimes in hashes, when hashes are open and a lot of data has been processed over time the server begins to lag so I want to Bypass that as well,

Are Hashes floats, strings etc? Or is there a limitation? I have never seen documentation on that yet,.

I do plan on using a constructor in a small aspect of player loops.
I also plan to re review the squirrel manual to refresh my mind on other possibilitys that I can not recall.

^^ in the play around script listed above I plan to remove the default load hashes close hashes and implement into the constructor. As this Idea seems interesting. once converted to VCMP format some functions will not be needed as much luckily causing the script to have less hashing requirements and cleaner.

Don't take this build Serious ;D

Stormeus

Oh man, last time I tried something for fun here, people still took it seriously and made some pretty bad scripts. Good luck with that though.

Mötley

#11
Quote from: Stormeus on Apr 28, 2016, 09:47 PMOh man, last time I tried something for fun here, people still took it seriously and made some pretty bad scripts. Good luck with that though.

What was it that you tried?

Well at this time the hash test server went from being a silly test server to a server that is beginning to implement a constructor to the player class, so it's hard to just script it in as I have many ideas and can't configure on how I would like to handle the players data. I might attempt to go simple to get it done and update at a later time as I keep getting ocd over players data.

Playing with hashes I can do this

Stats.Add( player.Name +  "____Account___", 0 + " Account " + 0 + " Account " + 0 + " Account " + 0 + " Account " + 0 );
And in the hash file will add

Motley____Account___
0 Account 0 Account 0 Account 0 Account 0
So I might attempt to play with this at another time to be capable of adding majority of data in one line, due to how hashes add to hashing files, But I would need to create locals etc and splite the text you guys/girls should know what I am talking about...

I might be capable of making the hashes hav the out come of
Motley____Account___
Cash = 0, Bank = 0, Wanted = 0, IP = 0

If I can get a real understanding of hashes ( how they work) and If they can receive Identifyers as well If I can create locals say local Cash = Player.Cash Then it should get cash = what ever data is added in another term the hash file would say Player.Cash = 0,. But I could use help from @Vrocker or Ad tech for a background on hashes