Frictional Games Forum (read-only)

Full Version: a funtion with the same name and parameter already exists
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)chweaw Wrote: [ -> ]I want to learn more.

Then do research on function overloading.
(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 Smile 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?
(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.
Here you go. This should do the trick! Smile

////////////////////////////
// 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-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
btw, Callbacks should be in OnStart since usually you only want the callbacks to happen the first time you enter the map Smile if it's on enter it calls every time you enter the map
(04-25-2012, 12:19 PM)TeamSD Wrote: [ -> ]Here you go. This should do the trick! Smile

////////////////////////////
// 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 Blush