Jump to content
Sign in to follow this  
alleycat

onPlayerConnected confusion

Recommended Posts

http://community.bistudio.com/wiki/onPlayerConnected

Not sure how to use this. Do I have to place a statement declaring what scripts to run in the init.sqf?

Like this:

onPlayerConnected "[_id, _name] execVM ""PlayerConnected.sqf""";

Or does it mean the above stuff is already running and the game is hardcoded to look for PlayerConnected.sqf? And if that is the case, where does the script have to be? mission root folder?

Share this post


Link to post
Share on other sites

i think onPlayerConnected command using for JIP and use in init.sqf.example i have 2 .sqf (ban.sqf and showmarker.sqf) and i want run this sqf files for JIP players too.

so my init.sqf is like this:

sm = [] execVM "showmarker.sqf";

TKonserver= false; 
indexTKlist=0;
TKlist=[];
publicvariable "indexTKlist";
publicvariable "TKList";

onPlayerConnected "[_id, _name] execVM ""ban.sqf""";

Now ban.sqf will run for JIP but showmarker.sqf not run so i must add showmarker.sqf in ban.sqf file, like this:

BAN.sqf

sm = [] execVM "showmarker.sqf";

publicvariable "TKList";

ban_number = 4;

_nameTK = _this select 1;

for "_i" from 0 to ((count TKlist) -1) do
{
  if ((_nameTK) == ((TKlist select _i) select 0)) 
   exitWith  { 
                    if ( ((TKlist select _i) select 1) >= (ban_number) ) 
                    then {   
                               serverCommand format ['#kick %1', _nameTK]; 
                              } ;
                    };

};

Now showmarker.sqf will run for JIP.You can run more .sqf for JIP this way.i hope this help you.

Share this post


Link to post
Share on other sites

I am not getting it. Is OPC supposed to run whenever a player connects and fire the script that is ordered in the server.cfg, or do I have to place OPC in the init.sqf to work?

Also why is there "OnUserConnected" and "OnPlayerConnected"?

When I try to use OPC (OUC) in tophes launcher as in the example I get errors:

[_id, _name] execVM ""logintest_server.sqf""

This wont work, the server log shows:

Error in expression <[_id, _name] execVM "logintest_server.sqf">

Error position: <execVM "logintest_server.sqf">

Error Missing ;

Error in expression <[_id, _name] execVM "logintest_server.sqf">

Error position: <execVM "logintest_server.sqf">

Error Missing ;

Share this post


Link to post
Share on other sites

Now ban.sqf will run for JIP but showmarker.sqf not run so i must add showmarker.sqf in ban.sqf file, like this:

The marker.sqf will run for any player that joins. Aslong as you didn't use a server / local check to run the script initially (once). Thus onplayerconnected shouldn't be needed for the marker.sqf.

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  

×