Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   JKL's Scripting Questions (https://forums.graalonline.com/forums/showthread.php?t=134258195)

jkldogg 03-14-2010 05:34 PM

Attempted to Create A window my self
 
Tried to learn how to use the GUI Editor.

Can someone tell me where I made an error? Because in RC, it doesn't say any errors.

It worked, but It doesn't come up when I press the key "9"

PHP Code:

function onKeyPressedcodekey )
{
  if ( 
key == "9" )
  {
    
triggerserver"gui"name"getMessage" );
  }


Or When on a chat command.


PHP Code:

function onPlayerChats()
{
  if ( 
player.chat == ":test" )
  {
    
triggerserver"gui"name"getMessage" );
  }


Here's the full code
PHP Code:

//#CLIENTSIDE
function onKeyPressedcodekey )
{
  if ( 
key == "9" )
  {
    
triggerserver"gui"name"getMessage" );
  }

function 
onPlayerChats()
{
  if ( 
player.chat == ":test" )
  {
    
triggerserver"gui"name"getMessage" );
  }
}  

function 
onCreated() {
  new 
GuiWindowCtrl("test_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "114,94";

    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Poll";
    
585;
    
265;

    new 
GuiCheckBoxCtrl("test_CheckBox1") {
      
profile GuiBlueCheckBoxProfile;
      
height 20;
      
text "Yes";
      
width 100;
      
13;
      
31;
    }
    new 
GuiCheckBoxCtrl("test_CheckBox2") {
      
profile GuiBlueCheckBoxProfile;
      
height 20;
      
text "No";
      
width 100;
      
13;
      
56;
    }
    new 
GuiTextCtrl("test_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Do you like pie?";
      
width 75;
      
9;
      
7;
    }
  }


Can someone please help!

TSAdmin 03-14-2010 05:59 PM

Quote:

Originally Posted by jkldogg (Post 1562468)
You just give little small tips..that is annoying.

To be fair, he's just following the rules of the Scripting Forum which I implore you to read before making hostile posts.

Quote:

Originally Posted by Scripting Forum Rules
1. Be clear on your ability level. In other words, do not post asking for scripts, or asking people to fix scripts that are above your ability level. If you are writing a script to aid learning, then try writing a simpler script. If you are looking for a script for a server, then the best solution is probably to hire a scripter.

I have taken the liberty of bolding the part you don't seem to understand about why people are only giving "Small tips". If the small tips that you are getting are not helping you in your mind, even though they have been posted multiple times by multiple people, then that is considered "Above your skill level" and you should probably consider a simpler script.

Quote:

Originally Posted by Scripting Forum Rules
2. Similarly, do not just post whole scripts for people as a response to their difficulties. If you wish to post a wordy solution, then please feel free; however, please do not post things that people can just copy and paste. It isn't helping people to learn just by doing so. If you'd like to show off your scripts to others, post them in the Code Gallery subforum.

and above, I have bolded the part of the rules in which Andrew is following and you are not happy about. By copying the whole thing and reposting it for you with the alterations, they are "Posting a whole script as a response to your difficulties", which obviously would only be done if rule 1 were ignored because of the "It's above your skill level".

Overall, many would really appreciate it if you could recognise where you are in over your head and beyond your skill level before becoming so hostile toward people following the rules. Click here and please read the rules of the Scripting Forum. You will need to scroll down to Skyld's post, which is after Stefan's.

jkldogg 03-14-2010 06:03 PM

lol
 
^ View my first post on this page!

Quote:

Originally Posted by TSAdmin (Post 1562492)
To be fair, he's just following the rules of the Scripting Forum which I implore you to read before making hostile posts.



I have taken the liberty of bolding the part you don't seem to understand about why people are only giving "Small tips". If the small tips that you are getting are not helping you in your mind, even though they have been posted multiple times by multiple people, then that is considered "Above your skill level" and you should probably consider a simpler script.



and above, I have bolded the part of the rules in which Andrew is following and you are not happy about. By copying the whole thing and reposting it for you with the alterations, they are "Posting a whole script as a response to your difficulties", which obviously would only be done if rule 1 were ignored because of the "It's above your skill level".

Overall, many would really appreciate it if you could recognise where you are in over your head and beyond your skill level before becoming so hostile toward people following the rules. Click here and please read the rules of the Scripting Forum. You will need to scroll down to Skyld's post, which is after Stefan's.

No, it isn't above my skill level to erase a line of text. There were 3 lines of "PLAY SOUND" or whatever so I deleted them all and the sound went away, so I was confused. Because he simply said "delete play sound" so i came back to see what the problem was. And then he helped.

xAndrewx 03-14-2010 06:07 PM

PHP Code:

function onKeyPressed(codekey) {
  if (
temp.key != 9) return; //If its not the 9 key, do nothing

  
test_Window1.visible = !test_Window1.visible//A toggle option to display or hide the window


function 
onCreated() {
  new 
GuiWindowCtrl("test_Window1") {
  
//ADD THIS LINE IN HERE, so it's not always showing when you update the script
    
visible false;
  
//REST OF YOUR STUFF HERE 
  
}


Try this, it should work

cbk1994 03-14-2010 06:14 PM

How does this man still have a green rep bar?

fowlplay4 03-14-2010 06:19 PM

Quote:

Originally Posted by TSAdmin (Post 1562492)
Overall, many would really appreciate it if you could recognise where you are in over your head and beyond your skill level before becoming so hostile toward people following the rules. Click here and please read the rules of the Scripting Forum. You will need to scroll down to Skyld's post, which is after Stefan's.

So that's where those were.

Also jkl, read the following: http://wiki.graal.us/onActionServerSide

You should notice that triggerserver does not do anything with the GUI window.

You can hide/show a GUI window with this line of code:

NameOfGUIObject.show();
NameOfGUIObject.hide();

There are many other functions that GUI Objects contain: http://wiki.graal.net/index.php/Crea...ent/GuiControl

This is probably the last bit of help you're going to get if you keep up the ignorant behavior which will result in your banning.

Links that may help:

http://wiki.graal.us/ - Skyld's Documentation
http://wiki.graal.net/index.php/Creation/Dev/GScript - gBible Documentation contains a couple tutorials
http://public.zodiacdev.com/index.php?title=Fowlplay4 - Tutorial I started work on, that still needs work.

I'd also recommend you try learning how to program in general and try to wrap your head around the logic involved.

jkldogg 03-14-2010 06:26 PM

no curr
 
Quote:

Originally Posted by xAndrewx (Post 1562498)
PHP Code:

function onKeyPressed(codekey) {
  if (
temp.key != 9) return; //If its not the 9 key, do nothing

  
test_Window1.visible = !test_Window1.visible//A toggle option to display or hide the window


function 
onCreated() {
  new 
GuiWindowCtrl("test_Window1") {
  
//ADD THIS LINE IN HERE, so it's not always showing when you update the script
    
visible false;
  
//REST OF YOUR STUFF HERE 
  
}


Try this, it should work

Works like a charm, much appreciated. You help the most.

Quote:

Originally Posted by cbk1994 (Post 1562500)
How does this man still have a green rep bar?

1.) Me?
2.) Why do I care?
3.) I don't even know what rep does.. Repuatation?
4.) Do you not remember me chris?
5.) Era? Lol, like I care what others think.

