Jump to content
  • 0

Read variables from database ?


StiflersM0M

Question

8 answers to this question

Recommended Posts

  • 0

Should be pretty straight forward. For humanity I grabbed the first snipped I could find from the existing Epoch files and got something like this:

_characterID = player getVariable ["CharacterID",0];
_key = format["CHILD:102:%1:",_characterID];
_primary = _key call server_hiveReadWrite;
if (count _primary > 0) then {
	if ((_primary select 0) == "ERROR") exitWith {
		//Could not get data
	};
};
_humanity =	_primary select 5;

No idea if it works or not though, you're going to have to test it out. This particular call (102) also grabs data such as medical status, stats, state, worldspace etc. So I guess there's probably a more discrete way of doing this, but this should work just as fine.

 

Though I don't see why you need to grab it straight from the database. Most basic info is available through variables:

_humanity = player getVariable ["humanity",0];
Link to comment
Share on other sites

  • 0

 

Should be pretty straight forward. For humanity I grabbed the first snipped I could find from the existing Epoch files and got something like this:

_characterID = player getVariable ["CharacterID",0];
_key = format["CHILD:102:%1:",_characterID];
_primary = _key call server_hiveReadWrite;
if (count _primary > 0) then {
	if ((_primary select 0) == "ERROR") exitWith {
		//Could not get data
	};
};
_humanity =	_primary select 5;

No idea if it works or not though, you're going to have to test it out. This particular call (102) also grabs data such as medical status, stats, state, worldspace etc. So I guess there's probably a more discrete way of doing this, but this should work just as fine.

 

Though I don't see why you need to grab it straight from the database. Most basic info is available through variables:

_humanity = player getVariable ["humanity",0];

First one seems not to working, throws me out a "any" with dia_log _humanity

 

So to get a bit more direct,

 

I want to write a fix for the humanity duping with infistar 335, cause infistar seems not to send me the newest version i need to help my self :D

 

In player_switchmodel i want to check for the humanity before its complete and get the humanity via the database and set it to the character after the humanity dupe happend.

Link to comment
Share on other sites

  • 0

First one seems not to working, throws me out a "any" with dia_log _humanity

 

So to get a bit more direct,

 

I want to write a fix for the humanity duping with infistar 335, cause infistar seems not to send me the newest version i need to help my self :D

 

In player_switchmodel i want to check for the humanity before its complete and get the humanity via the database and set it to the character after the humanity dupe happend.

 

Mmm in that case yeah that might not work. I grabbed this snipped from a server side file.

Link to comment
Share on other sites

  • 0

Need to be careful that the character record has been written to the DB recently as it is not saved all the time, only on certain events.  If possible grabbing the environment variable for humanity (if set) would be much preferred.

 

You cannot access the DB calls directly from the client code (deliberately) so you would have to set up a new public variable to request the data from the server.  The server would then catch this request, query the data (by running a server side SQF with the code snippet above in it - don't forget to initialise variables etc).  The server would then pass the public variable back the calling client via another public variable.  The client would then receive the variable and could manipulate it.

 

You could need to define the public variable calls at each side for client to server and server to client as well as write the sqf to query the db and whitelist the public variables in Battleeye / Infinistar.

 

Not such as small job as it may have seemed but very do-able if you want to go that way.

 

I have not looked at the humanity issue but saving the current humanity to a local variable, changing the clothes and then writing the saved humanity back ot the player object variable would be the normal way to do it.

 

If you want to give an overview of the issue then I may be able to offer some better suggestions, if you would like.

Link to comment
Share on other sites

  • 0

Need to be careful that the character record has been written to the DB recently as it is not saved all the time, only on certain events.  If possible grabbing the environment variable for humanity (if set) would be much preferred.

 

You cannot access the DB calls directly from the client code (deliberately) so you would have to set up a new public variable to request the data from the server.  The server would then catch this request, query the data (by running a server side SQF with the code snippet above in it - don't forget to initialise variables etc).  The server would then pass the public variable back the calling client via another public variable.  The client would then receive the variable and could manipulate it.

 

You could need to define the public variable calls at each side for client to server and server to client as well as write the sqf to query the db and whitelist the public variables in Battleeye / Infinistar.

 

Not such as small job as it may have seemed but very do-able if you want to go that way.

 

I have not looked at the humanity issue but saving the current humanity to a local variable, changing the clothes and then writing the saved humanity back ot the player object variable would be the normal way to do it.

 

If you want to give an overview of the issue then I may be able to offer some better suggestions, if you would like.

Yeah i think the last way would be a better way to do, but i am scripting since 1 week and dont know yet how i can save the hummanity in a local variable, the direct issues is not well known, but the hummanity just doubled sometimes a player changed his skin, so i got players who got more then 4KK hummanity. and thats really sucks. I know how to set and get the hummanity variable, but i dont know how to save it temporary, any help would be nice, and for all who got the same problem, of cause i will publish the solution with a instruction if it works.

Link to comment
Share on other sites

  • 0

Yeah just

 

_tempHumaity = player getvariable["humanity",0];

 

player setvariable ["Humanity",_tempHumanity, true];

 

Just off the top of my head so may not run as is ;) but should give an idea.

 

There is also a big thread on the issue although I have not read through it yet.

Link to comment
Share on other sites

  • 0
On 10/2/2014 at 3:40 PM, Rocu said:

Should be pretty straight forward. For humanity I grabbed the first snipped I could find from the existing Epoch files and got something like this:


_characterID = player getVariable ["CharacterID",0];
_key = format["CHILD:102:%1:",_characterID];
_primary = _key call server_hiveReadWrite;
if (count _primary > 0) then {
	if ((_primary select 0) == "ERROR") exitWith {
		//Could not get data
	};
};
_humanity =	_primary select 5;

No idea if it works or not though, you're going to have to test it out. This particular call (102) also grabs data such as medical status, stats, state, worldspace etc. So I guess there's probably a more discrete way of doing this, but this should work just as fine.

 

Though I don't see why you need to grab it straight from the database. Most basic info is available through variables:


_humanity = player getVariable ["humanity",0];

Do you know how to read custom column for database 1.0.6 epoch?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...