chweaw
Junior Member
Posts: 4
Threads: 1
Joined: Apr 2012
Reputation:
0
|
a funtion with the same name and parameter already exists
Ok hi! I know you hear this a lot but I am new to the whole making of customstories and Im not good with scripting. I tried to read some about it but i get dizzy and get headaches so I figured you guys might help me and teach me a thing about this problem of mine.
So what I have done is that I have created an area that closes a door behind me on collision and what I wanted to do next was to make a sound play as i enter the new room.
Script as it looks like so far:
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "Unlock_door", "door_1", 0, false);
RemoveItem("keyl_1");
}
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "DoorCloseFunc1" , true , 1);
}
void DoorCloseFunc1(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("door_1", true, true);
}
void OnStart()
{
PreloadSound("00_laugh.snt");
AddEntityCollideCallback("Player", "ScriptArea_1", "Sound", true, 1);
}
void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "00_laugh.snt", "ScriptArea_1", 0.0, false);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
I get the error 21,1 : a funtion with the same name and parameter already exists
So what should I do? I want to learn more.
|
|
04-24-2012, 11:19 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: a funtion with the same name and parameter already exists
(04-24-2012, 11:19 PM)chweaw Wrote: I want to learn more.
Then do research on function overloading.
|
|
04-24-2012, 11:20 PM |
|
chweaw
Junior Member
Posts: 4
Threads: 1
Joined: Apr 2012
Reputation:
0
|
RE: a funtion with the same name and parameter already exists
(04-24-2012, 11:20 PM)Your Computer Wrote: (04-24-2012, 11:19 PM)chweaw Wrote: I want to learn more.
Then do research on function overloading. Ok, just need the keywords to search and I will thx
(04-24-2012, 11:20 PM)Your Computer Wrote: (04-24-2012, 11:19 PM)chweaw Wrote: I want to learn more.
Then do research on function overloading. You might just think I'm lazy but man, I do not understand how to get this working! could you please just tell me and why so that i can fix my future problems?
(This post was last modified: 04-24-2012, 11:43 PM by chweaw.)
|
|
04-24-2012, 11:31 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: a funtion with the same name and parameter already exists
(04-24-2012, 11:31 PM)chweaw Wrote: You might just think I'm lazy but man, I do not understand how to get this working! could you please just tell me and why so that i can fix my future problems?
You have two void OnStart() functions. You can only have one.
|
|
04-24-2012, 11:57 PM |
|
TeamSD
Member
Posts: 51
Threads: 3
Joined: Apr 2012
Reputation:
2
|
RE: a funtion with the same name and parameter already exists
Here you go. This should do the trick!
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "DoorCloseFunc1" , true , 1);
PreloadSound("00_laugh.snt");
AddEntityCollideCallback("Player", "ScriptArea_1", "Sound", true, 1);
}
void DoorCloseFunc1(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("door_1", true, true);
}
void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "00_laugh.snt", "ScriptArea_1", 0.0, false);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "Unlock_door", "door_1", 0, false);
RemoveItem("keyl_1");
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
|
|
04-25-2012, 12:19 PM |
|
chweaw
Junior Member
Posts: 4
Threads: 1
Joined: Apr 2012
Reputation:
0
|
RE: a funtion with the same name and parameter already exists
(04-24-2012, 11:57 PM)Your Computer Wrote: (04-24-2012, 11:31 PM)chweaw Wrote: You might just think I'm lazy but man, I do not understand how to get this working! could you please just tell me and why so that i can fix my future problems?
You have two void OnStart() functions. You can only have one. But lets say that i have a series of functions that uses the same name, what do i do to make it work? not having multiple void OnStart() functions?
thanks for the help btw
|
|
04-25-2012, 04:06 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: a funtion with the same name and parameter already exists
btw, Callbacks should be in OnStart since usually you only want the callbacks to happen the first time you enter the map if it's on enter it calls every time you enter the map
|
|
04-25-2012, 04:09 PM |
|
chweaw
Junior Member
Posts: 4
Threads: 1
Joined: Apr 2012
Reputation:
0
|
RE: a funtion with the same name and parameter already exists
(04-25-2012, 12:19 PM)TeamSD Wrote: Here you go. This should do the trick!
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "DoorCloseFunc1" , true , 1);
PreloadSound("00_laugh.snt");
AddEntityCollideCallback("Player", "ScriptArea_1", "Sound", true, 1);
}
void DoorCloseFunc1(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("door_1", true, true);
}
void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "00_laugh.snt", "ScriptArea_1", 0.0, false);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "Unlock_door", "door_1", 0, false);
RemoveItem("keyl_1");
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
} Thank you! i really appreciate the help
|
|
04-25-2012, 04:10 PM |
|
|