Results 1 to 10 of 10
  1. #1
    uPaymeiFixit's Avatar
    Join Date
    May 2011
    Gender
    male
    Posts
    6
    Reputation
    10
    Thanks
    0

    Unknown function (Really short code)

    Hey guys. This is, I think my first port here, so... Hi.

    I am new to GSC (Just started learning two days ago) and don't have much previous experience with programming (little bit of vb.net). So I'm teaching myself by doing small things, like toggles using examples from bits of code I find online.

    Today I ran into my first problem I can't seem to solve and would love if somebody could help me out. I will attach only the code I have modified, however I think the problem exists in doTestToggleTwo().

    Code:
    onPlayerSpawned()
    {
    	self endon("disconnect");
    	
    	for(;;)
    	{
    		self waittill("spawned_player"); //Waits for player spawn
    		self iPrintlnBold( "^3Hello World" ); //Mod name
    		wait 1.5;
    		self iPrintln( "^1MD6 ^7version ^11r1826" ); //Mod version
    		wait 1.5;
    		self iPrintln( "Instilizing ^3doSplash() ^1&& ^3doTestToggle ^1&& ^3doTestToggle2" ); //Notification
    		self.testvar=0; //Sets testvar to 0 for toggle
    		self thread doSplash(); //Instilizes doSplash()
    		self thread doTestToggle(); //Instilizes doTestToggle
    		self thread doTestToggleTwo(); //Instilizes doTestToggle2
    		wait 1.5;
    		self iPrintln( "Instilized" ); //Notification
    	}
    }
    
    
    doSplash()
    {
    	self endon("disconnect");
    	self endon("death");
    	
    	wait 1;	
    		notifyData = spawnstruct();
    		notifyData.iconName = "rank_prestige10"; //Icon, 10th prestige
    		notifyData.titleText = "^5GSC ^7by ^2uPayme^0iFixit"; //Line 1
    		notifyData.notifyText = "^3Hello World"; //Line 2
    		notifyData.notifyText2 = "Press ^1actionslot2 ^7for mods"; //Line 3
    		notifyData.glowColor = (2.55, 0.0, 0.0); //RGB Color array divided by 100
    		notifyData.sound = "veh_ac130_sonic_boom"; //Sound, level up sound here
    		self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
    }
    
    
    doTestToggle()
    {
    self endon("disconnect");
    self endon("death");
    	
    self notifyOnPlayerCommand("1", "+actionslot 2"); //Aparantly this is needed when using button press
    for(;;){ //for(;;) allows a loop
    	self waittill("1"); //Waits for actionslot 2 to be pressed
    	if (self.testvar==0) //Begin my favorite toggle logic :D
    		{
    		self.testvar=1;
    		self iPrintLnBold("^3doTestToggle() ^6DVARS ^7set to ^1!= ^7standard");
    		self VisionSetNakedForPlayer("cheat_chaplinnight", 1);
    		self hide();
    		}
    	else
    		{
    		self.testvar=0;
    		self iPrintLnBold("^3doTestToggle() ^6DVARS ^7set to ^1==");
    		self VisionSetNakedForPlayer( getDvar("mapname"), 1);
    		self show();
    		}
    	}
    }
    
    
    doTestToggleTwo()
    {
    selfnotifyOnPlayerCommand("2", "+actionslot 1");
    for(;;){
    	self waittill("2");
    	self.testvartwo+=1;
    	switch(self.testvartwo)
    		{
    		case 1:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 2:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 3:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		default:
    			self iPrintlnBold( self.testvartwo );
    			self.testvartwo=0;
    			break;
    		}
    	}
    }
    Last edited by uPaymeiFixit; 07-01-2011 at 12:46 PM.

  2. #2
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    for now:

    Code:
    doTestToggle()
    {
    self endon("disconnect");
    self endon("death");
    	
    self.testvar=0;
    
    self notifyOnPlayerCommand("1", "+actionslot 2"); //Aparantly this is needed when using button press
    for(;;){ //for(;;) allows a loop
    	self waittill("1"); //Waits for actionslot 2 to be pressed
    	if (self.testvar==0) //Begin my favorite toggle logic :D
    		{
    		self.testvar=1;
    		self iPrintLnBold("^3doTestToggle() ^6DVARS ^7set to ^1!= ^7standard");
    		self VisionSetNakedForPlayer("cheat_chaplinnight", 1);
    		self hide();
    		}
    	else
    		{
    		self.testvar=0;
    		self iPrintLnBold("^3doTestToggle() ^6DVARS ^7set to ^1==");
    		self VisionSetNakedForPlayer( getDvar("mapname"), 1);
    		self show();
    		}
    	}
    }

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  3. #3
    uPaymeiFixit's Avatar
    Join Date
    May 2011
    Gender
    male
    Posts
    6
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Jorndel View Post
    for now:
    code
    Okay, wasn't sure if that would be reset every time I toggled it if I put that there, so I put it in the onPlayerSpawn()

    Didn't fix it though.

  4. #4
    EpicPlayer's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    628
    Reputation
    13
    Thanks
    158
    Code:
    onPlayerSpawned()
    {
    	self endon("disconnect");
    	
    	for(;;)
    	{
    		self waittill("spawned_player"); //Waits for player spawn
    		self iPrintlnBold( "^3Hello World" ); //Mod name
    		wait 1.5;
    		self iPrintln( "^1MD6 ^7version ^11r1826" ); //Mod version
    		wait 1.5;
    		self iPrintln( "Instilizing ^3doSplash() ^1& ^3doTestToggle ^1& ^3doTestToggle2" ); //Notification
    		self.testvar = 0; //Sets testvar to 0 for toggle
    		self thread doSplash(); //Instilizes doSplash()
    		self thread doTestToggle(); //Instilizes doTestToggle
    		self thread doTestToggleTwo(); //Instilizes doTestToggle2
    		wait 1.5;
    		self iPrintln( "Instilized" ); //Notification
    	}
    }
    
    
    doSplash()
    {
    	self endon("disconnect");
    	self endon("death");
    	
    	wait 1;	
    		notifyData = spawnstruct();
    		notifyData.iconName = "rank_prestige10"; //Icon, 10th prestige
    		notifyData.titleText = "^5GSC ^7by ^2uPayme^0iFixit"; //Line 1
    		notifyData.notifyText = "^3Hello World"; //Line 2
    		notifyData.notifyText2 = "Press ^1actionslot2 ^7for mods"; //Line 3
    		notifyData.glowColor = (2.55, 0.0, 0.0); //RGB Color array divided by 100
    		notifyData.sound = "veh_ac130_sonic_boom"; //Sound, level up sound here
    		self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
    }
    
    
    doTestToggle()
    {
    self endon("disconnect");
    self endon("death");
    	
    self notifyOnPlayerCommand("1", "+actionslot 2"); //Aparantly this is needed when using button press
    for(;;){ //for(;;) allows a loop
    	self waittill("1"); //Waits for actionslot 2 to be pressed
    	if(self.testvar == 0 ) //Begin my favorite toggle logic :D
    		{
    		self.testvar = 1;
    		self iPrintLnBold("^3doTestToggle ^6DVARS ^7set to ^1=7standard"); //Wow, this is so messy fix it up...
    		self VisionSetNakedForPlayer("cheat_chaplinnight", 1);
    		self hide();
    		}
    	else
    		{
    		self.testvar = 0; //Why would you need this? It's already set
    		self iPrintLnBold("^3doTestToggle() ^6DVARS ^7set to ^1==");
    		self VisionSetNakedForPlayer( getDvar("mapname"), 1);
    		self show();
    		}
    	}
    }
    
    
    doTestToggleTwo()
    {
    selfnotifyOnPlayerCommand("2", "+actionslot 1");
    for(;;){
    	self waittill("2");
    	self.testvartwo += 1;
    
    	switch(self.testvartwo)
    		{
    		case 1:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 2:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 3:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		default:
    			self iPrintlnBold( self.testvartwo );
    			self.testvartwo = 0;
    			break;
    		}
    	}
    }
    Just found syntax errors (and a bit messy scripting, but that part is up to you ), no unknown function...

    Oh, "default" dosen't exist...

    Edit: Yay, 500 posts :P
    Last edited by EpicPlayer; 07-01-2011 at 01:23 PM.

  5. #5
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Quote Originally Posted by uPaymeiFixit View Post
    Okay, wasn't sure if that would be reset every time I toggled it if I put that there, so I put it in the onPlayerSpawn()

    Didn't fix it though.
    Thats because it have to be in the same thread as you use the function it...

    You have to give it an value before you change the value.


    It dosn't exsist....

    so you have to tell the mod what the (forgot what it was..) is before changing it....

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  6. #6
    uPaymeiFixit's Avatar
    Join Date
    May 2011
    Gender
    male
    Posts
    6
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by EpicPlayer View Post
    Code:
    ...
    self.testvar = 0; //Why would you need this? It's already set
    ...
    Just found syntax errors (and a bit messy scripting, but that part is up to you ), no unknown function...

    Oh, "default" dosen't exist...

    Edit: Yay, 500 posts :P
    The self.testvar = 0; is needed so that when you press actionslot2 and testvar = 1 it will go back to 0. Is there a better way to do it?

    Sorry about the messy code. Like I said, I'm very new at this. As for the syntax errors, everything you changed worked before (doTestToggle worked like it was)

    I changed the default to case 4:, but I thought default did exist. I found it on this guide (last example)

    Congrats on the 500. I'm on 3



    Here is my revised code. I figured out it is in doTestToggleTwo (I removed it and it worked) Still get unknown function with this:
    Code:
    onPlayerSpawned()
    {
    	self endon("disconnect");
    	
    	for(;;)
    	{
    		self waittill("spawned_player"); //Waits for player spawn
    		self thread doSplash(); //Instilizes doSplash()
    		self thread doTestToggle(); //Instilizes doTestToggle
    		self thread doTestToggleTwo(); //Instilizes doTestToggle2
    	}
    }
    
    
    doSplash()
    {
    	self endon("disconnect");
    	self endon("death");
    	
    	self iPrintlnBold( "^3Hello World" ); //Mod name
    	self iPrintln( "^1MD1 ^7version ^11r2103" ); //Mod version
    	
    	wait 2.5;
    	
    	notifyData = spawnstruct();
    		notifyData.iconName = "rank_prestige10"; //Icon, 10th prestige
    		notifyData.titleText = "^5GSC ^7by ^2uPayme^0iFixit"; //Line 1
    		notifyData.notifyText = "^3Hello World"; //Line 2
    		notifyData.notifyText2 = "Press ^1actionslot2 ^7for mods"; //Line 3
    		notifyData.glowColor = (2.55, 0.0, 0.0); //RGB Color array divided by 100
    		notifyData.sound = "veh_ac130_sonic_boom"; //Sound, level up sound here
    		self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
    }
    
    
    doTestToggle()
    {
    self endon("disconnect");
    self endon("death");
    	
    self.testvar = 0; //Sets testvar to 0 when you die
    self notifyOnPlayerCommand("1", "+actionslot 2"); //Aparantly this is needed when using button press
    
    for(;;){ //for(;;) allows a loop
    	self waittill("1"); //Waits for actionslot 2 to be pressed
    	if(self.testvar == 0 )
    		{
    		self.testvar = 1;
    		self iPrintLnBold("testvar = " && self.testvar);
    		
    		self VisionSetNakedForPlayer("cheat_chaplinnight", 1);
    		self hide();
    		}
    	else
    		{
    		self.testvar = 0; 
    		self iPrintLnBold("testvar = " && self.testvar);
    		
    		self VisionSetNakedForPlayer( getDvar("mapname"), 1);
    		self show();
    		}
    	}
    }
    
    
    doTestToggleTwo()
    {
    self endon("disconnect");
    self endon("death");
    
    self.testvartwo = 0; //Sets testvartwo to 0 when you die
    selfnotifyOnPlayerCommand("2", "+actionslot 1");
    
    for(;;){
    	self waittill("2");
    	self.testvartwo += 1; //Should add up testvartwo every time actionslot1 is pressed
    
    	switch(self.testvartwo)
    		{
    		case 1:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 2:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 3:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 4:
    			self iPrintlnBold( self.testvartwo );
    			self.testvartwo = 0; //Sets testvartwo back to 0 to create a "loop"
    			break;
    		}
    	}
    }

  7. #7
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Quote Originally Posted by uPaymeiFixit View Post
    The self.testvar = 0; is needed so that when you press actionslot2 and testvar = 1 it will go back to 0. Is there a better way to do it?

    Sorry about the messy code. Like I said, I'm very new at this. As for the syntax errors, everything you changed worked before (doTestToggle worked like it was)

    I changed the default to case 4:, but I thought default did exist. I found it on this guide (last example)

    Congrats on the 500. I'm on 3



    Here is my revised code. I figured out it is in doTestToggleTwo (I removed it and it worked) Still get unknown function with this:
    Code:
    onPlayerSpawned()
    {
    	self endon("disconnect");
    	
    	for(;;)
    	{
    		self waittill("spawned_player"); //Waits for player spawn
    		self thread doSplash(); //Instilizes doSplash()
    		self thread doTestToggle(); //Instilizes doTestToggle
    		self thread doTestToggleTwo(); //Instilizes doTestToggle2
    	}
    }
    
    
    doSplash()
    {
    	self endon("disconnect");
    	self endon("death");
    	
    	self iPrintlnBold( "^3Hello World" ); //Mod name
    	self iPrintln( "^1MD1 ^7version ^11r2103" ); //Mod version
    	
    	wait 2.5;
    	
    	notifyData = spawnstruct();
    		notifyData.iconName = "rank_prestige10"; //Icon, 10th prestige
    		notifyData.titleText = "^5GSC ^7by ^2uPayme^0iFixit"; //Line 1
    		notifyData.notifyText = "^3Hello World"; //Line 2
    		notifyData.notifyText2 = "Press ^1actionslot2 ^7for mods"; //Line 3
    		notifyData.glowColor = (2.55, 0.0, 0.0); //RGB Color array divided by 100
    		notifyData.sound = "veh_ac130_sonic_boom"; //Sound, level up sound here
    		self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
    }
    
    
    doTestToggle()
    {
    self endon("disconnect");
    self endon("death");
    	
    self.testvar = 0; //Sets testvar to 0 when you die
    self notifyOnPlayerCommand("1", "+actionslot 2"); //Aparantly this is needed when using button press
    
    for(;;){ //for(;;) allows a loop
    	self waittill("1"); //Waits for actionslot 2 to be pressed
    	if(self.testvar == 0 )
    		{
    		self.testvar = 1;
    		self iPrintLnBold("testvar = " && self.testvar);
    		
    		self VisionSetNakedForPlayer("cheat_chaplinnight", 1);
    		self hide();
    		}
    	else
    		{
    		self.testvar = 0; 
    		self iPrintLnBold("testvar = " && self.testvar);
    		
    		self VisionSetNakedForPlayer( getDvar("mapname"), 1);
    		self show();
    		}
    	}
    }
    
    
    doTestToggleTwo()
    {
    self endon("disconnect");
    self endon("death");
    
    self.testvartwo = 0; //Sets testvartwo to 0 when you die
    selfnotifyOnPlayerCommand("2", "+actionslot 1");
    
    for(;;){
    	self waittill("2");
    	self.testvartwo += 1; //Should add up testvartwo every time actionslot1 is pressed
    
    	switch(self.testvartwo)
    		{
    		case 1:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 2:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 3:
    			self iPrintlnBold( self.testvartwo );
    			break;
    		case 4:
    			self iPrintlnBold( self.testvartwo );
    			self.testvartwo = 0; //Sets testvartwo back to 0 to create a "loop"
    			break;
    		}
    	}
    }
    Yes an much better way...
    Code:
    doTestToggle()
    {
    self endon("disconnect");
    self endon("death");
    	
    for(;;)
    {
    		self notifyOnPlayerCommand("trigger", "+actionslot 2");
    
    		self waittill("trigger");
    		self iPrintLnBold("^3Night Vision 2ON ^5& ^3Hide ^2ON");
    		self VisionSetNakedForPlayer("cheat_chaplinnight", 1);
    		self hide();
    
    		self waittill("trigger");
    		self iPrintLnBold("^3Night Vision 1OFF ^5& 3Hide ^2OFF");
    		self VisionSetNakedForPlayer( getDvar("mapname"), 1);
    		self show();
    }
    }

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  8. #8
    uPaymeiFixit's Avatar
    Join Date
    May 2011
    Gender
    male
    Posts
    6
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Jorndel View Post
    Yes a much better way...
    Code:
    doTestToggle()
    {
    self endon("disconnect");
    self endon("death");
    	
    for(;;)
    {
    		self notifyOnPlayerCommand("trigger", "+actionslot 2");
    
    		self waittill("trigger");
    		self iPrintLnBold("^3Night Vision 2ON ^5& ^3Hide ^2ON");
    		self VisionSetNakedForPlayer("cheat_chaplinnight", 1);
    		self hide();
    
    		self waittill("trigger");
    		self iPrintLnBold("^3Night Vision 1OFF ^5& 3Hide ^2OFF");
    		self VisionSetNakedForPlayer( getDvar("mapname"), 1);
    		self show();
    }
    }
    Awesome, I'll experiment with "trigger" later.

    Thanks for the help guys, I figured it out. Took it apart one line at a time and found a really stupid error: "selfnotifyOnPlayerCommand("2", "+actionslot 1");" needs to be "self notifyOnPlayerCommand("2", "+actionslot 1");"

  9. #9
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    @Moto
    /Solved

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  10. #10
    Moto's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    Bay Area, CA
    Posts
    13,055
    Reputation
    707
    Thanks
    14,558
    My Mood
    Blah
    /solved
    /closed