Admins able to spawn vehicles

hi all,

can somebody help me with the script of leo?

i tried different things and can't get it work :(
i think it's about getting set as admin!?

have no idea what is wrong

thanks a lot :)
 

Attachments

  • init.sqf
    2.5 KB · Views: 22
  • playercustomactions.sqf
    179 bytes · Views: 20
  • serverspawnVeh.sqf
    433 bytes · Views: 17
  • spawn_vehicle.sqf
    174 bytes · Views: 17
greetings,
1.
you should change ""spawn_vehicle.sqf"" to "spawn_vehicle.sqf":
Code:
{
  player addaction ['<t color="#FF0000">' + "V " + _x + '</t>', ""spawn_vehicle.sqf"",""]; // wrong: too many quotation marks (""spawn_vehicle.sqf"" -> "spawn_vehicle.sqf")
}  foreach ["UH1H_DZ","Ural_CDF","V3S_Civ","Volha_2_TK_CIV_EP1"]

2.
where are the arguments you have to handover to spawn_vehicle.sqf ([class,player]) ?
as you can see in my example:
Code:
_id = player addaction ['<t color="#FF0000">' + "V " + _x + '</t>', "spawn_vehicle.sqf",[_x,player], -7, false, true, "", ""];
im calling the spawn_vehicle.sqf with arguments [_x,player]

3.
add
Code:
waituntil {!isnil "gear_ui_init"};
as first line in playercustomactions.sqf to make sure UI functions are initialized
+ add a ; at the end of (this seems to be my misstake ^^)
Code:
}  foreach ["UH1H_DZ","Ural_CDF","V3S_Civ","Volha_2_TK_CIV_EP1"]

last, check if all files are located in MPMissions\dayz.mapname\

good luck,
Leo
 
hi leo,

thanks a lot for your fast answer...

I have still some problems... :(

i correct those things you said... but i don't understand what you mean in "step 2"..
i'm still at the beginning by learning the code...:(


can you help me again?

thank you very much! :)
 

Attachments

  • playercustomactions.sqf
    249 bytes · Views: 23
  • init.sqf
    2.3 KB · Views: 17
  • spawn_vehicle.sqf
    174 bytes · Views: 20
  • serverspawnVeh.sqf
    433 bytes · Views: 18
hi,
can you tell me, what is not working now ?
can you see the actions ?

unitName addAction [title, filename, arguments, priority, showWindow, hideOnUse, shortcut, condition];

title: String or Structured Text - The action name which is displayed in the action menu.
filename: String - Path to the script that is called when the action is activated. Relative to the mission folder.
arguments: Anything - (optional) Arguments to pass to the script (will be (_this select 3) for the script)
priority: Number - (optional) Priority value of the action. Actions will be arranged descending according to this. Every game action has a preset priority value. Value can be negative or decimal. Actions with same values will be arranged in order which they were made, newest at the bottom. Typical range is 0 (low priority. Eg: 'Get out') to 6 (high priority. Eg: 'Auto-hover on').
showWindow: Boolean - (optional) If set True; players see "Titletext". At mid-lower screen, as they approach the object. False turns it off.
hideOnUse: Boolean - (optional) If set to true, it will hide the action menu after selecting that action. If set to false, it will leave the action menu open and visible after selecting that action, leaving the same action highlighted, for the purpose of allowing you to reselect that same action quickly, or to select another action.
shortcut: String - (optional, default:"") One of the key names defined in bin.pbo (e.g. "moveForward")
condition: String - (optional, Arma 2 only, default:true) Code that must return true for action to be shown. Special variables "_target" (unit to which action is attached to) and "_this" (caller/executing unit) can be used in the evaluation.

Parameters of the called script upon activation:
An array of parameters is passed to the called script:
[target, caller, ID, (arguments)]
target: Object - the object which the action is assigned to
caller: Object - the unit that activated the action
ID: Integer - ID of the activated action
arguments: Anything - arguments given to the script if you are using the extended syntax

in a foreach loop is _x the content of the array index
for example:
["UH1H_DZ","Ural_CDF","V3S_Civ","Volha_2_TK_CIV_EP1"]
1. loop _x = "UH1H_DZ"
2. loop _x = "Ural_CDF"
3. loop _x = "V3S_Civ"
.
.
End of Array = End of Loop

this means [_x,player] in the addaction sends the array content + the player object to the called script, so the called script can work with this information
the array that is send to the script looks like this -> [target, caller, ID, (arguments)]

in your addaction line (player addaction ['<t color="#FF0000">' + "V " + _x + '</t>', "spawn_vehicle.sqf",[_x,player], -7, false, true, "", ""];)
this means target = player, caller = player, ID = actionID(you can remove this action in called script with this information), arguments = [class,player]
called script:
_this select 0 = target (player)
_this select 1 = caller (player)
_this select 2 = ID (actionID)
_this select 3 = arguments ([class,player] array)


