Home   Help Search Login Register  

Author Topic: JIP (WIP) any insight?  (Read 2017 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
JIP (WIP) any insight?
« 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.

Code: (Init.sqf) [Select]
if (isServer) then
{
OnPlayerConnected "[_name, _id] execVM ""D_Functions\Connected.sqf""";
OnPlayerDisconnected "[_name, _id] execVM ""D_Functions\Disconnected.sqf""";
};


Code: (Connected.sqf) [Select]
_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
{
};


Code: (Disconnected.sqf) [Select]
_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.   >:(
« Last Edit: 07 Oct 2008, 08:25:54 by bedges »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: JIP (WIP) any insight?
« Reply #1 on: 07 Oct 2008, 03:21:41 »
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
I know a little about a lot, and a lot about a little.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: JIP (WIP) any insight?
« Reply #2 on: 07 Oct 2008, 08:26:48 »
Also doesn't help when the topic is locked...  :whistle:

Offline ModestNovice

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #3 on: 08 Oct 2008, 00:44:09 »
sry guys :(
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Synide

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #4 on: 08 Oct 2008, 09:02:16 »
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...
« Last Edit: 08 Oct 2008, 09:09:45 by Synide »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: JIP (WIP) any insight?
« Reply #5 on: 08 Oct 2008, 15:09:30 »
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
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #6 on: 08 Oct 2008, 23:11:49 »
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.  ;)
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Synide

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #7 on: 09 Oct 2008, 20:54:01 »
@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.
« Last Edit: 09 Oct 2008, 21:13:03 by bedges »

Offline ModestNovice

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #8 on: 10 Oct 2008, 00:48:11 »
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. 
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Synide

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #9 on: 10 Oct 2008, 13:19:22 »
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...

Offline ModestNovice

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #10 on: 10 Oct 2008, 18:25:35 »
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.

 ;)
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline ModestNovice

  • Members
  • *
Re: JIP (WIP) any insight?
« Reply #11 on: 01 Nov 2008, 23:05:08 »
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
Code: [Select]
_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
Code: [Select]
_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.";
};
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley