Jump to content
  • 0

Help making this script


juandayz

Question

Hello im working on PlotSecure system... its about launch an alarm sound when enemy players enter in a plot area.

basically this work like: If owner && plot friend... then disallow alarm sound ---if  is in plot area and !no ower && !no plotfriend then launch alarm sound.

but, dsnto work yet. any idea?

I made the call from init.sqf   IF is dedicated section:

Spoiler

//plotsecure//
[] execVM 'custom\script\plotsecur\init_plotsecur.sqf';

in my custom variables.sqf

Spoiler

dayz_resetSelfActions = {

s_player_stopalarm = -1;
   s_player_startalarm = -1;

in init_plotsecur.sqf

Spoiler

msg = false;


  while {true} do {
    private ["_pos","_location","_inRange","_trigger"];
    
    _trigger = ["Plastic_Pole_EP1_DZ"];
    _pos = getPosATL player;
    _location = (nearestObjects [_pos, _trigger, 5]);
    _inRange = count _location > 0;

        
    if  (_inRange) then {
        if (!msg) then {
            cutText ['Plot Area. ScrollMenu ProximityON/OF', 'PLAIN'];
            msg = true;
        };
    } else { msg = false; };


    if (_inRange) then {
    
        if (s_player_startalert < 0) then { s_player_startalert = player addaction [("<t color=""#0074E8"">" + ("ProximityON") +"</t>"),"custom\script\plotsecur\startalert.sqf","",5,false,true,"",""]; };
        if (s_player_stopalert < 0) then {    s_player_stopalert = player addaction [("<t color=""#0074E8"">" + ("ProximityOFF") +"</t>"),"custom\script\plotsecur\stopalert.sqf","",5,false,true,"",""]; };
    } else {
        player removeAction s_player_stopalert;
        player removeAction s_player_startalert;
        s_player_stopalert = -1;
        s_player_startalert = -1;
        
    };
    sleep 2;
};

startalert.sqf

Spoiler

private ["_position","_nearplot","_playerUID"," _friends "," _owner ","_soundalert"]

_position = getPosATL player;
_nearplot = count nearestObjects [_position, ["Plastic_Pole_EP1_DZ"], 30] > 0;
_playerUID = [player] call FNC_GetPlayerUID;
_owner =  _nearplot getVariable ["ownerPUID","010"];
_friends = _nearplot getVariable ["plotfriends", []];


if (_nearplot && _owner && _friend ) exitWith {
    cutText [format["Proximity Warning Succes."], "PLAIN DOWN"];
};

if (_nearplot && !_owner && !_friend) then {

_soundalert = objNull;
if (true) then
{
  _soundalert = createSoundSource ["Sound_BadDog", position player, [], 0];
  sleep 10;
  deleteVehicle _soundalert; //stops alarm
};
sleep 0.01;
    titleText ["Proximity Warning Activated!", "PLAIN DOWN"];titleFadeOut 5;
};

stopalert.sqf

Spoiler

//alert Stop


player removeAction s_player_stopalert;

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Heres another way:

init.sqf  IS DEDICATED SECTION:

Spoiler

//plotsecure//
[] execVM 'custom\script\plotsecur\startalarm.sqf';

startalarm.sqf

Spoiler

 

private ["_position","_trigger","_nearestPole","_playerUID","_ownerID","_friendlies","_soundSource_3"]

//DEFINE TRIGGER//
_position = getPosATL player;
_trigger = count nearestObjects [_position, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//END TRIGGER//


//DEFINE OWNER AND PLOT FRIENDS//
_findNearestPole = [];
_nearestPole = _findNearestPole select 0;
_ownerID = _nearestPole getVariable ["CharacterID","0"];
_friendlies        = player getVariable ["friendlyTo",[]];
//END OF DEFINES//

//START CHECK CONDITIONS//

    //plotarea/AND/isOwner///isFriendly// show succes text //////
if (_trigger && _ownerID && _friendlies ) exitWith {
    cutText [format["Proximity Warning Succes."], "PLAIN DOWN"];};

    
    //Plotarea//AND/NotOwner/And/NotFriendly// Spawn Dog Sound!//
if (_trigger && !_ownerID && !_friendlies) then {

    _soundSource_3 = objNull;
    if (true) then
    {
    _soundSource_3 = createSoundSource ["Sound_BadDog", position player, [], 0];
    };

};

 

 

Link to comment
Share on other sites

  • 0

well duke, i was trying in diferents way. Last try i removed every thing about chek owners and friendlys... and sounds dsnt play. i think i have a error in parameters who create the sound.

tried to call a sound trigger, and call sound trought description.ext but nothing.

this is my last try whit out owners and friends check

Spoiler

private ["_position","_trigger"," _soundSource "]

//DEFINE TRIGGER//
_position = getPosATL player;
_trigger = count nearestObjects [_position, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//END TRIGGER//

if (_trigger) then {

_soundSource = createSoundSource [""Sound_Alarm2"", position player, [], 0]
    sleep 10;
    deleteVehicle _soundSource; //stops alarm


};

 

Link to comment
Share on other sites

  • 0

Have you looked at this ?

https://community.bistudio.com/wiki/playSound

 

Example 1:
playSound "soundname"
Example 2:
Start a sound and then stop it after 1.2 second:playSound "AlarmCar"; [] spawn { _sound = ASLToAGL [0,0,0] nearestObject "#soundonvehicle"; sleep 1.2; deleteVehicle _sound; };
Example 3:
Start a sound and wait until it is finished:playSound "Alarm"; hint "Started!"; [] spawn { _sound = ASLToAGL [0,0,0] nearestObject "#soundonvehicle"; waitUntil {isNull _sound}; hint "Finished!"; };
Link to comment
Share on other sites

  • 0

what tech support said

use

playsound "soundname";

then in the description.ext  in 

class CfgSounds

add

class soundname
    {
    name="soundname";
    sound[]={custom\sounds\soundname.ogg,0.9,1};
    titles[] = {};
    };

 

So basically what you are trying to do, i think is have a sound played when someone enters the area? ma i correct?

If so, in the block of code that does the action/script, either warn players or allow them in the area , add

playsound "soundname";

before the end bracket   };

Link to comment
Share on other sites

  • 0

yep i tryed using description.ext whitout  owner and friendlys checks for this moment. but nothing. tnks duke and tech support. I tryed the same sound and way whit another script that i making, and its work,, so have something wrong in the way of call this script or in the defines area

Spoiler

class CfgSounds
{
    sounds[] =
    {
        Radio_Message_Sound
        
    };
    class Radio_Message_Sound
    {
        name = "Radio_Message_Sound";
        sound[] = {custom\remote\radio.ogg,0.4,1};
        titles[] = {};
    };
    sounds2[] =
    {
    alarm
    };
    class alarm
    {
    name="alarm";
    sound[]={custom\script\plotsecur\alarm.ogg,0.9,1};
    titles[] = {};
    }
};   

alarm.sqf

Spoiler

private ["_position","_trigger"]

//DEFINE TRIGGER//
_position = getPosATL player;
_trigger = count nearestObjects [_position, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//END TRIGGER//

if (_trigger) then {

playsound "alarm";


};

 

gonna try call the script whit fn_selfaction.sqf

Link to comment
Share on other sites

  • 0

Got it.

at bottom of selfaction.sqf

Spoiler

/////////////plot alarm//
private["_playerPos","_restricted"];

_playerPos = getPosATL player;
_restricted = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 3] > 0;
 
if (_restricted) then {
        if (s_player_alarm < 0) then {
            s_player_alarm = player addaction[("<t color=""#00C732"">" + ("StartAlarm") +"</t>"),"custom\script\plotsecur\alarm.sqf"];
        };
    } else {
        player removeAction s_player_alarm;
        s_player_alarm = -1;
    };
/////////////////

alarm.sqf

Spoiler

private ["_playerPos","_restricted"]

call gear_ui_init;
_playerPos = getPosATL player;
_restricted= count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 4] > 0;

 

if (_restricted) then
    {
    playsound "alarm";
    sleep 2;
    cutText ["Youre in a private area", "PLAIN DOWN"];
};

 

now, i gonna try make it works  only if palyer is enemy of plot

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...