WriteIniString Returns an error

Started by Mötley, Mar 05, 2016, 09:17 PM

Previous topic - Next topic

Mötley



script path

const Path = "scripts/Main/";

Functions
function RegisterPlayer( Player, Text ) {

  WriteIniString( Path + "Data/" + Player.Name + ".ini", "Account", "Name", Player.Name );
  WriteIniString( Path + "Data/" + Player.Name + ".ini", "Account", "IP", Player.IP );
  WriteIniString( Path + "Data/" + Player.Name + ".ini", "Account", "Password", Text );
  WriteIniInteger( Path + "Data/" + Player.Name + ".ini", "Account", "Level", 1 );
  WriteIniInteger( Path + "Data/" + "Logs.ini", "Active", Player.Name , 1 );
  MessagePlayer("You have been registered", Player );
 
}

function LogPlayer( Player, Text ) {

  ReadIniInteger( Path + "Data/" + Player.Name + ".ini", "Account", "Level" );
  WriteIniInteger( Path + "Data/" + "Logs.ini", "Active", Player.Name , 1 );
  MessagePlayer("You have been logged in", Player, Green );

}



CMD
function onPlayerCommand( Player, Cmd, Text )
{
    if ( Player.IsSpawned )  {

    switch( Cmd ) {

    case "register": case"reg":
    {
       local Level = ReadIniInteger( Path + "Data/" + Player.Name + ".ini", "Account", "Level" );

       if ( Text ) {
          if ( Level != 1 ) {
             RegisterPlayer( Player, Text );
          }
          else {
             MessagePlayer("You are registered!", Player );
          }
       }
       else {
          MessagePlayer("Register your account: /register [password]", Player );
       }
       break;
    }

    case "login": case"log":
    {
       local LoggedIn = ReadIniInteger( Path + "Data/" + "Logs.ini", "Active", Player.Name );
       if( Text ) {
          if( LoggedIn != 1 )
          {
             LogPlayer( Player, Text );
          }
          else {
             MessagePlayer("You are logged in", Player );
          }
       }
       else {
          MessagePlayer("Login your account: /login [password]", Player );
       }
       break;
    }

What is Wrong?

.

#1
You really don't want to go down that road. You have to look a bit through the crap in the scripting section but eventually you can find better alternatives and examples. Now you see why I hate crap snippets.

EDIT: I forgot to say but your server will be banned now that we know you don't encrypt passwords.
.

Mötley

I understand....

I have done so many searches and nothing[ That is why i finally posted ]

Maybe my issue is due to the file saves as the Player.name instead of a file that is manually already created etc. 

Mötley

I will have a WHIRLPOOL i just wanted to get the script created i have not gone that far this is only beta build ;p

Murdock

If you will be storing player data in ini files you'll get a directory with over 10k ini files over time.. not recommendable. Also encrypt your passwords

Mötley

does the built in function whirlpool work? sorry i literally just threw this together

function Password ( Player, szParams, numArgs ) {

if ( Account [ Player.ID ].Logged == true ) {

if ( szParams ) {

if ( [some func to get the pass] ( Player ) == WHIRLPOOL ( GetTok ( szParams, " ", 1 ) ) ) {

[some func to get the pass] ( Player, GetTok ( szParams, " ", 2, numArgs ) );

MessagePlayer ( "New password: " + szParams, Player );

return;
}

.

.

Mötley

Quote from: S.L.C on Mar 05, 2016, 09:53 PMThere's a hashing module that includes several hashing algorithms.

Thanks so much. now i just want to focus on my system to work then work in encrypted passwords

DizzasTeR

Let me repeat. INI plugin is messed up and it will not store/write data if the INI does not exist already. It will not create it and instead throw errors.

Mötley

#9
Quote from: Doom_Kill3R on Mar 06, 2016, 02:31 AMLet me repeat. INI plugin is messed up and it will not store/write data if the INI does not exist already. It will not create it and instead throw errors.

Never picked that up, but thats what i was thinking in the server.exe as it made no sense.   As soon as i made this post I had to clock in and go to work.

I will separate the data to Weapons ini etc..

BUT!![I like to script and waste time sometimes and find fixes :D] What if I used another method to create the file? when it creates the Player.Name there is a Timer to ensure it is not messing up(creating file/saving/writing/etc) all at the same time.

Maybe use hashes to create the file?, Then say a 5 sec timer then WriteIniInteger? using the other method to create the file then get that file and write to it?

Or if this gives you another idea on a method like this let me know.

DizzasTeR

Your efforts will be in vain unfortunately.

Mötley

Well all I wanted to do is script. Get Creative. I do not really care for the account system that S.L.C mentioned so..
I will either find another project eles where [NOT VC:MP]. As i can hardly add a Police system with stats, FireFighter system as well as Paramedic along side, and The TrashMaster [Trash Missions] as well as helicopter races and boat races, I need to do a lot of call back functions with saving the data, I need a lot of normal Squirrel scripting capability's as well. Mute player with time stamps etc.

Starting to Consider Maybe I am better off going Back to Liberty Unleashed and Continue my RPG server. At least I can Build the way I Really need to support the server. This is Rather Depressing. Was hoping to find ways to Bring in more players.

unless that plugin is fixed, I have no intentions to come back and script for this MultiPlayer.

:/
Nice meeting The VC:MP community

KAKAN

Quote from: Mr_Motley on Mar 06, 2016, 06:27 AMunless that plugin is fixed, I have no intentions to come back and script for this MultiPlayer.
Good bye! You would never return back since the INI plugin will never get fixed. Don't you see the message on startup? "Loaded deprecated_ini"
It's already deprecated. You should stick to either SQLite of mysql. And also, you can fix the errors yourself, you know?
For that fix, since I don't know the INI format, I'll use vargv
function WriteIniString( path, ... ){
local f = file(path,"a");
f.close();
::WriteIniString(path, vargv[ 0 ], vargv[ 1 ], vargv[ 2 ]);
}
Untested, but it should work if you don't try to bitch with it
oh no

Mötley

I will play with that code sometime.

I see the error as it is trying to open a file when instead I am trying to create the file then write to it...

Unfortunately I have lost my eagered interest. I will have to give this time then come back when i am ready.

DizzasTeR

Nobody is stopping you from being creative. Be creative. What I have learned here is that without struggling and giving a worth of time you can't create a server which is 'different' from others. I myself created a server which took alot of struggle and is doing much more than what VCMP provides. You have to work hard for it.

Giving up just because you can't use an INI plugin is stupid. Even though INIs are SLOWER than SQLIte and MySQL so why not go for it? Why not learn further? The choice is yours. I or anyone can't stop you from doing so but atleast I'll tell you before you leave regretting.