Jump to content
Sign in to follow this  
ablueman

Help (addAction problem)

Recommended Posts

Hi, I have a script to check the UID of a char, if that chars UID = one of the clan, allow them to have addActions or custom loadout, whatever.

So I was testing it by adding a few actions. And have had other people test to make sure they dont get the actions if default. or not the member that has them.

Heres the code.

init box of all players:

null=[] execVM "script.sqf";

The code for the script:

WaitUntil{not isNull player};
_uid = getPlayerUID player;

switch(_uid)do 
{ 
case "111111": // EasyTarget
{
hint format["Hello %1", name player];
_aa1 = Player addAction ["Teleport1", "base.sqf",["1"],1,false];
_aa2 = Player addAction ["Teleport2", "base.sqf",["2"],1,false];
_aa3 = Player addAction ["Teleport3", "base.sqf",["3"],1,false];
};

case "222222": // cpt_custard
{
hint format["Hello %1", name player];
};

default
   	{
hint format["You are not on the list %1", name player];

};
};

What i get is (player 1) "me" gets 9 addActions, 3 for me 3 for the 2nd person and 3 for the third. (player2) whether its a player or AI get none but gets the correct welcome and (player 3) gets the your not listed message only.

So the players are getting what they are supposed to but i get addActions for each and every player repeating.

Any ideas please? this is doing my head in ..

Share this post


Link to post
Share on other sites

i know nothing about the scripting but i am thinking its something about the "default"

maybe try an "else" statement?

Share this post


Link to post
Share on other sites

ok, not sure why that screws it up, but one solution with this problem for anyone interested is to use init.sqf and not in each of the players that seems to resolve all problems.

---------- Post added at 10:20 PM ---------- Previous post was at 10:19 PM ----------

i know nothing about the scripting but i am thinking its something about the "default"

maybe try an "else" statement?

Nah wasnt that default just means if not in list like else and that works fine .. thanks for the reply though .. and see my resolution above ;)

Share this post


Link to post
Share on other sites

I think your problem might be that you tried this with a non dedicated session hosted by you?

So by the time the script was executed (init of unit), player always refers to you? I think to have the player command give you the actual player (controller), it has to be executed where this player is local (i.e. on the client of the player, and not on any other client or the server).

But if it works when called from the "init.sqf", I think it the code is better to maintain then distributing (calling) code in init lines of some units in the editor.

Share this post


Link to post
Share on other sites
I think your problem might be that you tried this with a non dedicated session hosted by you?

So by the time the script was executed (init of unit), player always refers to you? I think to have the player command give you the actual player (controller), it has to be executed where this player is local (i.e. on the client of the player, and not on any other client or the server).

But if it works when called from the "init.sqf", I think it the code is better to maintain then distributing (calling) code in init lines of some units in the editor.

Yeah better way to do it .. but confusing nevertheless. I would have thought the waitUntil would have resolved that issue you were talking about and I did try it with real people as well as AI. But anyway .. doesnt matter. this is def better.

Share this post


Link to post
Share on other sites
ok, not sure why that screws it up, but one solution with this problem for anyone interested is to use init.sqf and not in each of the players that seems to resolve all problems.

---------- Post added at 10:20 PM ---------- Previous post was at 10:19 PM ----------

Nah wasnt that default just means if not in list like else and that works fine .. thanks for the reply though .. and see my resolution above ;)

lol.im trying to learn :) i have a pretty basic understanding of the scripts and how they work... but not the syntax of most of it, or more accuratly why the syntax works how it does lol. well glad you got it working.. might use it for my group :)

Share this post


Link to post
Share on other sites
lol.im trying to learn :) i have a pretty basic understanding of the scripts and how they work... but not the syntax of most of it, or more accuratly why the syntax works how it does lol. well glad you got it working.. might use it for my group :)

Please do m8 just make sure the bugs are gone first lol .. refer back here every now and then you may see that i update it.. Im a newb to m8 .. half this code I ripped out of other places, fiddled, faffed and fixed by trial and error. :)

Share this post


Link to post
Share on other sites
... I would have thought the waitUntil would have resolved that issue you were talking about and I did try it with real people as well as AI. ...

I guess your script got executed on your computer (the server?) while the units where still local to the server ("AI controlled").

Now, if you are running a non dedicated server, the waitUntil should wait until there is a player- you. But I am not really deep into MP scripting, so I'd better stop here.

Share this post


Link to post
Share on other sites
I guess your script got executed on your computer (the server?) while the units where still local to the server ("AI controlled").

Now, if you are running a non dedicated server, the waitUntil should wait until there is a player- you. But I am not really deep into MP scripting, so I'd better stop here.

http://forums.bistudio.com/showpost.php?p=1489412&postcount=7

Its working.... thats another post where i was dabbling with this and the original idea. Check that for future..

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  

×