Jump to content
Sign in to follow this  
Mr.jizz

need help with publiceventhandler (client)

Recommended Posts

so im currently setting up a database using inidbi (yes inidbi2 is out, but iv just got my head around it all and i think inidbi adds multiple database files, where inidbi2 adds only one with multi sections, i prefer multi files, could be wrong?), but anyway, i have pretty much everything running (i think anyway), im using hints for some simple debugging

 

basically i have a load sqf, sends data to server to see if database exists...(execvm load.sqf from initplayerlocal.spf)

//send data to server to check for database.....
_dataplayrowner = clientOwner;
_dataplayrname = profileName;
_dataplayruid = getPlayerUID player;

un_database_check = [_dataplayrowner,_dataplayrname,_dataplayruid];
publicVariableServer "un_database_check";

server receives the data and checks if database is there....(iniserver.sqf)

waitUntil {time > 0};
call compile preProcessFile "\inidbi\init.sqf";

"un_database_check" addPublicVariableEventHandler {
private ["_packet","_dataplayrowner","_dataplayrname","_dataplayruid"];

  _packet = _this select 1;
  _dataplayrowner = _packet select 0;
  _dataplayrname = _packet select 1;
  _dataplayruid = _packet select 2;
  _datanamearray = format ["%1_%2_mission_name", _dataplayrname, _dataplayruid];
  databasename = _datanamearray;
  _databasefind = databasename call iniDB_exists;
  _databasefindarray = format ["%1", _databasefind];

then if the database is there it loads the data from the current selected database and send the data back to the player.....(initserver.sqf)

//read data and send to player..............
  if (_databasefindarray == "true") then {
     "Loading Database" remoteExec ["hint"];
	 _readpos = [databasename, "GLOBAL", "UN_pos", "ARRAY"] call iniDB_read;
	 _readdir = [databasename, "GLOBAL", "UN_dir", "STRING"] call iniDB_read;

	 un_database_load = [_readpos,_readdir];
     _dataplayrowner publicVariableClient "un_database_load";

	 _saying = format ["done, %1 , %2",_readpos,_readdir];
	 _saying remoteExec ["hint"];
	};

and finally the player receives the data and then reacts to it......out of all the stages i can tell they all work as they trigger the hints and my saving works as it saves a database file to my server inidb folder, the only satge that doesnt seem to work is this last one as the "your stats have loaded " hint doesnt fire? (load.sqf)

//if database found then load it................
"un_database_load" addPublicVariableEventHandler {
private ["_ppacket","_readpos","_readdir"];
  _ppacket = _this select 1;
  _readpos = _packet select 0;
  _readdir = _packet select 1;
  
  player setPosATL _readpos;
  player setDir _readdir;
  sleep 1;
  hint "your stats have loaded ";
};

2 things i think might be wrong 

 

1. clientOwner maybe isnt the correct var for sending punlicvariableclients ?

2. publicvariableeventhandler isnt right client side?

 

or iv just completely missed something.....

 

 

"i have to state that i know it is reading and writing to the data base (ie it creates database folder and hints what is written in the database folder)"

i just cant seem to get whats written in the database folder sent to the player or atleast get the client/player to react to it?

 

thanks in advance, i didnt wanna call out for help but currently iv spent a week trying to fix this and its wrecking my brain now.....stumped  :wacko:

Share this post


Link to post
Share on other sites
private ["_ppacket","_readpos","_readdir"];
  _ppacket = _this select 1;
  _readpos = _packet select 0;
  _readdir = _packet select 1;

there is one "p" too much

_this select 1 params ["_readpos", "_readdir"];

should work

  • Like 1

Share this post


Link to post
Share on other sites
private ["_ppacket","_readpos","_readdir"];
  _ppacket = _this select 1;
  _readpos = _packet select 0;
  _readdir = _packet select 1;

there is one "p" too much

_this select 1 params ["_readpos", "_readdir"];

should work

 

 

 

oh, that was a total brain fart on my behalf haha, unfortunately the variable 'naming' wasnt the issue (i had the issue before i messed with variable names ie they were all "packet" previously) but i did over look that and thanks for pointing it out.....

 

i have resolved my issue though and i really cant believe it!, it was a simple timing issue.

 

basically i was sending the 'variable' before the the 'eventhandler' was created, i have now moved the eventhandler so it is created before the variable creation and now everything is working perfectly!!!!!!! thank god!!!!

 

ill now finish/tidy it all up a bit and post it here so anyone looking a quick inidbi database setup for their dedi server can have it and setup a persistent data base with ease (even after a server restart player specs will be saved), looking about the forums i know alot of lesser qualified coders were looking something like this as was i before i took on the task myself, didnt think i could do it but i got there in the end!!, thanks anyway man, really appreciate the support from this community at times!!!

 

ps (i knew it was something to do with the eventhandler not firing)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×