TSAdmin 03-14-2010 06:37 PM

Quote:

Originally Posted by jkldogg (Post 1562504)
1.) Me?
2.) Why do I care?
3.) I don't even know what rep does.. Repuatation?
4.) Do you not remember me chris?
5.) Era? Lol, like I care what others think.

I don't mean to be a pain, but do you think this is the reason why you're not getting a lot of help in a thread you made asking for help? This is the kind of hostility I was talking about earlier. Please, tone it down... a lot.

jkldogg 03-14-2010 06:39 PM

Quote:

Originally Posted by TSAdmin (Post 1562508)
I don't mean to be a pain, but do you think this is the reason why you're not getting a lot of help in a thread you made asking for help? This is the kind of hostility I was talking about earlier. Please, tone it down... a lot.

Chris Vimes knows what's up. He says he likes me on Era a few months ago and now he's mad. OH WELL. I'm done with that crap. I was in a position of "half-way-caring" which is like caring but only to an extent. That extent is gone. :whatever:

jkldogg 03-14-2010 06:45 PM

Health Respawn problem
 
SORRY DOUBLE POST.

Personally scripted by *Switch for use only on Vega United.

The problem is whenever you die, a little watermark appears and you press Space bar to revive, this worked fine. But switch came back and altered the script and now it doesn't let you respawn. You must reconnect to the server to revive. This is extremely annoying, and many of our players have stopped coming because of this reason. Help is appreciated, please and thank you in advance.

