Modme Forums

Need help on a script

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: TrueGamerCalls
I'm trying to make a PAP system where you have to activate 4 switches in order to open PAP. I plan to use the level varibles (Forget my post about the flags) and when all four switches are detected, it will delete a door that leads to PAP. My issue is that the triggers are working perfectly, but the door isn't deleting, I'm not the best at scripting so I don't know what errors I made besides what the launcher tells me

function papswitch1()
{ 
  switcht1 = GetEnt("switcht1", "targetname"); 
  //Declare item model
  switchm1 = GetEnt("switchm1", "targetname");
  //Set Hintstring for item trigger
  switcht1 SetHintString("Hold &&1 To Activate Switch");
  //Remove hand icon for item trigger
  switcht1 SetCursorHint("HINT_NOICON");
  //Wait for player to action item trigger
  switcht1 waittill("trigger", player);
  level.pswitches ++;
  player.score += 100;
  switcht1 Delete();
  switchm1 Delete();
}

function pswitch2()
{
  switcht2 = GetEnt("switcht2", "targetname");
  switcht2 SetHintString("Hold &&1 To Activate Switch");
  switcht2 SetCursorHint("HINT_NOICON");
  switcht2 waittill("trigger", player);
  level.pswitches ++;
  player.score += 100;
  switcht2 Delete();  
}

function papswitch3()
{
  switcht3 = GetEnt("switcht3", "targetname");
  switcht3 SetHintString("Hold &&1 To Activate Switch");
  switcht3 SetCursorHint("HINT_NOICON");
  switcht3 waittill("trigger", player);
  level.pswitches ++;
  player.score += 100;
  switcht3 Delete();  
}

function papswitch4()
{
  switcht4 = GetEnt("switcht4", "targetname");
  switcht4 SetHintString("Hold &&1 To Activate Switch");
  switcht4 SetCursorHint("HINT_NOICON");
  switcht4 waittill("trigger", player);
  level.pswitches ++;
  player.score += 100;
  switcht4 Delete();  
}

function papunlock()
{ 
  if(level.pswitches == 4)	
  {
	 switchdoor = GetEntArray("easter_egg_door","targetname");	//door parts array
     switchdoor Delete();
  }
}


ModmeBot:

Reply By: VoltiK
I have taken a look at your script and amended it. I have made your papunlock function into a while(1) and called the thread on the player after each trigger has been used and points have been given.

<sub>function papswitch1()</sub>
<sub>{ </sub>
<sub> switcht1 = GetEnt("switcht1", "targetname"); </sub>
<sub> //Declare item model</sub>
<sub> switchm1 = GetEnt("switchm1", "targetname");</sub>
<sub> //Set Hintstring for item trigger</sub>
<sub> switcht1 SetHintString("Hold &&1 To Activate Switch");</sub>
<sub> //Remove hand icon for item trigger</sub>
<sub> switcht1 SetCursorHint("HINT_NOICON");</sub>
<sub> //Wait for player to action item trigger</sub>
<sub> switcht1 waittill("trigger", player);</sub>
<sub> level.pswitches ++;</sub>
<sub> player.score += 100;</sub>
<sub>//Added script to check progession on switches..</sub>
<sub> thread papunlock(player);</sub>
<sub>switcht1 Delete();</sub>
<sub> switchm1 Delete();</sub>
<sub>}</sub>
<sub>function pswitch2()</sub>
<sub>{</sub>
<sub> switcht2 = GetEnt("switcht2", "targetname");</sub>
<sub> switcht2 SetHintString("Hold &&1 To Activate Switch");</sub>
<sub> switcht2 SetCursorHint("HINT_NOICON");</sub>
<sub> switcht2 waittill("trigger", player);</sub>
<sub> level.pswitches ++;</sub>
<sub> player.score += 100;</sub>
<sub>//Added script to check progession on switches..</sub>
<sub> thread papunlock(player);</sub>
<sub>switcht2 Delete(); </sub>
<sub>}</sub>
<sub>function papswitch3()</sub>
<sub>{</sub>
<sub> switcht3 = GetEnt("switcht3", "targetname");</sub>
<sub> switcht3 SetHintString("Hold &&1 To Activate Switch");</sub>
<sub> switcht3 SetCursorHint("HINT_NOICON");</sub>
<sub> switcht3 waittill("trigger", player);</sub>
<sub> level.pswitches ++;</sub>
<sub> player.score += 100;</sub>
<sub>//Added script to check progession on switches..</sub>
<sub> thread papunlock(player);</sub>
<sub>switcht3 Delete(); </sub>
<sub>}</sub>
<sub>function papswitch4()</sub>
<sub>{</sub>
<sub> switcht4 = GetEnt("switcht4", "targetname");</sub>
<sub> switcht4 SetHintString("Hold &&1 To Activate Switch");</sub>
<sub> switcht4 SetCursorHint("HINT_NOICON");</sub>
<sub> switcht4 waittill("trigger", player);</sub>
<sub> level.pswitches ++;</sub>
<sub> player.score += 100;</sub>
<sub>//Added script to check progession on switches..</sub>
<sub> thread papunlock(player);</sub>
<sub>switcht4 Delete(); </sub>
<sub>}</sub>
<sub>function papunlock(player)</sub>
<sub>{</sub>
<sub> while(1)</sub>
<sub> {</sub>
<sub> self waittill(level.pswitches >= 4);</sub>
<sub> if(level.pswitches == 4)</sub>
<sub> {</sub>
<sub> switchdoor = GetEntArray("easter_egg_door","targetname"); //door parts array</sub>
<sub> switchdoor Delete();</sub>
<sub> }</sub>
<sub> break;</sub>
<sub> }</sub>
<sub>}</sub>


