(10-01-2010, 05:11 PM)LoneWolf Wrote: (please tell me if im doing it wrong, it says line 5 and 15 is wrong)
////////////////////////////Bad
// Run first time starting map
void OnStart()
AddUseItemCallback("", "StudyKey", "castle_arched01_3", "UsedKeyOnDoor",true); (coding is wrong apparently)
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
-----------------------------------------------------------------
good
void CollideScript(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("castle_arched01_2", true, true);
ShowEnemyPlayerPosition("servant_grunt_1");
}
These are examples of a bad function and a good one.
All function follow this rule:
nameOfTheFuncion(parameters)
{
whatTheFunctionDoes1;
whatTheFunctionDoes2;
whatTheFunctionDoesetc;
}
So change the OnStart:
void OnStart()
{
AddUseItemCallback("","StudyKey","castle_arched01_3","UsedKeyOnDoor",true);
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
; (<--don't forget the ;! its important)
}
When i said to remove the {} i meant the one you had around the callback not the ones OnStart. Sorry for the confusion
The 1st error was missing the {} so wrong coding because that wasn't what the program expected.
The 2nd error was because when the {} came they weren't for the OnStart function but the program recognized them as being for the OnStart which lead to an error.
To prevent more confusion here is the code:
Quote:// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "CollideScript", true,1);
AddUseItemCallback("","StudyKey","castle_arched01_3","UsedKeyOnDoor",true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_arched01_3", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_arched01_3", 0, false);
RemoveItem("StudyKey");
}
void CollideScript(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("castle_arched01_2", true, true);
ShowEnemyPlayerPosition("servant_grunt_1");
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
All Add(...) go on the OnStart() function.
The void(...) go outside the OnStart().
void OnStart()
{
This text is inside the OnStart()
}
Void This text is outside the OnStart()
{
}