Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i need some help/ explaination
Headless Offline
Junior Member

Posts: 20
Threads: 3
Joined: Dec 2014
Reputation: 0
#1
i need some help/ explaination

Can someone help me with this code
Can anyone help me plz.
dont know why its wrong:/

Can you guys also explain to me why its wrong?
thx guys.

Btw i get error (14,1) : ERR : Uncexpected token'{'

But its hould be there right?
-----------------------------------------------------------------------------------------------------


void OnStart()
{
AddUseItemCallback("", "SoundDoor", "DoorSlam", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

void DOORopenSOUND(string& asName, string& asSound);
{
SetLevelDoorLockedSound(string& asName, string& asSound, true);
}
12-24-2014, 01:28 AM
Find
Kurton Offline
Senior Member

Posts: 533
Threads: 8
Joined: Oct 2010
Reputation: 16
#2
RE: i need some help/ explaination

Take the semicolon off the end of your DOORopenSOUND syntax.

Also this should be in Support

12-24-2014, 02:13 AM
Find
Headless Offline
Junior Member

Posts: 20
Threads: 3
Joined: Dec 2014
Reputation: 0
#3
RE: i need some help/ explaination

Like this???

void OnStart()
{
AddUseItemCallback("", "SoundDoor", "DoorSlam", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

void DOORopenSOUND
{
SetLevelDoorLockedSound(string& asName, string& asSound)
}

bc now i get a error (14,1) : ERR : Exprected '('
12-24-2014, 11:08 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#4
RE: i need some help/ explaination

PHP Code: (Select All)
void DOORopenSOUND 
{
    
SetLevelDoorLockedSound(stringasNamestringasSound)


Two problems here.
First is at the void DOORopenSOUND. There should have been the callback syntax. Because the function used was AddUseItemCallback, use (string &in asItem, string &in asEntity) as it's callback.

Second is at the SetLevelDoorLockedSound function. You need to fill the parameters in. Like what asName is, what asSound is, etc. You're also missing a semicolon.

And that's it.


OR!
Ignore everything I said above and just copy-paste the script below.

Spoiler below!

PHP Code: (Select All)
void DOORopenSOUND(string &in asItemstring &in asEntity)
{
    
SetLevelDoorLockedSound("LevelDoor""SoundFile"); ///Note: I'm not sure if SoundFile uses an extension or not.



"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 12-24-2014, 12:37 PM by PutraenusAlivius.)
12-24-2014, 12:34 PM
Find
Headless Offline
Junior Member

Posts: 20
Threads: 3
Joined: Dec 2014
Reputation: 0
#5
RE: i need some help/ explaination

okay thx i will try it out

Oh i screwed up kinda, sorry.
What i wanted is when you try to open this door.
Another door slammed open.

Dont know how to code this so lookin at engine scripts but didnt read it properly
thanks anyways.
i will keep searching how to do it
(This post was last modified: 12-24-2014, 12:51 PM by Headless.)
12-24-2014, 12:43 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#6
RE: i need some help/ explaination

(12-24-2014, 12:43 PM)Headless Wrote: Oh i screwed up kinda, sorry.
What i wanted is when you try to open this door.
Another door slammed open.

Oh, like uh..
You have two doors, both locked. On the left is Door A and on the right is Door B. If you interact with Door B, nothing happens. But if you try to pull or push Door A, Door B will slam open, is that what you mean?

If it is, then I could probably do it.

"Veni, vidi, vici."
"I came, I saw, I conquered."
12-24-2014, 01:50 PM
Find
Headless Offline
Junior Member

Posts: 20
Threads: 3
Joined: Dec 2014
Reputation: 0
#7
RE: i need some help/ explaination

void OnStart()
{
AddUseItemCallback("Player", "DoorLocked", "DoorOpenSlamming", "DOORopen", true);
AddUseItemCallback("", "DoorLocked", "SlammingSound", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

void DOORopen(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("DoorOpenSlamming", false, false);
SetSwingDoorDisableAutoClose("DoorOpenSlamming", true);

PlaySoundAtEntity("SlammingSound", "joint_door_move_special.snt", "DoorOpenSlamming", false);

Addtimer("", 2, "TimerStopSound");
AddTimer("DoorOpenSlamming", 0, "TimerMoveDoor");
}

void TimerMoveDoor(string &in asTimer)
{
if(GetLocalVarInt("VarDoor") == 10) return;
AddLocalVarInt("VarDoor", 1);

AddTimer(asTimer, 0.03, "TimerMoveDoor");

AddPropForce(asTimer, -70, 0, 0, "world");
}

void TimerStopSound(string &in asTimer)
{
StopSound("SlammingSound", 0.4);
}
I think im closer but im lost again

Yes exactly that!

DoorOpenSlamming>DoorB ..........................................Doorlocked>DoorA
----------------------------------------------------------------------------00000--
0
0
0
---------------------------------------------------------------------------00000--
.................................................................................................Door:Where you enter the room
(This post was last modified: 12-24-2014, 02:05 PM by Headless.)
12-24-2014, 01:52 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#8
RE: i need some help/ explaination

Spoiler below!

PHP Code: (Select All)
void OnStart()
{
    
SetLocalVarInt("DoorVar"0);
    
SetSwingDoorLocked("Door_A"truetrue);
    
SetSwingDoorLocked("Door_B"truetrue);
    
SetEntityPlayerInteractCallback("Door_A""Slam_Door_B"false);
}

void Slam_Door_B(string &in asEntity)
{
    
AddLocalVarInt("DoorVar"1);
    
DoorCheck();
}

void DoorCheck()
{
    if(
GetLocalVarInt("DoorVar") == 10//Indicates you have to interact with it ten(10) times
    
{
        
AddTimer("Slam"2.75f"Slam");
    }
}

void Slam(string &in asTimer)
{
    
SetSwingDoorLocked("Door_B"falsefalse);
    
AddPropForce("Door_B"000"World"); //Change the Z or X argument (X is the first zero, Z is the last zero) to fit your door's alignment



That's my take on this. Untested. If something doesn't fit what you want, go ahead and give me a PM.

"Veni, vidi, vici."
"I came, I saw, I conquered."
12-24-2014, 02:08 PM
Find
Headless Offline
Junior Member

Posts: 20
Threads: 3
Joined: Dec 2014
Reputation: 0
#9
RE: i need some help/ explaination

Thanks Im gonna test it right away

changed my door names to Door_A and Door_B Sound to Slam right?

ANd i get error 14.1

void OnStart()
{
AddUseItemCallback("Player", "DoorLocked", "DoorOpenSlamming", "DOORopen", true);
AddUseItemCallback("", "DoorLocked", "SlammingSound", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

{ //here
SetLocalVarInt("DoorVar", 0);
SetSwingDoorLocked("Door_A", true, true);
SetSwingDoorLocked("Door_B", true, true);
SetEntityPlayerInteractCallback("Door_A", "Slam_Door_B", false);
}

void Slam_Door_B(string &in asEntity)
{
AddLocalVarInt("DoorVar", 1);
DoorCheck();
}

void DoorCheck()
{
if(GetLocalVarInt("DoorVar") == 10) //Indicates you have to interact with it ten(10) times
{
AddTimer("Slam", 2.75f, "Slam");
}
}

void Slam(string &in asTimer)
{
SetSwingDoorLocked("Door_B", false, false);
AddPropForce("Door_B", -1, 0, 0, "World"); //Change the Z or X argument (X is the first zero, Z is the last zero) to fit your door's alignment
}

Maybe i think i didnt put it in right but not sure how to do it

Sorry im kinda new to scripting and mostly use tutorials and trail and error.
(This post was last modified: 12-24-2014, 02:25 PM by Headless.)
12-24-2014, 02:14 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#10
RE: i need some help/ explaination

PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("Player""DoorLocked""DoorOpenSlamming""DOORopen"true);
    
AddUseItemCallback("""DoorLocked""SlammingSound""DOORopenSOUND"true);
    
AddUseItemCallback("""Key""Door""UseKeyOnDoor"true);
    
SetLocalVarInt("DoorVar"0);
    
SetSwingDoorLocked("Door_A"truetrue);
    
SetSwingDoorLocked("Door_B"truetrue);
    
SetEntityPlayerInteractCallback("Door_A""Slam_Door_B"false);
}

void UseKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
RemoveItem(asItem);
}

void Slam_Door_B(string &in asEntity)
{
    
AddLocalVarInt("DoorVar"1);
    
DoorCheck();
}

void DoorCheck()
{
    if(
GetLocalVarInt("DoorVar") == 10//Indicates you have to interact with it ten(10) times
    
{
        
AddTimer("Slam"2.75f"Slam");
    }
}

void Slam(string &in asTimer)
{
    
SetSwingDoorLocked("Door_B"falsefalse);
    
AddPropForce("Door_B", -100"World"); //Change the Z or X argument (X is the first zero, Z is the last zero) to fit your door's alignment


Corrected.


Here's a lesson.
Spoiler below!

ALL FUNCTIONS MUST EXIST IN A CALLBACK FUNCTION. So stuff like SetSwingDoorLocked or AddTimer must be inside things like:
void Function(parameter)
{
//Function//
}

If you see two void OnStarts that are conflicting, put the functions in the secondary OnStart. So if you see:
//Primary OnStart//
void OnStart()
{
//Function A..//
}
AND
//Secondary OnStart
void OnStart()
{
//Function B..
}

that, eliminate the second OnStart and put the functions in the secondary OnStart to the primary OnStart. In the end it should look like:
//Primary OnStart//
void OnStart()
{
//Function A...//
//Function B...// <- Function from second OnStart
}


"Veni, vidi, vici."
"I came, I saw, I conquered."
12-24-2014, 02:43 PM
Find




Users browsing this thread: 2 Guest(s)