Forum Jump :

Author Message


Posts: 189
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 24
In-game name:

 
#1 Posted at 2008-04-29 04:18        
     
I need help adding an action to all vehicles if the player is a cop.

I think I can start it off.

_car = _this select 0;

if ((Side player == RESISTANCE)) then 
{
SirenOn = _car addaction ["Siren On", "SirenOn.sqf"];
};

SirenOn.sqf
_car = _this select 0;

_car removeaction SirenOn;
SirenOff = _car addaction ["Siren Off", "SirenOff.sqf"];

Siren = TRUE;
publicvariable "Siren";

while {alive _car} do
{
_car say "SirenPolice";
};

SirenOff.sqf
_car = _this select 0;

while {alive _car} do
{
stop playsound "SirenPolice";

_car removeaction SirenOff;
SirenOn = _car addaction ["Siren On", "SirenOn.sqf"];

Siren = FALSE;
publicVariable "Siren";
};

I'm not sure if this will work, I need lots of help, I can never get Sirens to work.



:dontknow


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 47
In-game name: Myke

 
#2 Posted at 2008-04-29 10:17        
     
One problem though is, that in the sirenon.sqf you have a while do loop which has no sleep in it. Probably your siren sound has a length. An object can only "say" one sound at a time (since it's meant to simulate talking people) so a new "say" command will cut the previous. So look how long your sirend sound is and add a sleep command right after the say.

Another problem is, whenever you activate the siren, it wont stop as long the car is alive. Use the variable "Siren" you're using:
while {Siren} do
{
_car say "SirenPolice";
sleep X;
};

And finally, why do you use publicvariable? This will prevent other players to use the siren on any others Police cars. Just remove it.

And as i'm reading through it, i don't think (or in other words: i'm almost sure) "stop playsound blah" will not work. If you want the siren to stop immediately ,create a "empty" soundfile (means the file exists but no sound recorded) and "say" this one. Otherwise just let finish the last "say" command it's sound. If it doesn't last for minutes it might not disturb. Or even more elegant: look if you can find a sample with "siren goes off" sound....you know, when the pitch goes down.


Advertisement


Author Message


Posts: 189
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 24
In-game name:

 
#3 Posted at 2008-04-29 22:27        
     
okay thanks Myke! I'll fix this up and try it all out.

Ah yea, forgot the sleep command :hammer

the sound is only like 6 or so seconds long.


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 47
In-game name: Myke

 
#4 Posted at 2008-04-29 22:50        
     
Another advice: whenever you use global variables (like the Siren variable) always use prefixes. It doesn't change the use of it but if you have scripts from other scripters and anyone else had used the same variablename, it may interfere with yours.

Maybe you should make use of OFPEC's registered Tags to avoid double-use of Tags. Myself i am registered with the tag "STM_" so whenever you find a variable like STM_myvariable you'll know it's from my script.

A quick check showed me that maybe DCV (for D a C he V s) might be a tag for you but for sure you can use your own.

So instead of:
Siren = TRUE;
publicvariable "Siren";

you'll use
DCV_Siren = TRUE;
publicvariable "DCV_Siren";

Believe me, you can avoid a lot of bughunting trouble by registering and using this tag system.

NOTE: doesn't need to be used on local variables like _siren as they are not given out of the running script.


Author Message


Posts: 189
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 24
In-game name:

 
#5 Posted at 2008-05-01 03:35        
     
well it works but the siren won't stop.


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 47
In-game name: Myke

 
#6 Posted at 2008-05-01 14:13        
     
You should post the actual versions of your scripts.


Author Message


Posts: 189
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 24
In-game name:

 
#7 Posted at 2008-05-01 22:07        
     
SirenOn.sqf
_car = _this select 0;
this removeaction SirenOn;
SirenOff = this addaction ["Siren Off", "SirenOff.sqf"];

While {true} do
{
0 fadesound 1; _car say "SirenPolice"; 
sleep 5;
};

SirenOff.sqf
_car = _this select 0;


0 fadesound 1; _car say "SirenOff";

this removeaction SirenOff;
SirenOn = _car addaction ["Siren On", "SirenOn.sqf"];


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 47
In-game name: Myke

 
#8 Posted at 2008-05-01 22:46        
     
Is the action removed correctly and also added correctly? THIS has nothing to do in a script. Only place you may use THIS is in initlines.


Author Message


Posts: 189
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 24
In-game name:

 
#9 Posted at 2008-05-02 03:19        
     
yea, I tried fadesound 0, and everything stops, but after the 5 seconds delay, the siren starts up again. :(


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 47
In-game name: Myke

 
#10 Posted at 2008-05-02 12:46        
     
Duh...how could i overlook this one. Geeze, sure your siren will never stop because your while do loop has no exit condition.

while {true} do
TRUE is always TRUE, it will never be FALSE, therefor the while loop will never end (at least as long it doesn't hit the 10000 loops limit).

In the sirenon.sqf you have to insert this:
_car = _this select 0;

this removeaction SirenOn;
SirenOff = this addaction ["Siren Off", "SirenOff.sqf"];
DCV_siren = true;
While {DCV_siren} do
{
0 fadesound 1; _car say "SirenPolice";
sleep 5;
};
and in the sirenoff.sqf you add this:
_car = _this select 0;

DCV_siren = false;
0 fadesound 1; _car say "SirenOff";

this removeaction SirenOff;
SirenOn = _car addaction ["Siren On", "SirenOn.sqf"];


Author Message


Posts: 189
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 24
In-game name:

 
#11 Posted at 2008-05-02 22:19        
     
thanks!

works!

This post was edited by DaChevs (2008-05-03 02:08, ago)


Author Message


Posts: 54
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#12 Posted at 2008-05-03 05:32        
     
DaChevs :

DaChevs, I clicked your RPG link with great interest. But, when I got to the second line: "DO NOT ABUSE THIS, it will get you kicked and possibly banned", I could read no more.

Banning should not be a feature that is purposely built into video games. Instead, having fun should be built in.

Spend your enthusiasm to assist others wisely, as the cost of ignorant rejection and small minded ridicule can quickly bankrupt it.

Author Message


Posts: 189
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 24
In-game name:

 
#13 Posted at 2008-05-03 05:57        
     
Banning is not something I enjoy.

Those I put up a while back, hasn't been updated.

But on that note, having played RPG missions, and seeing how people spam and talk smack there, it really get annoying.

RPG is not a deathmatch gametype

it's updated now.

This post was edited by DaChevs (2008-05-03 06:02, ago)


Author Message


Posts: 3
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#14 Posted at 2009-01-24 14:56        
     
OK, I do not understand one word of script code, or how to put it in the game. Can someone please help me out here? How would I put this into the game.


Author Message


Posts: 1
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#15 Posted at 2014-05-19 07:40        
     
anyway to make ai from dzai use the siren when they spawn? if they in a certain heli?