VarHolder - Add custom properties to Player, Vehicle, Pickup, Checkpoint, Object

Started by habi, May 16, 2023, 06:50 PM

Previous topic - Next topic


VarHolder means Variable Holder.

In server.cfg
plugins squirrel04rel32 varholder04rel32
Then in scripts/main.nut
CreateVar( "CPlayer", "adminlevel", 3); //to use player.adminlevel
CreateVar( "CVehicle", "property", "OK");  //for
CreateVar( "CPickup", "value", 0);
CreateVar( "CObject", "alpha", 2.33);
CreateVar( "CCheckpoint", "alpha", [1]);

player.adminlevel = 4;
FindCheckpoint(0).alpha[0] = 2;
pickup.value = 1 = "NO";

You can create functions too...
CreateVar( "CPlayer", "warn", function(){::MessagePlayer("You have been warned", this);} )

These topics ?topic=468 (2015), ?topic=257.0 (2015), of the forum related to the same subject.

Download links(plugin): (mediafire)

Function documentation
No:of functions : 1
  • CreateVar( string classname, string varname, initialvalue )
    classname is one of "CPlayer", "CVehicle", "CPickup", "CCheckpoint" and "CObject".
    varname : The name of the variable you want to create
    initialvalue : Can be any data type. If table, array or classinstance it works internally by creating clone of it.
    Return value : always null
    Behaviour : If variable already exists, it will be deleted and recreated.

Some question and answers
  • Do the property i created resets automatically when for example a player with ID 2 leaves server and another player joins with ID 2. Do my property resets to initial value for this new player?
    Yes. The values of old player are erased and the properties are fresh initialvalue you provided when creating the property.

Tested to work in 64-bit Linux (Ubuntu)
  • The plugin is tested to work on WSL ubuntu.

Source available : (19.06 KB)