Frictional Games Forum (read-only)

Full Version: Script Problem...please help?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
////////////////////////////
// Run when entering map
void OnEnter()
{
        PlayMusic("amb_safe.ogg", true, 0.5, 5, 0, true);
        GivePlayerDamage(50, "", false, true);
        AddUseItemCallback("", "crowbar", "closet", "KeyOnDoor1", true);
        AddUseItemCallback("", "HallKey", "hall", "KeyOnDoor2", true);
        AddUseItemCallback("", "artroomkey", "artroom", "KeyOnDoor3", true);
        AddUseItemCallback("", "pathwaytolabkey", "pathtolab", "KeyOnDoor4", true);
        SetLevelDoorLockedText("pathtolab", "Doors", "Door_pathtolab_Name");
        SetLevelDoorLockedText("frontdoor", "Doors", "Door_frontdoor_Name");
        AddEntityCollideCallback("Player", "readnote", "AddQuest", true, 1);
        AddEntityCollideCallback("Player", "nighttime", "SetMessage", true, 1);
        SetEntityCallbackFunc("fromfriend", "OnPickup");
        SetEntityCallbackFunc("lantern", "OnPickup1");
        SetMessage("MessageDisplay", "Message_wakingup_Name", 5.0f);
        StartPlayerLookAt("fromfriend", 2.0f, 2.0f, "");
        AddTimer("", 5.0f, "stoplook");
}

void     SetMessage(string& asTextCategory, string& asTextEntry, float afTime);
{
        SetMessage("MessageDisplay", "Message_nighttime_Name", 5.0f);
}

The problem is the "void SetMessage (and so on till the } bracket)". Everytime i run the map with this command, it crashes and gives me an error, however, when i remove it, it runs perfectly normal...can anyone help me and see whats the problem? thanks.

BTW, i included a picture of the error it gives me.
(08-10-2011, 06:14 AM)Xvideogamer720X Wrote: [ -> ]void SetMessage(string& asTextCategory, string& asTextEntry, float afTime);
{
SetMessage("MessageDisplay", "Message_nighttime_Name", 5.0f);
}

Improper name and signatures there (bolded text). Looks like a copy-paste typo to me. Also, the semicolon after the void function's name causes an error. You also need to add an OnStart() function and an OnLeave() function.

Also, I saw you added item callbacks and such in OnEnter. This is a bad idea, since if the player leaves the area and returns later on, they'll be able to use the items again, perhaps giving them unlimited sanity or allowing them to do other weird things. Put these callback declarations into your OnStart function instead. This way the player will only be able to use an item once (unless you add another callback with script).

(08-10-2011, 07:22 AM)palistov Wrote: [ -> ]
(08-10-2011, 06:14 AM)Xvideogamer720X Wrote: [ -> ]void SetMessage(string& asTextCategory, string& asTextEntry, float afTime);
{
SetMessage("MessageDisplay", "Message_nighttime_Name", 5.0f);
}

Improper name and signatures there (bolded text). Looks like a copy-paste typo to me. Also, the semicolon after the void function's name causes an error. You also need to add an OnStart() function and an OnLeave() function.

Alright then ill try that out right now. Oh by the way, i do have those OnStart and OnLeave functions (except onstart was onenter...but ill change that) its just i didnt include it in the text (to make the text shorter, because i think copying the WHOLE script is too much...isnt it? :p)

Quote:Also, I saw you added item callbacks and such in OnEnter. This is a bad idea, since if the player leaves the area and returns later on, they'll be able to use the items again, perhaps giving them unlimited sanity or allowing them to do other weird things. Put these callback declarations into your OnStart function instead. This way the player will only be able to use an item once (unless you add another callback with script).

Ohhhhhhhhhhhhh that explains why everyone uses OnStart! Thank you so much for explaining! Smile

EDIT1: Thank you soooooo much! It worked! Gah, i hate it when i cant find those small problems in the scripts (and trust me i was looking for them) and all the trouble was caused by the darn ";" sign -_- and not to mention i have other void commands and i could have just looked at them and see that they dont have the ";" sign -_- :p well anyways another problem solved thanks to you, friend!