Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help? (https://forums.graalonline.com/forums/showthread.php?t=134260313)

pez307 08-24-2010 03:10 PM

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.

Dnegel 08-24-2010 05:09 PM

NPC Code:
  this.time += .05;; 



You sure this one is right?

ffcmike 08-24-2010 05:19 PM

Quote:

Originally Posted by pez307 (Post 1596352)
NPC Code:
//#CLIENTSIDE 


The fact there is a space after //#CLIENTSIDE?

Soala 08-24-2010 06:57 PM

Use PHP tags for your script next time, it's easier to read.

Dnegel 08-24-2010 08:42 PM

Quote:

Originally Posted by ffcmike (Post 1596366)
The fact there is a space after //#CLIENTSIDE?

Lol, the most common GS2 problem. :D

salesman 08-24-2010 08:51 PM

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 (Post 1596366)
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).

ffcmike 08-24-2010 09:20 PM

Quote:

Originally Posted by salesman (Post 1596396)
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 x_x.

LoneAngelIbesu 08-25-2010 12:03 AM

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.

pez307 08-25-2010 04:19 PM

Don't worry i have it working now thanks to everybodys help. Thanks, it was a //#CLIENTSIDE problem :P

salesman 08-25-2010 08:03 PM

Quote:

Originally Posted by pez307 (Post 1596574)
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.

Crow 08-25-2010 08:39 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1596431)
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

salesman 08-26-2010 12:24 AM

-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, ...)

Crow 08-26-2010 04:51 PM

Quote:

Originally Posted by salesman (Post 1596675)
-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.


All times are GMT +2. The time now is 10:37 PM.

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