Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-24-2010, 03:10 PM
pez307 pez307 is offline
ImThatGuy
pez307's Avatar
Join Date: Apr 2007
Posts: 58
pez307 is an unknown quantity at this point
Help?

Hi i've been tinkering with Chris's script he posted on forums, i edited the script with a new GUI but it's not opening.. I have no Errors come up everything seems to be in good working order but soon as i press R doesn't work, it doesn't work. Then i decided to add Chris's script Non-Edited and it still never worked...

Script:
NPC Code:
//#CLIENTSIDE 
function onCreated()
{
show();
}
function onKeyPressed( code, key )
{
if ( key == "r" )
{
setTimer( 0.05 );
Pez_Window2.visible = Pez_Window2.visible - 1;
GraalControl.makeFirstResponder( true );
}
}
function onWeaponFired()
{
say2( "Press 'r' to toggle Music Player" );
}
function show()
{
playing = this.playing;
Pez_Window2.destroy();
new GuiWindowCtrl( "Pez_Window2" )
{
profile = "GuiBlueWindowProfile";
width = 280;
height = 120;
x = screenwidth - width;
y = screenheight - height;
canClose = canMinimize = true;
canMaximize = canResize = false;
visible = false;
text = "Music Player for" SPC servername;
useownprofile = true;
profile.transparency = .9;
new GuiMLTextCtrl( "Pez_Text1" )
{
profile = "GuiBlueTextProfile";
x = 10;
y = 30;
width = 270;
height = 20;
useownprofile = true;
profile.align = "center";
text = "<center>Now playing:" SPC playing;
}
new GuiPopUpMenuCtrl( "Pez_Popup1" )
{
profile = "GuiBluePopUpMenuProfile";
width = 260;
height = 20;
x = 10;
y = 50;
textprofile = "GuiBlueTextListProfile";
scrollprofile = "GuiBlueScrollProfile";
clearRows();
temp.music = {
{ "SONG_NAME", "SONG_URL" },
{ "SONG2_NAME", "SONG2_URL" }
};
for ( temp.i = 0; temp.i < temp.music.size(); temp.i ++ )
{
with( addRow( 0, temp.music[temp.i][0] ) )
{
this.var = temp.music[temp.i][1];
}
}
setSelectedRow( 0 );
sort();
}
new GuiButtonCtrl( "Pez_Button1" )
{
profile = "GuiBlueButtonProfile";
width = 75;
height = 30;
x = Pez_Window2.width / 2 - ( width / 2 );
y = Pez_Window2.height - 40;
text = "Stop Music";
}
}
stopmidi();
this.playing = "[None]";
Pez_Text1 = "Now playing: [None]";
}
function onTimeOut()
{
this.time += .05;;
setTimer( 0.05 );
}
function Pez_Button1.onAction()
{
stopmidi();
this.playing = "[None]";
Pez_Text1 = "Now playing: [None]";
}
function Pez_Popup1.onSelect()
{
if ( this.time > 0 )
{
this.playing = params[1];
Pez_Text1.text = "Now playing:" SPC params[1];
play( Pez_Pupup1.rows[params[2]].var );
}
}
function onPlay( title, song )
{
this.playing = title;
Jukebox_Text.text = "Now playing:" SPC title;
play( song );
}



Anybody know what's wrong? Help would be appretiated.
__________________
Cm*

Last edited by pez307; 08-24-2010 at 03:34 PM..
Reply With Quote
  #2  
Old 08-24-2010, 05:09 PM
Dnegel Dnegel is offline
Rjax Shizibz
Join Date: Jul 2009
Posts: 1,334
Dnegel will become famous soon enough
NPC Code:
  this.time += .05;; 



You sure this one is right?
Reply With Quote
  #3  
Old 08-24-2010, 05:19 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by pez307 View Post
NPC Code:
//#CLIENTSIDE 

The fact there is a space after //#CLIENTSIDE?
Reply With Quote
  #4  
Old 08-24-2010, 06:57 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Use PHP tags for your script next time, it's easier to read.
Reply With Quote
  #5  
Old 08-24-2010, 08:42 PM
Dnegel Dnegel is offline
Rjax Shizibz
Join Date: Jul 2009
Posts: 1,334
Dnegel will become famous soon enough
Quote:
Originally Posted by ffcmike View Post
The fact there is a space after //#CLIENTSIDE?
Lol, the most common GS2 problem.
Reply With Quote
  #6  
Old 08-24-2010, 08:51 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Have you tried debugging your code at all? Coming to the forums should not be your first step for debugging code...take it one line at a time and find out where it is failing.

Quote:
Originally Posted by ffcmike View Post
The fact there is a space after //#CLIENTSIDE?
I'm pretty sure that if he had added an extra space you would see two spaces when you highlight it (one for the extra space and one for the line break).
__________________
Reply With Quote
  #7  
Old 08-24-2010, 09:20 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by salesman View Post
I'm pretty sure that if he had added an extra space you would see two spaces when you highlight it (one for the extra space and one for the line break).
Appears I'm mistaken, checked for this as opposed to an actual scripting error due to the lack of PHP tag + unusual styling .
Reply With Quote
  #8  
Old 08-25-2010, 12:03 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Did you add the weapon to yourself?

Also, what's this?
PHP Code:
Pez_Window2.visible Pez_Window2.visible 1
.visible takes boolean values, either 'true' or 'false' (1 or 0). If it's already set to 0, subtracting 1 would leave '-1', which isn't a boolean value.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #9  
Old 08-25-2010, 04:19 PM
pez307 pez307 is offline
ImThatGuy
pez307's Avatar
Join Date: Apr 2007
Posts: 58
pez307 is an unknown quantity at this point
Don't worry i have it working now thanks to everybodys help. Thanks, it was a //#CLIENTSIDE problem :P
__________________
Cm*
Reply With Quote
  #10  
Old 08-25-2010, 08:03 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by pez307 View Post
Don't worry i have it working now thanks to everybodys help. Thanks, it was a //#CLIENTSIDE problem :P
You said you weren't getting any errors ? If there was a problem with the clientside line, you should have been seeing ~20 errors on RC.

You also might want to change this:
PHP Code:
Pez_Window2.destroy(); 
new 
GuiWindowCtrl"Pez_Window2" 
because I've read that destroying and creating a gui control in the same function can cause srs problems.
__________________
Reply With Quote
  #11  
Old 08-25-2010, 08:39 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by LoneAngelIbesu View Post
Also, what's this?
PHP Code:
Pez_Window2.visible Pez_Window2.visible 1
.visible takes boolean values, either 'true' or 'false' (1 or 0). If it's already set to 0, subtracting 1 would leave '-1', which isn't a boolean value.
Should be:
PHP Code:
this.bool this.bool// alternative to the line below
this.bool = !this.bool
Preference and the like, you know what I'm talkin' about :3
__________________
Reply With Quote
  #12  
Old 08-26-2010, 12:24 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
-1 evaluates to true, so next time you access control.visible would it return -1 or 1? If it returns 1, then his method would work, otherwise it would just keep evaluating to true (i.e. -2, -3, -4, ...)
__________________
Reply With Quote
  #13  
Old 08-26-2010, 04:51 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by salesman View Post
-1 evaluates to true, so next time you access control.visible would it return -1 or 1? If it returns 1, then his method would work, otherwise it would just keep evaluating to true (i.e. -2, -3, -4, ...)
He just mixed it up. If you subtract the current value from 1, you will end up with either 0 or 1; it's that simple.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.