I tried to fix it by altering this code, but I think I did more harm than good? >_<

PHP Code:

  layer 4;
      
red green blue 0;
      
mode 1;
      
alpha 0.7;
    }
    
with (findImg(201)) {
      
text "Press spacebar to revive.";
      
GraalControl.width/2GraalControl.height/2+GraalControl.height/3.5;
      
layer 4;
      
style "c";
      
red green blue 1;
      
zoom GraalControl.width/600;
    }
  }
  else {
    
hideImgs(200201);
  }
}
function 
GraalControl.onResize() {
  if (
clientr.health_current == null) {
    
with (findImg(200)) {
      
polygon = {GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/4

Here's the full code.
PHP Code:

function onActionServerside(cmdp1p2) {
  if (
cmd == "setstats") {
    
clientr.health_current clientr.health_max 100;
    
clientr.armor_current clientr.armor_max 0;
    
onHeal(player.account);
  }
  if (
cmd == "hurt") {
    if (!
player.level.isnopkzone) {
      if (
clientr.armor_current 0) {
        if (
clientr.armor_current >= p1) {
          
clientr.armor_current -= p1;
          if (
clientr.armor_current 0) {
            
clientr.armor_max 0;
          }
          
player.ani "hurt";;
          
scheduleEvent(1"Unhurt"player.account);
        }
        else {
          
temp.remain p1-clientr.armor_current;
          
clientr.armor_current clientr.armor_max 0;
          
clientr.health_current -= temp.remain;
          if (
clientr.health_current <= 0) {
            
clientr.health_current 0;
            
death(p2);
          }
        }
      }
      else if (
clientr.health_current 0) {
        if (
clientr.health_current p1) {
          
clientr.health_current -= p1;
          
player.ani "hurt";
          
scheduleEvent(1"Unhurt"player.account);
        }
        else {
          
clientr.health_current 0;
          
death(p2);
        }
      }
    }
  }
  else if (
cmd == "respawn") {
    
onHeal(player.account);
  }
  
triggerClient("gui"this.name);
}
function 
onUnhurt(pl) {
  if (
player.ani == "hurt") {
    
player.ani "idle";
  }
}
function 
death(pl) {
  
player.ani "dead";
  
freezePlayer2();
  
clientr.deaths++;
  
clientr.dead true;
  
player.chat "" @findPlayer(pl).communityname"!";
  
findPlayer(pl).clientr.kills++;
  
findPlayer(pl).chat "" @player.communityname"!";
}
function 
onHeal(pl) {
  
findPlayer(pl).ani "idle";
  
clientr.dead false;
  
findPlayer(pl).clientr.health_current findPlayer(pl).clientr.health_max;
  
findPlayer(pl).unfreezePlayer();
  
findPlayer(pl).setLevel2("overworld_ad-ae.nw"9.37562.5);
  
findPlayer(pl).triggerClient("gui"this.name);
}

//#CLIENTSIDE
function onCreated() {
  
Health this;
  if (
clientr.health_current == null) {
    
triggerServer("gui"this.name"setstats");
  }
}
function 
GraalControl.onKeyPressed(codekeyscan) {
  if (
clientr.health_current == null) {
    if (
scan == 0) {
      
triggerServer("gui"this.name"respawn");
    }
  }
}
function 
onActionClientside() {
  
HUD.findImg(201).width = ((clientr.health_current/clientr.health_max)*82)/16;
  if (
clientr.health_current 0) {
    
HUD.findImg(201).alpha 1;
  }
  else {
    
HUD.findImg(201).alpha 0;
  }
  
HUD.findImg(202).text clientr.health_current"/" @clientr.health_max;
  
HUD.findImg(203).width = ((clientr.health_current/clientr.health_max)*82)/16;
  if (
clientr.armor_current 0) {
    
HUD.findImg(203).alpha 1;
  }
  else {
    
HUD.findImg(203).alpha 0;
  }
  
HUD.findImg(204).text = (clientr.armor_current == null?"0/0":clientr.armor_current"/"clientr.armor_max);
  if (
clientr.health_current == null) {
    
with (findImg(200)) {
      
polygon = {GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/3,
                 
GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/3};
      
layer 4;
      
red green blue 0;
      
mode 1;
      
alpha 0.7;
    }
    
with (findImg(201)) {
      
text "Press spacebar to revive.";
      
GraalControl.width/2GraalControl.height/2+GraalControl.height/3.5;
      
layer 4;
      
style "c";
      
red green blue 1;
      
zoom GraalControl.width/600;
    }
  }
  else {
    
hideImgs(200201);
  }
}
function 
GraalControl.onResize() {
  if (
clientr.health_current == null) {
    
with (findImg(200)) {
      
polygon = {GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/3,
                 
GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/3};
      
layer 4;
      
red green blue 0;
      
mode 1;
      
alpha 0.7;
    }
    
with (findImg(201)) {
      
text "Press spacebar to revive.";
      
GraalControl.width/2GraalControl.height/2+GraalControl.height/3.5;
      
layer 4;
      
style "c";
      
red green blue 1;
      
zoom GraalControl.width/600;
    }
  }
}

function 
onActionProjectile(bdmgpl) {
  if (
== "bullet") {
    
triggerServer("gui"this.name"hurt"dmgpl);
  }



DrakilorP2P 03-14-2010 06:55 PM

Quote:

Originally Posted by jkldogg (Post 1562511)
SORRY DOUBLE POST.

The problem is whenever you die, a little watermark appears and you press Space bar to revive, this worked fine. But switch came back and altered the script and now it doesn't let you respawn. You must reconnect to the server to revive. This is extremely annoying, and many of our players have stopped coming because of this reason. Help is appreciated, please and thank you in advance.

I tried to fix it by altering this code, but I think I did more harm than good? >_<

Here's the full code.
PHP Code:

function onActionServerside(cmdp1p2) {
  if (
cmd == "setstats") {
    
clientr.health_current clientr.health_max 100;
    
clientr.armor_current clientr.armor_max 0;
    
onHeal(player.account);
  }
  if (
cmd == "hurt") {
    if (!
player.level.isnopkzone) {
      if (
clientr.armor_current 0) {
        if (
clientr.armor_current >= p1) {
          
clientr.armor_current -= p1;
          if (
clientr.armor_current 0) {
            
clientr.armor_max 0;
          }
          
player.ani "hurt";;
          
scheduleEvent(1"Unhurt"player.account);
        }
        else {
          
temp.remain p1-clientr.armor_current;
          
clientr.armor_current clientr.armor_max 0;
          
clientr.health_current -= temp.remain;
          if (
clientr.health_current <= 0) {
            
clientr.health_current 0;
            
death(p2);
          }
        }
      }
      else if (
clientr.health_current 0) {
        if (
clientr.health_current p1) {
          
clientr.health_current -= p1;
          
player.ani "hurt";
          
scheduleEvent(1"Unhurt"player.account);
        }
        else {
          
clientr.health_current 0;
          
death(p2);
        }
      }
    }
  }
  else if (
cmd == "respawn") {
    
onHeal(player.account);
  }
  
triggerClient("gui"this.name);
}
function 
onUnhurt(pl) {
  if (
player.ani == "hurt") {
    
player.ani "idle";
  }
}
function 
death(pl) {
  
player.ani "dead";
  
freezePlayer2();
  
clientr.deaths++;
  
clientr.dead true;
  
player.chat "" @findPlayer(pl).communityname"!";
  
findPlayer(pl).clientr.kills++;
  
findPlayer(pl).chat "" @player.communityname"!";
}
function 
onHeal(pl) {
  
findPlayer(pl).ani "idle";
  
clientr.dead false;
  
findPlayer(pl).clientr.health_current findPlayer(pl).clientr.health_max;
  
findPlayer(pl).unfreezePlayer();
  
findPlayer(pl).setLevel2("overworld_ad-ae.nw"9.37562.5);
  
findPlayer(pl).triggerClient("gui"this.name);
}

//#CLIENTSIDE
function onCreated() {
  
Health this;
  if (
clientr.health_current == null) {
    
triggerServer("gui"this.name"setstats");
  }
}
function 
GraalControl.onKeyPressed(codekeyscan) {
  if (
clientr.health_current == null) {
    if (
scan == 0) {
      
triggerServer("gui"this.name"respawn");
    }
  }
}
function 
onActionClientside() {
  
HUD.findImg(201).width = ((clientr.health_current/clientr.health_max)*82)/16;
  if (
clientr.health_current 0) {
    
HUD.findImg(201).alpha 1;
  }
  else {
    
HUD.findImg(201).alpha 0;
  }
  
HUD.findImg(202).text clientr.health_current"/" @clientr.health_max;
  
HUD.findImg(203).width = ((clientr.health_current/clientr.health_max)*82)/16;
  if (
clientr.armor_current 0) {
    
HUD.findImg(203).alpha 1;
  }
  else {
    
HUD.findImg(203).alpha 0;
  }
  
HUD.findImg(204).text = (clientr.armor_current == null?"0/0":clientr.armor_current"/"clientr.armor_max);
  if (
clientr.health_current == null) {
    
with (findImg(200)) {
      
polygon = {GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/3,
                 
GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/3};
      
layer 4;
      
red green blue 0;
      
mode 1;
      
alpha 0.7;
    }
    
with (findImg(201)) {
      
text "Press spacebar to revive.";
      
GraalControl.width/2GraalControl.height/2+GraalControl.height/3.5;
      
layer 4;
      
style "c";
      
red green blue 1;
      
zoom GraalControl.width/600;
    }
  }
  else {
    
hideImgs(200201);
  }
}
function 
GraalControl.onResize() {
  if (
clientr.health_current == null) {
    
with (findImg(200)) {
      
polygon = {GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/4,
                 
GraalControl.width/2+GraalControl.width/5GraalControl.height/2+GraalControl.height/3,
                 
GraalControl.width/2-GraalControl.width/5GraalControl.height/2+GraalControl.height/3};
      
layer 4;
      
red green blue 0;
      
mode 1;
      
alpha 0.7;
    }
    
with (findImg(201)) {
      
text "Press spacebar to revive.";
      
GraalControl.width/2GraalControl.height/2+GraalControl.height/3.5;
      
layer 4;
      
style "c";
      
red green blue 1;
      
zoom GraalControl.width/600;
    }
  }
}

function 
onActionProjectile(bdmgpl) {
  if (
== "bullet") {
    
triggerServer("gui"this.name"hurt"dmgpl);
  }



Not sure what is going on, but try replacing
PHP Code:

function GraalControl.onKeyPressed(codekeyscan) { 

with
PHP Code:

function onKeyPressed(codekeyscan) { 

You should probably ask Switch about it since he's the last one who messed with it before it broke.

jkldogg 03-14-2010 07:22 PM

Quote:

Originally Posted by DrakilorP2P (Post 1562513)
Not sure what is going on, but try replacing
PHP Code:

function GraalControl.onKeyPressed(codekeyscan) { 

with
PHP Code:

function onKeyPressed(codekeyscan) { 

You should probably ask Switch about it since he's the last one who messed with it before it broke.

He came back to help, and made it worst. He hasn't been online since. I'll try your remedy.

EDIT: Works like a charm, thanks.

jkldogg 03-14-2010 09:30 PM

Guild Locked door
 
^^Tried to make a guild locked door, for my Squads System...Didn't work too well. Can someone tell me where I went wrong?
Please and thank you in advance. :)

PHP Code:

function onActionGrab() {
      if (
clientr.SquadName == "La Carmelas");
      
setlevel vega_kody-house-inside,30,30;
    }
    function 
onActionGrab() {
      if (
clientr.SquadName "La Carmelas");
      
setlevel vega_staff-meeting,20,20;
    } 


Deas_Voice 03-14-2010 09:38 PM

Quote:

Originally Posted by jkldogg (Post 1562538)
^^Tried to make a guild locked door, for my Squads System...Didn't work too well. Can someone tell me where I went wrong?
Please and thank you in advance. :)

PHP Code:

function onActionGrab() {
      if (
clientr.SquadName == "La Carmelas");
      
setlevel vega_kody-house-inside,30,30;
    }
    function 
onActionGrab() {
      if (
clientr.SquadName "La Carmelas");
      
setlevel vega_staff-meeting,20,20;
    } 


you are doing the function twice, that's a no-can-do.
also, still mixing with gs1, stop that if u want to be a scripter

jkldogg 03-14-2010 09:39 PM

1 function
 
Quote:

Originally Posted by Deas_Voice (Post 1562541)
you are doing the function twice, that's a no-can-do.
also, still mixing with gs1, stop that if u want to be a scripter

So if I take out the second function it will work?


All times are GMT +2. The time now is 06:14 PM.

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