Editing a Virtual Arsenal in Arma 3 with SQF - sqf

not sure if I can ask a question like this on Stack Over flow but basically in Arma 3 im currently editing a scenario called Antistasi, I want to remove some weapons from the virtual arsenal, i've got the variable name, but I have tried all the following and it is not removing the desired item.
[ caja, ["arifle_MXM_F"], true ] call BIS_fnc_removeVirtualItemCargo;
[ caja, ["arifle_MXM_F"], true ] call BIS_fnc_removeVirtualWeaponCargo;
Some help would be appreciated
Edit - It defiantly is the correct Variable as I can move it around with the same name.

You don’t say how you created the arsenal. I always favour scripting so the following will create a virtual arsenal with all weapons in a weapon crate named CRATE_1:
["AmmoboxInit", [CRATE_1, true]] call BIS_fnc_arsenal;
If you want to put this code in the ‘Object:Init’ field of the crate in the Eden editor then you need to use:
noUse = ["AmmoboxInit", [this, true]] call BIS_fnc_arsenal;
noUse is unimportant but a variable is required.
However if you do that the BIS_fnc_removeVirtualWeaponCargo function to remove weapons does not work. I believe there is a bug when you create a virtual weapon crate with all weapons. I get a half hidden error message when I open the arsenal "BIS_fnc_baseWeapon Class '%All' not found in CfgWeapons".
You can create an empty arsenal and add weapons to it. Those can be removed but I am guessing that is not what you want to do. The following code works:
["AmmoboxInit", [CRATE_1, false]] call BIS_fnc_arsenal;
[ CRATE_1, ["SMG_03_black", "arifle_MX_GL_F"], true ] call BIS_fnc_addVirtualWeaponCargo;
[ CRATE_1, ["SMG_03_black"], true ] call BIS_fnc_removeVirtualWeaponCargo;
I favour creating empty virtual arsenals and specifying the equipment I want in the arsenal. Bear in mind there are 4 functions for adding items to a virtual arsenal:
BIS_fnc_addVirtualWeaponCargo;
BIS_fnc_addVirtualMagazineCargo;
BIS_fnc_addVirtualItemCargo;
BIS_fnc_addVirtualBackpackCargo;
I offer a final warning if you are trying to limit weapons usable by players. The virtual arsenal will always show a weapon or equipment a player currently has on his character. In addition a player can load a loadout they previously saved that may have weapons and equipment you do not want them to have.

Related

New Item not displaying properly in-game

I've created my first weapon (item ID: 90000 | display ID: 42070) using Keira. I restarted the DB and clear the cache on the client. I spawned the weapon onto my character, but I get a question mark in the inventory. When I equip the weapon and the character is attacking I can see the weapon , but when it is sheath I can't see the weapon.
I've looked at several conversations that speak about patching the client, but its way over my current pay grade. I need to learn how to do this if I want to continue to create content. Where can I go to learn the skills that I am missing? or who can teach me how to fish so that I can fish for myself? Please advise...
~ tinywolf
You can do a workaround on this by changing a weapon that is already in the game in Keira3
Unless u have created a completely new model u maybe just wanna change another that already has the look

How do you use the CustomRoomData on Appwarps with cocos2d-x

