Graal Forums

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

Jeffyy 01-13-2008 04:10 PM

Any idea?
 
Any idea why this wont change nick?

NPC Code:
    
function onCreated() {
new GuiTextEditCtrl("RiotGamesys_TextEdit2") {
profile = GuiBlueTextEditProfile;
height = 20;
text = player.nick;
width = 122;
x = 176;
y = 23;

function onTimeout(){
player.nick = RiotGamesys_TextEdit2.text;
}
setTimer(.05);}
function RiotGamesys_Button11.onAction() {
RiotGamesys_Button11.active = false;
player.nick = RiotGamesys_TextEdit2.text;
RiotGamesys_Button11.active = true;
}
}


Chompy 01-13-2008 04:28 PM

Is this the whole script? It looks kinda 'unfinished' like some parts are missing..

Like the button action event is there, but the button script part isn't there.
Also you need to set player.nick serverside :O

Grey 01-13-2008 04:59 PM

Quote:

Originally Posted by Jeffyy (Post 1369487)
Any idea why this wont change nick?

First I'll point you to Skyld's code formatting thread:
http://forums.graalonline.com/forums...ad.php?t=61805

Making your text more readable will help you to see script problems in the long run and others will be able to give you help more easily.

You cannot have a function within a function, as you have both onTimeout and the action function for the button being instigated inside onCreated, ensure that one function is closed before you start the next.

You may be ill-advised trying to do this with GUI if you don't have a lot of scripting experience because as Chompy mentioned, unless you posted a semi-complete script, the button part is missing. Also you do not need the timeout for what you are trying to achieve.

If you're determined doing this with GUI then Twinny's site is good for GUI basics: http://resource.nukedstudios.org/ind...?page=quickgui

Kristi 01-13-2008 05:33 PM

Quote:

Originally Posted by Chompy (Post 1369491)
Also you need to set player.nick serverside :O

Key statement here

Crow 01-13-2008 05:52 PM

As far as I can see, you got your timeout function inside your textedit control declaration, which is inside your created event and also includes another function. What the ****?

Tigairius 01-13-2008 06:24 PM

PHP Code:


function onActionserverside() {
  switch(
params[0]) {
    case 
"changename":
      
player.nick params[1];
    break;
  }
}

//#CLIENTSIDE
function onCreated() {
  
onTimeout();
}

new 
GuiTextEditCtrl("RiotGamesys_TextEdit2") {

  
profile GuiBlueTextEditProfile;
  
height 20;
  
text player.nick;

  
width 122;
  
176;
  
23;

}



function 
onTimeout(){
  if (
player.nick != RiotGamesys_TextEdit2.text) {
    
triggerserver("weapon"name"changename"RiotGamesys_TextEdit2.text);
  }
  
setTimer(.05);
}

function 
RiotGamesys_Button11.onAction() {
  
RiotGamesys_Button11.active false;
  
triggerserver("weapon"name"changename"RiotGamesys_TextEdit2.text);
  
RiotGamesys_Button11.active true;


I know that some people learn by example, and the posts in this thread aren't going to help you much, good luck :)

Jeffyy 01-13-2008 08:04 PM

Well, I didn't think i needed to post the WHOLE script. Thats the only part thats wrong with it and Thanks tig, That did it. What i completely forgot was to add server side, I had Client side at the top of the script.

Chompy 01-13-2008 09:50 PM

Quote:

Originally Posted by Jeffyy (Post 1369522)
Well, I didn't think i needed to post the WHOLE script. Thats the only part thats wrong with it and Thanks tig, That did it. What i completely forgot was to add server side, I had Client side at the top of the script.

Hmm, I would suggest using a lower timeout tho


All times are GMT +2. The time now is 08:05 AM.

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