/leo
 
Hi Leo,

my problem is I see no action...
Where can i set my player ID or something... i tested login as admin but still no effect :(

/dondon85
 
ok,
create a script in your mission root
playeractions.sqf
Code:
_showactions = -1;
while {true} do {
      if (_showactions < 0) then {
            _showactions = player addaction ['<t color="#FFFFFF">' + "Show Action Menu" + '</t>', "playercustomactions.sqf", [], -30, false, true, "", ""];
      };
      sleep 2;
};

in your init.sqf add this at the end of the file
Code:
execVM "playeractions.sqf"

this should add a action called 'Show Action Menu' that should execute the playercustomactions.sqf
 
Manatee, im using this myself:

};

sleep 45;
adminPanelUIDS = ["000000"];
[] spawn {
if(!isDedicated) then {
if (getPlayerUID player in adminPanelUIDS) then {
hint "ADMIN TOOL ENABLED";
[] execVM "Admin\start.sqf";
};
};
};
 
you can define the admin UIDs at the start of you init.sqf , as ilari explained
Code:
adminPanelUIDS = ["1234567","7654321","9876543"];

then check for it at the end of the init.sqf
Code:
if(!isDedicated) then {
    if (getPlayerUID player in adminPanelUIDS) then {
        hint "ADMIN TOOL ENABLED";
        [] execVM "adminactions.sqf";
    };
};
 
have you deactivated the 'object not ok' routine in the dayz_server updateObjects script, that delete all objects without UID/ID ? if so, than the spawn script seems buged
 
Hi Leo,

now i've got the action menu but the same problem like Manatee, nothing happens :(

Do you have a finfished script to insert? or a step by step tutorial... i think i'm too stupid for this script ... anything goes wrong... it seems i cant't find it :(

thank you :)

/dondon
 
your serverspawnveh.sqf is a bit wrong too:
Code:
_posiplayer = getPos _this 1;
_dir =    getDir _this 1;
_class = _this 0;
this script should look like this:
Code:
private["_object","_posiplayer","_class","_dir","_fuel"];
_posiplayer = getPos _this select 1;
_dir =    getDir _this select 1;
_class = _this select 0;
_fuel = 1;
sleep 5; // waiting for player leaves the position (no one likes a veh on his head i think) ;P
_object = createVehicle [_class, _posiplayer, [], 0, "CAN_COLLIDE"];
_object setFuel _fuel;
_object setdir _dir;
 
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];

select was missing in my example (post edited)
please dont do copy/paste without checking and understanding the script ^^
you will have big problems in finding errors if you doint understand how scripts work :/
that's why i dont want publish whole script files...
 
Does this work with DayZ.st servers? If not, any ideas what I would need to change? I think they use Reality DayZ private hive.

adding a Veh to Database and make it persistent can look like this :
(using blisshive extension to execute some custom mysql procedures)
Code:
private["_class","_pos","_dir","_fuel","_charID","_worldspace","_ownerID","_discription","_worldspace"];
_class = _this select 0;
_pos = _this select 1;;
_dir = _this select 2;
_fuel = 1;
_charID = _this select 3;
_worldspace = [_dir,_pos];
_ownerID = _charID;
_discription = "Spawned by Admin";  // Discription for world_vehicle Table
 
/////Insert Veh into DB/////
//Wait for HIVE to be free
waitUntil{!hiveInUse};
hiveInUse = true;
_key = ["addVeh",[_class, _worldspace, _discription]];
diag_log("LEO: SERVER: Calling blishive: _key: " + str(_key));
_key call leo_hiveWrite;
sleep 0.1;
hiveInUse = false;
 
//////Read Veh from DB///////
//Get Veh page count
waitUntil{!hiveInUse};
hiveInUse = true;
_key = format["Q:%1:call Leo_proc_getVehsPageCount(%2)", (call fnc_instanceName), dayz_instance];
_result = "blisshive" callExtension _key;
_result = call compile _result;
l_pageCount = call compile ((_result select 0) select 0);
sleep 0.5;
hiveInUse = false;
diag_log("Leo: Got " + str(l_pageCount) + " pages of objects...");
 