Just started coding with Appwarps and I'm running into an issue. I have a lobby built that shows live rooms, but I really do not want to show the rooms for matches that have already started. I figured I would use
void Client::setCustomRoomData(std::string roomId, std::string customData)
But I have some doubts on how to use it. Once the game starts, I plan on sending
SetCustomRoomData(roomId, "Closed");
to notify the server that open seating is now closed. However, when I check the room properties on another device when it calls
void CCAppwarpDelegate::onGetLiveRoomInfoDone(AppWarp::liveroom revent)
{
CCLog("CustomData=%s",revent.customData.c_str());
...
it returns blank. What am I missing here? Besides the code not working, what really makes me question myself is that I don't understand the mechanics of the properties. How do you have multiple custom properties since you aren't assigning it any kind of index...or do room only have a single custom property at any given time?
You don't need to use customData and instead use only room properties. Room properties is a set of key/value pairs that you can associate with a room.
I recommend you read the following link
http://appwarp.shephertz.com/game-development-center/matchmaking-basic-concept/
So the flow is as follows -
you first create the room using the createRoom API and pass a
properties dictionary containing <"closed", "false">.
Then once the game is active, you use updateRoomProperties API
on the room and pass <"closed", "true"> to the API.
Then when you want to show the list you should use
getRoomWithProperties and pass <"closed", "false">. This will get
you a list of rooms that are not yet "closed".

Multiple logics (N number of clients) handled with only one function. All call the same function, HOW TO? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a corporate application written in python/Django (no python experience required to answer this). Its SAAS basically.
Few of the clients seems to have different requirement for a few modules.
Lets say there is a URL
www.xyz.com/groups
which is used by all clients but a few of the clients want to have different output on call of the same URL.
I want to know how can i do that without writing new function for each client or writing conditions in a single function.
Its a silly question i know but there must be some solution to it, i know.
If your code is required to do "A" for case "a" and "B" for case "b" and "C" for case "c", then regardless of what solution you pick, somewhere in the code has to exists something that decides whever or not case 'a/b/c' occurs, and something must exist that will dispatch correct 'A/B/C' action for that case, and of course those A/B/C actions have to be written somewhere in the code, too.
Step outside of the code and think about it. If it is specified and must happen - it has to be coded somewhere. You cannot escape that. Now, if the cases/actions are trivial and typical, you might find some more-or-even-more configurable library that accidentally allows you to configure such cases and actions, and off you go, you have it "with no code" and no "clutter". But looking formally, the code is deep there in the library. So, the decider, dispatcher and actions are coded. Just not by you - by someone that guessed your needs.
But if your needs are nontrivial and highly specific, for example, if it require your various conditions to decide which a/b/c case is it - then most probably you will have to code the 'decider' part for yourself. That means lots of tree-of-IFs, nested-switches, rules-n-loops, or whatever you like or feel adequate. After this, you are left with dispatch/execute phase, and this can be realized in a multitude of ways - i.e. strategy pattern - it is exactly it: dispatch (by concrete class related to case) and execute (the concrete strategy has the concrete code for the case).
Let's try something-like-OO approach:
For example, if you have cases a/b/c for UserTypes U1,U2,U3, you could introduce three classes:
UserType1 inherits from abstract UserType or implements "DoAThing" interface
UserType2 inherits from abstract UserType or implements "DoAThing" interface
UserType3 inherits from abstract UserType or implements "DoAThing" interface
UserType1 implements virtual method 'doTheThing' that executes actionA
UserType2 implements virtual method 'doTheThing' that executes actionB
UserType3 implements virtual method 'doTheThing' that executes actionC
your Users stop keeping "UserType" of type "int" equal to '1/2/3' - now their type is an object: UserType1, UserType2 or UserType3
whenever you must do the thing for a given user, you now just:
result = user.getType().doTheThing( ..params..)
So, instead of iffing/switching, you use OO: tell, don't ask rule. If the action-to-do is dependent solely on UserType, then let the UserType perform it. The resulting code is as short as possible - but at the cost of number of classes to create and, well, ...
... the decider, dispatcher and actions are still in the code. Actions - obvious - in the various usertype clasess. Dispatch - obvious - virtual call by common abstract base method. And decider..? Well: someone at some point had to choose and construct the correct UserType object for the user. If user was stored in the database, if "usertype" is just an integer 1/2/3, then somewhere in your ORM layer those 1/2/3 numbers had to be decoded and translated into UserType1/2/3 classes/objects. That means, that you'd need there a tree-of-ifs or a switch or etc. Or, if you have an ORM smart enough - you just set up a bunch of rules and it did it for you, but that's just again delegating part of the job to more-or-even-more configurable library. Not mentioning that your UserType1/2/3 classes in fact became somewhat .. strategies.
Ok, let's attack the 'choose' part.
You can build a tree of ifs or switches somewhere to decide and assign, but imperative seems to smell. Or, with OO, you can try to polymorphize something so that "it will just do the right thing", but it will not solve anything since again you will have to choose the object type somewhere. So, let's try data-driven: let's use lookups.
we've got five implementations of an action
create a hash/dictionary/map
add usertype1->caseA to the map
add usertype2->caseC to the map
add usertype3->caseB to the map
add usertype4->caseA to the map
add usertype5->caseE to the map
....
now, whenever you have a user and need to decide, just look it up. Instead of a "case" you may hold a ready to use object of a strategy. Or a callable method. Or a typename. Or whatever you need. The point is that instead of writing
if( user.type == 1) { ... }
else if( user.type == 2) ...
or switching, you just look it up:
thing = map[ user.type ]
if ( thing is null ) ???
but, mind that without some care, you might sometimes NOT find a match in the map. And also, the map must be PREDEFINED for ALL CASES. So, simple if X < 100 may turn up into a hundred of entries 0..99 inside the map.
Of course, instead of a map, you may use some rule-engine and you could define a mapping like
X<100 -> caseA
X>=100 -> caseB
and then 'run' the rules against your usertype and obtain a 'result' that will tell you "caseA".
And so on.
Each of the parts - decide, dispatch, execute - you may implement in various ways, shorter or longer, more or less extensible, more or less configurable, as OO/imperative/datadriven/functional/etc - but you cannot escape them:
you have to define the discriminant of the cases
you have to define the implementation of the actions
you have to define the mapping case-to-action
How to do them, is a matter of your aesthetics, language features, frameworks, libraries and .. time you want to spend on creating and mantaining it.

Advantages of passing a function as a parameter

Just studying for an exam and I can't find the answer to this question in our notes. Any help would be great.
Many languages permit subroutines/functions to be passed as
parameters. List two advantages provided by this, and motivate each
advantage with a clear explanatory example (this need not be code of
pseudo-code).
Think you are a manager of a charming singer ( in computer life : a program) , in the following two ways to start your morning.
Situation 1: You have to tell some underling to do the following a) get breakfast for the star and take great care with the kind of croissants she likes, remember she is very upset when she wakes up etc.. b) Put all cables on the stages using such and such power this lights but not that one , these colors ...
Situation 2: Ask your underling: Ask the majordomo to give our star her usual breakfast. Then ask the crew to take care of the stage for the usual songs.
Situation One is wrong from a computer point of view, it is typical of a quick and dirty way of doing. Yes you have the guy at hand but he is doing all the errands and handling several responsibilities of different types so he may be confused and moreover the order is long and detailed.
In situation two you are delegating, this handles the complexity , the order are short, we know who is doing the which jobs so we won't find a pink huge light bulb in the tea cup of the star (you think it is a joke but that is exactly what a bug is) .
In a few words complexity is partitioned in a meaningful way.
If you do not see why situation two is like calling functions here is a pseudo code.
extern FUNCTION majordomo( client , service , options ) ;
extern FUNCTION crew ( task , options ) ;
FUNCTION startMorning() BEGIN
call ( underling, majordomo( for_ourstar, usual_breakfast, she_is_picky));
call ( underling, crew(usual cables, bright lights));
END
The primary advantage is that if the function being called calls another function, you can modify the behavior of the function being called by specifying which other function is called.
Sorry, beyond that, you'll need to do your own homework.
One of the things passing an 'action' function to a method brings is the ability to perform an action against a collection without exposing the internals of that collection.
A typical use is, iterating over a private collection calling the passed function on each item.
Another is as a callback method.
I simple answer would be the function passed might get used as a callback function.
When the function completes it's job, it would call the callback function with or w/o arguments.
Applying a certain action to all members of a collection. (ie. square every number in it).
Consider a function that sorts an array of objects based on comparison sorting. Such a function needs a way to compare 2 objects and tell which is greater than the other. You can pass such a general sort function a pointer to the array and a pointer to the function that helps it compare any 2 objects.
See STL's sort for an example.

