Class / Constructor, Two classes 'extends'

Started by Mötley, Oct 12, 2016, 02:27 PM

Previous topic - Next topic

Mötley

Okay so I have come to an area where my studies lack in squirrel and I am about to really look DUMB

I would like to start in VCMP, As well I want a successful start, I want something different, I want a really good file system
The plugin is the simpleIni: http://forum.vc-mp.org/?topic=3631.msg27407#msg27407

I would Like to do it in some method of

\/

class Ini
{
  constructor(Open, File)
  {
        Open = INI_Open(File); // Open[1]; == Open("Accounts.ini")
        File = ["Accounts.ini", "IP_List.ini", "Subnet_List.ini", "UniqueID_List.ini"]; //Find the file
        Close = ::INI_Close(File); // Close[1]; == Close("Accounts.ini")
  }
 
  Open = ::INI_Open(File);
  File = ["????????.ini", "????????.ini", "????????.ini", "????????.ini"]; 
  Close = ::INI_Close(File);

    function functionX() {
        return Open[1];
    }
}

// player overrides Ini's functionX()
class player extends Ini {

function functionX() {
return Close[1];

}


Basic info on the keyword extends:: A class may be derived from another class by using the extends keyword with the original, or the 'base', class name.



I am really blowing my mind right now and I really can not seem to pick up to well in this area of studies,. Could somebody, In someway help me. That script above could be Way better I just really do not know what I am doing at this point, but I do I'm just a little lost, So a little boost at least should get me going better..

Thijn


jWeb

#2
Quote from: Thijn on Oct 12, 2016, 07:12 PMI'm not sure what your question is

Was there ever a question? It's just a topic so that something can be debated. Doesn't have to be anything specific. Just something where you can post when you get bored. Anyway, I'll start first:



Cool bro. But what's setting default values to members when constructor already for all instances because the system load would already overwrite INI:
Open = ::INI_Open(File);
  File = ["????????.ini", "????????.ini", "????????.ini", "????????.ini"]; 
  Close = ::INI_Close(File);

Also, return close does not close because if you close then you open too.

Also, the system is a nice system. This system could help the system when you load and because INI is function you can use tables. I heard You can tables because only single inheritance is to do in Squirrel.

Also, for INI to load INI does not help because Squirrel crash when you use pointer as array `return Open[1];`.

Also, do not forget the system.

Mötley

local File = [["Accounts.ini"], ["IP_List.ini"], ["Subnet_List.ini"], ["UniqueID_List.ini"]];

function onScriptLoad()
{
INI_SetInteger( INI_Open(File[1]), "Bracket", "One", 1); // Error return
}

AN ERROR HAS OCCURED [Error: Invalid filename.]

^ Random code



What could be another option then, Or tell me something that I could use to still do this and I will study into it,
I am not saying just fix my code :D,
You are 100 percent correct  @jWeb,

I never went to school for this, I only have personal studies at this time.

Any help is highly appreciated!!

I just really want to implement a really good system that is fun to play with


KAKAN

That's because you're creating a multi-dimensional array.
This one should work:-
local File = ["Accounts.ini", "IP_List.ini", "Subnet_List.ini", "UniqueID_List.ini"];

function onScriptLoad()
{
 INI_SetInteger( INI_Open(File[1]), "Bracket", "One", 1); // Error return
}
oh no

Mötley

#5
local File = ["Accounts.ini", "IP_List.ini", "Subnet_List.ini", "UniqueID_List.ini"];
function onScriptLoad()
{
   INI_SetInteger( INI_Open(File[0]), "Bracket", "One", 1);
   //INI_SaveFile( INI_Open(File[0]), File[0]);
}

Sadly 1 never writes to file, I will have to configure why later.

I really did not notice at first that I was using a multi-dimensional array. I actually used that for a test due to index 'File' never existed, until added.


Fixed. I really do nont understand why I can not use the method I wanted but to be cappable of actually writing to file I need to use this method

local File = ["Accounts.ini", "IP_List.ini", "Subnet_List.ini", "UniqueID_List.ini"];
local Account = INI_Open(File[0]);

function onScriptLoad()
{
INI_SetInteger( Account, "Bracket", "Money", 1)
INI_SaveFile( Account, File[0]);
}

Sadly I can not do

local File = ["Accounts.ini", "IP_List.ini", "Subnet_List.ini", "UniqueID_List.ini"];
local Open = INI_Open;

function onScriptLoad()
{
INI_SetInteger( Open(File[0]), "Bracket", "Money", 1)
INI_SaveFile( Open(File[0]), File[0]);
}

It just doesn't write.