ModmeBot:

Reply By: Scorpiolo

TrueGamerCalls
I'm trying to make a PAP system where you have to activate 4 switches in order to open PAP. I plan to use the level varibles (Forget my post about the flags) and when all four switches are detected, it will delete a door that leads to PAP. My issue is that the triggers are working perfectly, but the door isn't deleting, I'm not the best at scripting so I don't know what errors I made besides what the launcher tells me function papswitch1() { switcht1 = GetEnt("switcht1", "targetname"); //Declare item model switchm1 = GetEnt("switchm1", "targetname"); //Set Hintstring for item trigger switcht1 SetHintString("Hold &&1 To Activate Switch"); //Remove hand icon for item trigger switcht1 SetCursorHint("HINT_NOICON"); //Wait for player to action item trigger switcht1 waittill("trigger", player); level.pswitches ++; player.score += 100; switcht1 Delete(); switchm1 Delete(); } function pswitch2() { switcht2 = GetEnt("switcht2", "targetname"); switcht2 SetHintString("Hold &&1 To Activate Switch"); switcht2 SetCursorHint("HINT_NOICON"); switcht2 waittill("trigger", player); level.pswitches ++; player.score += 100; switcht2 Delete(); } function papswitch3() { switcht3 = GetEnt("switcht3", "targetname"); switcht3 SetHintString("Hold &&1 To Activate Switch"); switcht3 SetCursorHint("HINT_NOICON"); switcht3 waittill("trigger", player); level.pswitches ++; player.score += 100; switcht3 Delete(); } function papswitch4() { switcht4 = GetEnt("switcht4", "targetname"); switcht4 SetHintString("Hold &&1 To Activate Switch"); switcht4 SetCursorHint("HINT_NOICON"); switcht4 waittill("trigger", player); level.pswitches ++; player.score += 100; switcht4 Delete(); } function papunlock() { if(level.pswitches == 4) { switchdoor = GetEntArray("easter_egg_door","targetname"); //door parts array switchdoor Delete(); } }

This version should work better, I'm not sure why you'd have multiple pap door models but here you go, this will work far better than the one above, just thread the function init to initiate it

function init()
{
  thread papswitch1()
  thread papswitch2()
  thread papswitch3()
  thread papswitch4()
}

function papswitch1()
{ 
  switcht1 = GetEnt("switcht1", "targetname"); 
  switchm1 = GetEnt("switchm1", "targetname");
  switcht1 SetHintString("Hold &&1 To Activate Switch");
  switcht1 SetCursorHint("HINT_NOICON");
  switcht1 waittill("trigger", player);

  level.pswitches++;
  player.score += 100;
  switcht1 Delete();
  switchm1 Delete();
  papunlock()
}

function papswitch2()
{ 
  switcht2 = GetEnt("switcht2", "targetname"); 
  switchm2 = GetEnt("switchm2", "targetname");
  switcht2 SetHintString("Hold &&1 To Activate Switch");
  switcht2 SetCursorHint("HINT_NOICON");
  switcht2 waittill("trigger", player);

  level.pswitches++;
  player.score += 100;
  switcht2 Delete();
  switchm2 Delete();
  papunlock()
}

function papswitch3()
{ 
  switcht3 = GetEnt("switcht3", "targetname"); 
  switchm3 = GetEnt("switchm3", "targetname");
  switcht3 SetHintString("Hold &&1 To Activate Switch");
  switcht3 SetCursorHint("HINT_NOICON");
  switcht3 waittill("trigger", player);

  level.pswitches++;
  player.score += 100;
  switcht3 Delete();
  switchm3 Delete();
  papunlock()
}

function papswitch4()
{ 
  switcht4 = GetEnt("switcht4", "targetname"); 
  switchm4 = GetEnt("switchm4", "targetname");
  switcht4 SetHintString("Hold &&1 To Activate Switch");
  switcht4 SetCursorHint("HINT_NOICON");
  switcht4 waittill("trigger", player);

  level.pswitches++;
  player.score += 100;
  switcht4 Delete();
  switchm4 Delete();
  papunlock()
}

function papunlock()
{ 
  if(level.pswitches == 4)	
  {
     switchdoor = GetEntArray("easter_egg_door","targetname");
     for(i=0;i<switchdoor.size;i++) {="" switchdoor[i]="" delete();="" }="" }=""></switchdoor.size;i++)>


ModmeBot:

Reply By: Scorpiolo

VoltiK
I have taken a look at your script and amended it. I have made your papunlock function into a while(1) and called the thread on the player after each trigger has been used and points have been given. function papswitch1(){ switcht1 = GetEnt("switcht1", "targetname"); //Declare item model switchm1 = GetEnt("switchm1", "targetname"); //Set Hintstring for item trigger switcht1 SetHintString("Hold &&1 To Activate Switch"); //Remove hand icon for item trigger switcht1 SetCursorHint("HINT_NOICON"); //Wait for player to action item trigger switcht1 waittill("trigger", player); level.pswitches ++; player.score += 100; //Added script to check progession on switches.. thread papunlock(player); switcht1 Delete(); switchm1 Delete();} function pswitch2(){ switcht2 = GetEnt("switcht2", "targetname"); switcht2 SetHintString("Hold &&1 To Activate Switch"); switcht2 SetCursorHint("HINT_NOICON"); switcht2 waittill("trigger", player); level.pswitches ++; player.score += 100; //Added script to check progession on switches.. thread papunlock(player); switcht2 Delete(); } function papswitch3(){ switcht3 = GetEnt("switcht3", "targetname"); switcht3 SetHintString("Hold &&1 To Activate Switch"); switcht3 SetCursorHint("HINT_NOICON"); switcht3 waittill("trigger", player); level.pswitches ++; player.score += 100; //Added script to check progession on switches.. thread papunlock(player); switcht3 Delete(); } function papswitch4(){ switcht4 = GetEnt("switcht4", "targetname"); switcht4 SetHintString("Hold &&1 To Activate Switch"); switcht4 SetCursorHint("HINT_NOICON"); switcht4 waittill("trigger", player); level.pswitches ++; player.score += 100; //Added script to check progession on switches.. thread papunlock(player); switcht4 Delete(); } function papunlock(player){ while(1) { self waittill(level.pswitches >= 4); if(level.pswitches == 4) { switchdoor = GetEntArray("easter_egg_door","targetname"); //door parts array switchdoor Delete(); } break; }}

I don't think that will actually work and a lot of that code is pretty unnecessary


ModmeBot:

Reply By: Harry Bo21
nor will the code you posted

lines 3 - 7 all have syntax errors for a start


ModmeBot:

Reply By: Scorpiolo

Harry Bo21
nor will the code you postedlines 3 - 7 all have syntax errors for a start

Yeah realised that after I posted but was in class so couldn't change but I'm pretty sure the rest is fine, there are more efficient solutions but still. All the threads and the pap unlock lines need semi colons added to the end for the fix


ModmeBot:

Reply By: TrueGamerCalls

Scorpiolo
Harry Bo21 nor will the code you postedlines 3 - 7 all have syntax errors for a start Yeah realised that after I posted but was in class so couldn't change but I'm pretty sure the rest is fine, there are more efficient solutions but still. All the threads and the pap unlock lines need semi colons added to the end for the fix

Nope,

I fixed all the syntax errors, threaded the init, did everything and it still doesn't work. I even added the papunlock(); into the init and it still doesn't work, triggers work fine though.


ModmeBot:

Reply By: Harry Bo21

level.pswitches


doesnt seem to have been defined anywhere

so its trying to do

"undefined" + 1


ModmeBot:

Reply By: TrueGamerCalls

Harry Bo21
level.pswitches doesnt seem to have been defined anywhere so its trying to do"undefined" + 1

lol forgot about that, I just defined it and it worked.

Thanks for your help :)