How to explain method calls?

let's consider a small method:
int MyFunction(string foo, int bar)
{
...
}
and some calls:
MyFunction("",0)
int x = MyFunction(foo1,bar1)
How would you explain this to a non-technical persons? Has anybody a nice metaphor?
I tried to explain method calling (or function application) several times, but I failed. Seems I can't find the right words here.
Regards,
forki
UPDATE: It is important for me to explain how the parameters are passed / matched.
(Highly non-technical solution)
It's like making an order:
Calling the method = dialing the right number
Passing the arguments = giving your details
the method does is job
Getting a return value = getting what you ordered
You could tell function is a process available into an object that could be called by other. Lets say "You" is an object with function "Work". Your "Boss" is the caller object. Your Boss then can call you to Work with different type (which is parameter).
In the end Your "Boss" can ask "You" to Work("encode this") or Work("check email") or Work("finish deadline"), etc.
How about delegating a task? Imagine you’re baking a cake and ran out of flour. Instead of buying some yourself you could just send your kid with instructions to buy flour. Input: money, output: flour.
It's difficult to understand the "method call" concept if you don't understand first the
flow of control.
A simple explanation is that methods, or routines, is a construct for packeting instructions
in order to reuse them and make the code more readable.
Calling a method, temporarily, switches the execution flow to that method.
C:: do(a ,b)
You are telling C to do something , given the condition a and b.
The best approach is probably to come up with a domain specific example which the person you are explaining to can relate to. If she is working with the post office, you should describe the function "send letter with this text to this recipient", where recipient is a parameter (containing the address) and message is the parameter for the textual content.
Parameter order is not important as long as you have a name for each parameter. Trying to explain why order is important in some arcane programming language is fruitless.
How about
Calling a function: Ask the software to perform xxx task
Returning value type function: Ask your software to perform xxx task and tell you the outcome of the operation
Calling a function with param: Given X is this value and Y is thisvalue, ask your software to perform xxx task (and tell you the outcome of the operation)
Think of the system as a teller at a desk. To call a function you fill in a form to ask the system to do something, hand it to the teller. They go off and do the work, then hand you back a piece of paper with the result written on it. Depending on what you want the system to do, you pick an appropriate form.
The form for MyMethod says:
MYMETHOD REQUISITION FORM:
String _______
int _______
This analogy can be extended in all kinds of ways. Wouldn't it be handy if the form told you what the purpose of the String and int were? That's where languages with named parameters come in.
For OO, instead of having one desk for the whole system, each object is its own teller, you hand a form to them, and in order to get the job done, they hand a lot more forms back and forth between each other. Etc.