Adrianis
Senior Member
Posts: 620
Threads: 6
Joined: Feb 2012
Reputation:
27
|
RE: check if active/ string to int
(03-25-2013, 10:00 AM)Knusper. Wrote: ok, i found the problem, i didnt wrote void MyFunc(string &in asTimer)
I can't see anywhere in your script that you are using a timer, are you sure that that is the problem?
(03-25-2013, 10:00 AM)Knusper. Wrote: Now only At
void FadeOut1(string &in asParent, string &in asChild, int alState)
{
IsInArea = false;
string areanumber2 = StringSub(asChild, 11, 2);
int i1, i2;
i2 = areanumber2[0] *10 + areanumber2[1];
i1 = LastArea[0] *10 + LastArea[1];
if(i1 == i2 - 10)
{
AddDebugMessage("fade", false);
LastArea = areanumber2;
}
}
He sometimes shows the message and sometimes he does not.
Is there any particular reason you need to store the locations like areanumber and LastArea as strings, and not int's?
Did you write all of this script yourself, or has it been copied & pasted from other places?
|
|
03-25-2013, 01:09 PM |
|
Knusper.
Member
Posts: 58
Threads: 7
Joined: Feb 2013
Reputation:
2
|
RE: check if active/ string to int
Yes, it all has to be.
And the timer works now, before i changed it it didnt work.
And I write all scripts myself, just with help of the engine scripts.
Here is the complete script:
void OnEnter()
{
PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);
}
void OnStart()
{
for (int i = 0; i < 10; i++)
{
AddEntityCollideCallback("Player" , "ScriptArea_" + 0 + i , "InArea" , true , 1);
}
for (int i = 11; i < 20; i++)
{
for (int j = 1; j < 5; j++)
AddEntityCollideCallback("Player" , "ScriptArea_" + i + "." + j, "FadeOut1" , true , 1);
}
SetSanityDrainDisabled(true);
AddEntityCollideCallback("Player" , "Music2" , "secondmusic" , true , 1);
AddEntityCollideCallback("Player" , "activeslendy_1" , "Slender1" , true , 1);
AddEntityCollideCallback("Player" , "activeslendy_2" , "Slender2" , true , 1);
}
bool IsInArea = false;
bool Slender_1active = false;
bool Slender_2active = false;
string LastArea = "00";
void secondmusic (string &in asParent, string &in asChild, int alState)
{
StopMusic(0.0f, 1);
PlayMusic("Slender 2.ogg", true, 1.0f, 0.0f, 2, true);
}
void Slender1 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Slender_1", true);
Slender_1active = true;
AddDebugMessage("active", false);
}
void Slender2 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Slender_2", true);
Slender_2active = true;
AddDebugMessage("active2", false);
}
void InArea(string &in asParent, string &in asChild, int alState)
{
string areanumber1 = StringSub(asChild, 11, 2);
if ("Slender_" + areanumber1[1] + active)
{
AddDebugMessage("InArea > if statement executing", false);
IsInArea = true;
LastArea = areanumber1;
AddTimer("Dead", 3, "Dead");
}
}
void Dead(string &in asTimer)
{
if(IsInArea == true)
{
FadeOut(0.5);
SetPlayerHealth(0);
}
}
void FadeOut1(string &in asParent, string &in asChild, int alState)
{
IsInArea = false;
string areanumber2 = StringSub(asChild, 11, 2);
int i1, i2;
i2 = areanumber2[0] *10 + areanumber2[1]; //LastArea 2 als int
i1 = LastArea[0] *10 + LastArea[1]; //LastArea 1 als int
if(i1 == i2 - 10)
{
//FadeOut
AddDebugMessage("fade", false);
LastArea = areanumber2;
}
}
void OnLeave ()
{
SetupLoadScreen("", "", 5, "");
}
No one knows, how "I" goes.
(This post was last modified: 03-25-2013, 01:32 PM by Knusper..)
|
|
03-25-2013, 01:29 PM |
|
Knusper.
Member
Posts: 58
Threads: 7
Joined: Feb 2013
Reputation:
2
|
RE: check if active/ string to int
Now i think i got it.
It seems to work correctly.
Here it is: (after 3 hours of working )
void OnEnter()
{
PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);
}
void OnStart()
{
for (int i = 0; i < 10; i++)
{
AddEntityCollideCallback("Player" , "ScriptArea_" + 0 + i , "InArea" , false , 1);
}
for (int i = 11; i < 20; i++)
{
for (int j = 1; j < 5; j++)
AddEntityCollideCallback("Player" , "ScriptArea_" + i + "." + j, "FadeOut1" , false , 1);
}
SetSanityDrainDisabled(true);
AddEntityCollideCallback("Player" , "Music2" , "secondmusic" , true , 1);
AddEntityCollideCallback("Player" , "activeslendy_1" , "Slender1" , true , 1);
AddEntityCollideCallback("Player" , "activeslendy_2" , "Slender2" , true , 1);
}
bool IsInArea = false;
bool Slender_1active = false;
bool Slender_2active = false;
string Slender_active = "000000000";
string LastArea = "00";
void secondmusic (string &in asParent, string &in asChild, int alState)
{
StopMusic(0.0f, 1);
PlayMusic("Slender 2.ogg", true, 1.0f, 0.0f, 2, true);
}
void Slender1 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Slender_1", true);
Slender_active = "1" + StringSub(Slender_active, 1, 8);
AddDebugMessage("active", false);
AddDebugMessage(Slender_active, false);
}
void Slender2 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Slender_2", true);
Slender_active = StringSub(Slender_active, 0, 1) + "1" + StringSub(Slender_active, 2, 7);
AddDebugMessage("active2", false);
AddDebugMessage(Slender_active, false);
}
void InArea(string &in asParent, string &in asChild, int alState)
{
string areanumber1 = StringSub(asChild, 11, 2);
int i;
i = (areanumber1[0] -48) *10 + areanumber1[1] -48;
AddDebugMessage(Slender_active, false);
if (Slender_active[i-1] == 1 + 48)
{
AddDebugMessage("InArea > if statement executing", false);
IsInArea = true;
LastArea = areanumber1;
AddTimer("Dead", 2, "Dead");
}
}
void Dead(string &in asTimer)
{
if(IsInArea == true)
{
FadeOut(0.3);
SetPlayerHealth(0);
}
}
void FadeOut1(string &in asParent, string &in asChild, int alState)
{
IsInArea = false;
string areanumber2 = StringSub(asChild, 11, 2);
int i1, i2;
i2 = (areanumber2[0] - 48) *10 + areanumber2[1] -48;
i1 = (LastArea[0] - 48) *10 + LastArea[1] -48;
AddDebugMessage("i1 =" + i1, false);
AddDebugMessage("i2 =" + i2, false);
if(i1 == i2 - 10)
{
//FadeOut
AddDebugMessage("fade", false);
LastArea = areanumber2;
}
}
Now I know how to use the ASCII code at:
i2 = (areanumber2[0] - 48) *10 + areanumber2[1] -48;
i1 = (LastArea[0] - 48) *10 + LastArea[1] -48;
Thx all who helped!!!
I think its done.
No one knows, how "I" goes.
(This post was last modified: 03-25-2013, 05:57 PM by Knusper..)
|
|
03-25-2013, 05:56 PM |
|
Adrianis
Senior Member
Posts: 620
Threads: 6
Joined: Feb 2012
Reputation:
27
|
RE: check if active/ string to int
Np, glad to hear it's working!
Post again if it stops working
|
|
03-25-2013, 06:00 PM |
|
Knusper.
Member
Posts: 58
Threads: 7
Joined: Feb 2013
Reputation:
2
|
RE: check if active/ string to int
ok, now i have another problem
I dont hear the sounds i added.
Example:
PlaySoundAtEntity("", "Slender pip.snt", "player", 0, false);
Maybe it has to do something with the priority???
Before all sounds there is:
PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);
But, i dont know how to fix that.
What can it be?
No one knows, how "I" goes.
|
|
03-26-2013, 10:44 AM |
|
Adrianis
Senior Member
Posts: 620
Threads: 6
Joined: Feb 2012
Reputation:
27
|
RE: check if active/ string to int
(03-26-2013, 10:44 AM)Knusper. Wrote: ok, now i have another problem
I dont hear the sounds i added.
Example:
PlaySoundAtEntity("", "Slender pip.snt", "player", 0, false);
Maybe it has to do something with the priority???
Before all sounds there is:
PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);
But, i dont know how to fix that.
What can it be?
The priority of the music shouldn't be a problem - both should be able to play.
Can you post up the text in 'Slender pip.snt'?
|
|
03-26-2013, 11:55 AM |
|
Knusper.
Member
Posts: 58
Threads: 7
Joined: Feb 2013
Reputation:
2
|
RE: check if active/ string to int
<SOUNDENTITY>
<SOUNDS>
<Main>
<Sound File="Slender pip.ogg" />
</Main>
</SOUNDS>
<PROPERTIES Volume="2" MinDistance="0" MaxDistance="30" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="false" Loop="false" Use3D="false" Blockable="false" BlockVolumeMul="0.5" Priority="2" />
</SOUNDENTITY>
No one knows, how "I" goes.
|
|
03-26-2013, 12:10 PM |
|
Adrianis
Senior Member
Posts: 620
Threads: 6
Joined: Feb 2012
Reputation:
27
|
RE: check if active/ string to int
(03-26-2013, 12:10 PM)Knusper. Wrote: <SOUNDENTITY>
<SOUNDS>
<Main>
<Sound File="Slender pip.ogg" />
</Main>
</SOUNDS>
<PROPERTIES Volume="2" MinDistance="0" MaxDistance="30" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="false" Loop="false" Use3D="false" Blockable="false" BlockVolumeMul="0.5" Priority="2" />
</SOUNDENTITY>
I'm not sure if any of these suggestions will fix it but it's all I can suggest for now
- rename both the .ogg and .snt to use a '_' rather than just a space
- remove the .ogg file extension so it reads <Sound File="Slender_pip" />
- if you only have 1 sound, then Random should be "0"
- set the minimum distance to at least 1 (not sure that's necessary, but worth trying!)
Give those a go, let me know if it works or not...
(This post was last modified: 03-26-2013, 12:53 PM by Adrianis.)
|
|
03-26-2013, 12:52 PM |
|
Knusper.
Member
Posts: 58
Threads: 7
Joined: Feb 2013
Reputation:
2
|
RE: check if active/ string to int
tried all but it still doesnt work.
No one knows, how "I" goes.
|
|
03-26-2013, 01:11 PM |
|
Adrianis
Senior Member
Posts: 620
Threads: 6
Joined: Feb 2012
Reputation:
27
|
RE: check if active/ string to int
Hrrrm...
Try with Volume="1", Priority="1", Use3D="True"
|
|
03-26-2013, 01:14 PM |
|
|