Jump to content
Sign in to follow this  
thryckz

Need someone to verify my pseudo code please :)

Recommended Posts

I can't exactly check this right now, as I am at work with some free time. I am a new programmer to sqf and I've wrote this from the little I know of it, which is indeed, very little. Can someone just tell me if I'm missing anything, or do i have the gist of this?

Also, can I put this on a init.sqf and it will execute auto when I connect, or do I need to have a handle or loop or something for my connection? Putting it in a unit's initialization is not an option as players may choose my slot.

// check if admin
_uid = getPlayerUID player;
_tz = player;
_isShown = false;

if (_uid = "8107526")
then
{
   // show menu
   _tz addAction ["*Show Admin Menu*", _isShown = true];
   if (_isShown = true)
   then
   {
       _tz addAction ["*Hide Admin Menu", "hide.sqf"];
       _tz addAction ["Full Health", "sc\health.sqf"]; // cheat
       _tz addAction ["Infinite Health", "sc\infhealth.sqf"]; // cheat alot
   }
}

Also, when I was on the wiki, it said the "player" variable is executed individually. Does this mean it will execute for every player, or execute when their is a player in the slot?

Share this post


Link to post
Share on other sites

Hello,

You're going to have to isolate this part and put it in a new .sqf file.

   if (_isShown = true)
   then
   {
       _tz addAction ["*Hide Admin Menu", "hide.sqf"];
       _tz addAction ["Full Health", "sc\health.sqf"]; // cheat
       _tz addAction ["Infinite Health", "sc\infhealth.sqf"]; // cheat alot
   }

The reason for this is because ArmA 2 does not allow you to make an addaction and use code directly, you must always create a new .sqf file.

So you probably want to call it 'show.sqf' and edit it slightly so it will look like this:

_tz = this select 1;
_tz addAction ["*Hide Admin Menu", "hide.sqf"];
_tz addAction ["Full Health", "sc\health.sqf"]; // cheat
_tz addAction ["Infinite Health", "sc\infhealth.sqf"]; // cheat alot

I don't think you'll have any problems if you paste the first part directly into init.sqf but you want to edit it like so:

// check if admin
_uid = getPlayerUID player;
_tz = player;

if (_uid = "8107526")
then
{
   // show menu
   _tz addAction ["*Show Admin Menu*","show.sqf"];
}  

init.sqf script has nothing to do with slots, the server when the mission starts and everytime a player connects to the briefing screen is when init.sqf is executed, when it does the 'player' variable equals to the person connecting, it has nothing to do with slots, the script in init.sqf will run for every player connecting and the server itself (if online), it will check if the player UID of the player connecting equals to 8107526, if it does it will add an action to the player to show the admin menu. If player UID does not equal, the script will skip it and continue finishing init.sqf.

If you have any other questions, just ask me.

Kind regards,

Martin

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  

×