So I saw something like this once and thought it was really cool, looked around and didn't find anything like this on any of the usual mod sites, so I have decided to try and create my own version. So what exactly am I trying to do?
Basically I am trying to create a vehicle that respawns every server restart. <-- This part is easy and I have done already. The catch and what I think makes it really cool is that the vehicle would be assigned an owner, based on a player uid, if you try to enter as someone who doesn't own the vehicle you are kicked out and given a message along the lines of "you don't have permission to enter this vehicle". <--- This I am finding much more difficult.
So Let me share what I have so far and hopefully some of you much more talented people can tell me where I have gone wrong and if I am even doing this halfway correctly.
first I have a file called privatevehicles.sqf which is called server side through the server_monitor.sqf like so:
the privatevehicle.sqf which works fine with spawning in a vehicle:
// This spawns the vehicles.
_vec = createVehicle ["UH1H_TK_EP1", [14110.31, 2782.1448, 0], [], 0, "CAN_COLLIDE"]
_vec setVariable ["Sarge",1,true];
_vec setVariable ["owner",123,true]; //trying this to see if I can set an owner variable but this is over my head right now as to how to really do this and the values are placeholders.
_vec = execVM "z/addons/dayz_code/PV/privatechopper.sqf";
_vec2 = createVehicle ["LandRover_Special_CZ_EP1_DZ", [14210.31, 2782.1448, 0], [], 0, "CAN_COLLIDE"];
_vec2 setVariable ["Sarge",1,true];
_vec2 = execVM "z/addons/dayz_code/PV/privatelandrover.sqf"; //tried adding this to then end of the createvehicle line like I'm sure it should be but the sarge variable would not set when I did this so I'm not certain it's actually even using the script on the vehicle or not at this point.
This spawns in the vehicles and the sarge variable keeps them from exploding or disappearing when you enter them.
Now all that is very basic and easy to achieve however, now I have this which I was hoping would do all of the more interesting portions but so far has not worked.
private["_owner","_vec","_crew","_dontmove"];
if (vehicle player != player) then {
_vec = (vehicle player);
if (_vec isKindOf "UH1H_TK_EP1") then {
_owner = []; // this is filled with "123154123" in landrover.sqf
_owner = _vec getVariable "owner"; //this is removed in the landrover.sqf
if ((count _owner) > 0) then {
if (!((getPlayerUID player) in _owner)) then {
_crew = crew _vec;
_dontmove = false;
{ if ((getPlayerUID _x) in _owner) then { _dontmove = true;}; } forEach _crew;
if (!_dontmove) then {
cutText ["You are not allowed to enter this vehicle","PLAIN",3];
moveOut player;
};
};
};
};
};
};
So either that code is not functional or I am not actually calling it when I am spawning the vehicle. I hope that you guys will find this interesting and help me get this working.
Just realized what I was trying to do with the setVariable isn't going to work without some additional scripting to define what those variables are and could be a solution to assigning an owner possibly.
I assume if I use a setVariable solution to define the owner then I would have to define the variable itself somewhere with something like the example I found here: http://community.bistudio.com/wiki/setVariable but honestly this is over my head a bit still.
Question
thekaboobie
So I saw something like this once and thought it was really cool, looked around and didn't find anything like this on any of the usual mod sites, so I have decided to try and create my own version. So what exactly am I trying to do?
Basically I am trying to create a vehicle that respawns every server restart. <-- This part is easy and I have done already. The catch and what I think makes it really cool is that the vehicle would be assigned an owner, based on a player uid, if you try to enter as someone who doesn't own the vehicle you are kicked out and given a message along the lines of "you don't have permission to enter this vehicle". <--- This I am finding much more difficult.
So Let me share what I have so far and hopefully some of you much more talented people can tell me where I have gone wrong and if I am even doing this halfway correctly.
first I have a file called privatevehicles.sqf which is called server side through the server_monitor.sqf like so:
the privatevehicle.sqf which works fine with spawning in a vehicle:
This spawns in the vehicles and the sarge variable keeps them from exploding or disappearing when you enter them.
Now all that is very basic and easy to achieve however, now I have this which I was hoping would do all of the more interesting portions but so far has not worked.
So either that code is not functional or I am not actually calling it when I am spawning the vehicle. I hope that you guys will find this interesting and help me get this working.
Just realized what I was trying to do with the setVariable isn't going to work without some additional scripting to define what those variables are and could be a solution to assigning an owner possibly.
I assume if I use a setVariable solution to define the owner then I would have to define the variable itself somewhere with something like the example I found here: http://community.bistudio.com/wiki/setVariable but honestly this is over my head a bit still.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now