I'm pretty certain this script should work as I intend it to work:-
First time speaking to character plays speech dHospital1,
Second and every other time without Global Int 12 set to 1 should play speech dHospital 2,
And finally if Global Int is set to 1 then it should play dHospital3 once then switch back to dHospital2
function cSchoolkid_Talk()
{
if (GetGlobalInt(10) ==1) {
player.Walk(278, 89, eBlock);
player.Walk(277, 89, eBlock);
dHospital2.Start();
}
if (GetGlobalInt(12) ==1) {
player.Walk(278, 89, eBlock);
player.Walk(277, 89, eBlock);
dHospital3.Start();
player.AddInventory(iCorpseID);
player.AddInventory(iMetal);
GiveScore(2);
SetGlobalInt(12, 2);
SetGlobalInt(10, 1);
}
else {
player.Walk(278, 89, eBlock);
player.Walk(277, 89, eBlock);
dHospital1.Start();
SetGlobalInt(10, 1);
SetGlobalInt(11, 1);
}
}
However, after ending dHospital2 it straight away goes to dHospital1, as if it's meant to play both instead of just dHospital2.
I've checked the dialog commands in dHospital2 and there isn't anything that says to change to dHospital1. If anyone understands how to make it stop going straight to dHospital1 after dHospital2 please tell me how to correct it. Thanks.
function cSchoolkid_Talk(){
if ((GetGlobalInt(10)!=1) && (GetGlobalInt(12)!=1)) {
player.Walk(278, 89, eBlock);
player.Walk(277, 89, eBlock);
dHospital1.Start();
SetGlobalInt(10, 1);
SetGlobalInt(11, 1);
return;
}
if (GetGlobalInt(10) ==1) {
player.Walk(278, 89, eBlock);
player.Walk(277, 89, eBlock);
dHospital2.Start();
}
if (GetGlobalInt(12) ==1) {
player.Walk(278, 89, eBlock);
player.Walk(277, 89, eBlock);
dHospital3.Start();
player.AddInventory(iCorpseID);
player.AddInventory(iMetal);
GiveScore(2);
SetGlobalInt(12, 2);
SetGlobalInt(10, 1);
return;
}
}
Hopefully that helps.
If you want three mutually exclusive cases, you have to use "if ... else if ... else".
I'd do:
function cSchoolkid_Talk() {
player.Walk(277, 89, eBlock);
player.FaceLocation(276, 89, eBlock); // make player face left
if (GetGlobalInt(10)==0) {
SetGlobalInt(10, 1);
dHospital1.Start();
}
else if (GetGlobalInt(10)==1) {
dHospital2.Start();
}
else {
player.AddInventory(iCorpseID);
player.AddInventory(iMetal);
GiveScore(2);
SetGlobalInt(10, 1);
SetGlobalInt(12, 2);
dHospital3.Start();
}
}
To play the third dialog, use SetGlobalInt(10, 2);.
Thanks very much. I'll try them both.
I think you should try Khris first.. just a hunch but mine works as well. I might have misinterpreted something..
Yeah there was one problem with yours (minor) it was that you didn't input SetGlobalInt(11,1) but I changed it and it works fine.
I didn't try Khris's because I didn't understand what he had done so I tried yours first.
I just didn't understand what !=1) means, whats the ! for?
!= it's the opposite of ==
So that means that my line of code checks that the values of both ints aren't 1 and does some functions.Glad i helped. Rather change the topic name to solved rather than add a thumb but that's fine as well. Glad we helped.
Thanks alot. I only put the thumbs up so if people search speech problem then they know which ones have been solved by looking at the thumb. Either way it works i suppose but thanks alot anyway