OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: ModestNovice on 06 Oct 2008, 03:51:40
-
Hi, I have start work on a save stats\jip script.
I start this becuz I saw work on others, but have not see anything from them for a while :(
I could use ur help on finishing/fixing it up, it probably has much errors.
Anyways, this what I have so far.
if (isServer) then
{
OnPlayerConnected "[_name, _id] execVM ""D_Functions\Connected.sqf""";
OnPlayerDisconnected "[_name, _id] execVM ""D_Functions\Disconnected.sqf""";
};
_name = _this select 0;
_id = _this select 1;
_check = server_stats_array find format["%1_stats",_name];
if (_check > -1) then
{
_my_bank = ((server_stats_array select _check) select 1);
_my_vehicles = ((server_stats_array select _check) select 2);
_my_keys = ((server_stats_array select _check) select 3);
DCV_Bank = _my_bank;
vehicle_array = _my_vehicles;
vehicle_locks_array = _my_keys;
}
else
{
};
_name = _this select 0;
_id = _this select 1;
_check = server_stats_array find format["%1_stats",_name];
if (_check > -1) then
{
_set_new_stats = [((server_stats_array select _check) select 0), DCV_Bank, vehicle_array, vehicle_locks_array];
server_stats_array set [_check, _set_new_stats];
publicVariable "server_stats_array";
}
else
{
call compile format ["server_stats_array = server_stats_array + [[""%1_stats"", DCV_Bank, vehicle_array, vehicle_locks_array]]", _name];
publicVariable "server_stats_array";
};
wow...I was hoping I would get at least 1 reply. >:(
-
After one day you complain about no replies?
Have patience, sometimes you just have to wait till the person with the necessary knowledge comes in or notices your topic.
It can take several days sometimes.
Planck
-
Also doesn't help when the topic is locked... :whistle:
-
sry guys :(
-
it's good practice to put 'isServer' around code blocks... technically though it's not necessary in this instance 'cause it doesn't matter if those particular scripting commands are processed in the init.sqf on say a client as they will never get actioned on anywhere other than the server.
Question. Where does the 'server_stats_array' actually get initially populated?
The way you currently have it the player would have to connect & then disconnect just to have there info added to the array...
Also, I can sorta see what you are trying to get going here, but... with respect to your first post... what is your question?
And, finally... why not use Keygety's ArmALib... this is exactly the sort of thing his application is suited for... It works flawlessly and requires no additional addons or anything on the client end...
Any information you can glean in script you can store in either the persistent Kalevi DB or if it's session only info in the volatile Urpo DB.
Oh, also finally... Apart from OnPlayerConnected & OnPlayerDisconnected server events one does have the ability in the init.sqf to deduce 1 of 4 context's that the init.sqf is being run in...
1. mp_server - the init.sqf is being run on a dedi machine.
2. sp_server - the init.sqf is being run on a player/host machine.
3. mp_client - the init.sqf is being run on a multiplayer client that was there at mission start.
4. jip_client - the init.sqf is being run on a multiplayer client that has joined an in-progress mission.
Note. if a mp_client disconnects either to the multiplayer selection screen (to select a different unit) or disconnects from the server completely they will become a jip_client.
This 'context' that a script is being run in and the OnPlayerConnected & OnPlayerDisconnected and ArmALib is a very powerful combo...
-
Erm, those four variables (mp_server, sp_server, mp_client, jip_client) are not provided by vanilla ArmA or though using ArmALib. Many third party scripts and addons calculate those sort of values, but that doesn't make them available for DaChevs, or anyone else, unless you tell them where they are coming from ;P
-
right. Well, we started with ArmA-Lib, though this does not work on Linux server's, so I am having attempt at my own.
PLUS: sometimes its you know 'fun' to make your own things, ESPECIALLY when they work. ;)
-
@Spooner - They're not variables... didn't say they were... they are 'contexts'. DaChevs has enough information to do thorough searches to find any further information he can't work out himself.
As he seems quite keen on "...having attempt at my own." , "make your own things, ESPECIALLY when they work."
If you tell people how to scratch every single itch, they don't learn much.
DaChevs, if you get really stuck, just do searches in the BIS forums, here, use the biki... everything you need is there.
-
Well i dont seem to keen on trying my own Synide, I was merely posting this to ask the gurus if they thought it seemed 'logical'.
I was going to use ArmALib but as i explained above it does not work on Linux server
I didnt really ask alot Synide either, as you see I wrote it myself and am asking if people who ARE experienced with MP could let me know if I was tossing/recieving the variables right or not.
Thats all.
-
My apologies DaChevs, obviously I cannot provide you with want you want/need... I'm sure one of the Ofpec regular posters will be more than happy to tell you exactly what to do as I'm obviously out-of-date with the protocols around ofpec... good luck matey, I'll leave you to it.
PS. you are right about the certain satisfaction in getting mp/jip operating well in ArmA...
-
No no, its ok Synide.
I over-reacted a bit, and I apologize, you have no need to, you were only trying to help.
Thanks for what you did/could.
;)
-
Ok I have it working, though for some reason it overwrites peoples stuff if someone saves it. Then another person saves it later, the person who saved it first, is no longer in the array :/
Any ideas??
saveStats.sqf
_name = _this select 0;
{
s_stats = [];
if (_x select 0 != _name) then
{
s_stats = s_stats + [_x];
};
server_stats_array = s_stats;
publicVariable "server_stats_array";
} foreach server_stats_array;
server_stats_array = server_stats_array + [[_name, DCV_Bank, vehicle_array]];
publicVariable "server_stats_array";
player groupChat format ["%1", server_stats_array];
player groupChat "Stats Saved.";
loadStats.sqf
_name = _this select 0;
if (DCV_loaded_stats == 0) then
{
for [{_i=0},{_i < count server_stats_array}, {_i=_i+1}] do
{
_theName = ((server_stats_array select _i) select 0);
if (_theName == _name) then
{
_myBank = ((server_stats_array select _i) select 1);
_myVehicles = ((server_stats_array select _i) select 2);
DCV_Bank = _myBank;
vehicle_array = _myVehicles;
DCV_loaded_stats = 1;
};
};
/*
{
_x addAction ["Lock\Unlock", "lock.sqf"];
} foreach vehicle_array;
*/
}
else
{
player groupChat "You already retrieved your stats.";
};