//Load objects
waitUntil{!hiveInUse};
hiveInUse = true;
l_objList = [];
l_objCount = 0;
//_page = _pageCount;
_key = format["Q:%1:call Leo_proc_getVehs(%2, %3)", (call fnc_instanceName), dayz_instance, l_pageCount];
diag_log("Leo: Server: Load Objects: _key: " + str(_key));
_result = "blisshive" callExtension _key;
_result = call compile _result;
_end = ((count _result) - 1);
l_item = _result select _end;
if (count l_item > 0) then {
    l_objList set [count l_objList, l_item];
    l_objCount = l_objCount + 1;
    //diag_log("DEBUG: Added object " + l_item);
};
sleep 0.5;
hiveInUse = false;
 
//Spawn objects
l_countr = 0;
{
    //Parse individual vehicle row
    l_countr = l_countr + 1;
 
    l_idKey = call compile (_x select 0);
    l_type = _x select 1;
    l_ownerID = _x select 2;
    l_pos = call compile (_x select 3);
    l_dir = (l_pos) select 0;
    l_pos = (l_pos) select 1;
    l_intentory = call compile (_x select 4);
    l_hitPoints = call compile (_x select 5);
    l_fuel = call compile (_x select 6);
    l_damage = call compile (_x select 7);
 
    if (l_damage < 1) then {
 
 
        //Create it
        l_object = createVehicle [l_type, l_pos, [], 0, "CAN_COLLIDE"];
        l_object setVariable ["lastUpdate",time];
        l_object setVariable ["ObjectID", l_idKey, true];
        l_object setVariable ["CharacterID", l_ownerID, true];
        l_object setVariable ["ObjectUID", "0", true];
 
        clearWeaponCargoGlobal  l_object;
        clearMagazineCargoGlobal  l_object;
 
        l_object setdir l_dir;
        l_object setDamage l_damage;
 
        if (l_object isKindOf "AllVehicles") then {
            {
                l_selection = _x select 0;
                l_dam = _x select 1;
                if (l_selection in dayZ_explosiveParts and l_dam > 0.8) then {l_dam = 0.8};
                [l_object,l_selection,l_dam] call object_setFixServer;
            } forEach l_hitpoints;
            l_object setvelocity [0,0,1];
            l_object setFuel l_fuel;
 
            l_object addEventHandler ["HandleDamage", { _this call vehicle_handleDamage }];
            l_object addEventHandler ["Killed", { _this call vehicle_handleKilled }];
            l_object addEventHandler ["GetOut", { _this call vehicle_handleInteract }]; // @Bliss\addons\dayz_server\init\server_functions.sqf  Ln 35
            l_object addEventHandler ["GetIn", { _this call vehicle_handleInteract }];
 
        };
 
        //Monitor the object
        dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,l_object];
        diag_log("Spawned: " + str(l_idKey) + " " + l_type + " dayz_serverObjectMonitor:" + str(dayz_serverObjectMonitor));
    };
// check Veh variables
  _oLastUpD = l_object getVariable ["lastUpdate",0];
  _oID = l_object getVariable ["ObjectID",0];
  _oUID = l_object getVariable ["ObjectUID","0"];
  _oChID = l_object getVariable ["CharacterID",0];
  _oLastDam = l_object getVariable ["lastDamage",0];
  diag_log ("Leo: Server: Spawn Veh:>> l_object: " + str(l_object) + " Type: " + str(typeOf l_object) + " _oLastUpD: " + str(_oLastUpD) + " _oID: " + str(_oID) + " _oUID" + str(_oUID) + " _oChID" + str(_oChID) + " _oLastDam: " + str(_oLastDam));
} forEach l_objList;
 
this is an example for an older bliss version (3.x) that cames with blisshive.dll, bliss 4.x+ , reality and standard hive dont have this dll so it will not work
if you search this forum for 'update database using hiveext.dll' or somthing like this, you will find some usefull thinks that will help you to change that script
 
I added everything in and used a different way to initialize the menu. Whenever I join my server I get kicked for script restriction #126
Code:
02.04.2013 14:53:37:  ()  - #126 "licVariableEventHandler {_id = (_this select 1) execVM "serverspawnVeh.sqf"};
};
 
if (!isDedicated) then {
 
0 fadeSound 0;
waitU"
Any idea how I can fix this? I'm usually pretty good at making exceptions but this one baffled me :c

I was adding it all in 1 by 1 and testing it. once I added the public variable event handler execVM line and the server spawn sqf is when it broke for me. Before adding those 2 things in I had it so the menu was working there was just no function to actually spawn anything.
 
hm.... try to check line 126 of your Arma2\dayz_x.chernarus\BattlEye\script.txt and change the 5 at the beginning of the line to 1
maybe it could be the line 126 in Arma2\dayz_x.chernarus\BattlEye\publicvariableval.txt too
i dont know the content of your files but a 5 at line start means log + kick und a 1 at line start means log only
 
all the lines around #126 are 1s and none of my other script filters go above line 100 I might just test it without battleye first.
 
Back
Top