Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-03-2007, 06:11 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
Simple, yet Confusing problem.

I cannot get this script to work. It is so simple yet it will not work.
The script is a baddy for a quest and as you can see it asks you a question, the player is supposed to respond with an answer.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
showcharacter();
  
head       "head47.png";
  
colors0] = "orange";
  
colors1] = "black";
  
colors2] = "darkred";
  
colors3] = "white";
  
colors4] = "black";
  
shield     "no-shield.png";
  
body       "body18.png";
  
dir        2;
  
setcharani("niromia2_idle",NULL);
  
  
showtext1this.x+1.5this.y-.5"Kartika""cb""Click me");
}

function 
onMouseDown(button)
{
  if (
button == "left" || button == "right") {
    if (
mousex in 2326| && mousey in 4446|) {
      
say2("If you can answer one question...
   I will aid you in your quest.

   What are the 2 nations on Niromia?"
);
    }
  }
}

function 
onPlayerChats() {
  if (
player.chat == "test") {
    
findimg(1).text "I will now give you this weapon.";
  }

Anybody know what the problem is?
Reply With Quote
  #2  
Old 06-03-2007, 08:22 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Please be more clear with your problem; what does and doesn't function correctly?
__________________
Skyld
Reply With Quote
  #3  
Old 06-03-2007, 08:26 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
For some reason I recall hearing somewhere that showtext isn't supposed to be used under onCreated...
__________________
Reply With Quote
  #4  
Old 06-03-2007, 08:33 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by Googi View Post
For some reason I recall hearing somewhere that showtext isn't supposed to be used under onCreated...
I use it all the time under 'onCreated' x.x
__________________
What signature? I see no signature?
Reply With Quote
  #5  
Old 06-03-2007, 08:33 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by Googi View Post
For some reason I recall hearing somewhere that showtext isn't supposed to be used under onCreated...
I works, I've done it before. :/
__________________
Deep into the Darkness peering...
Reply With Quote
  #6  
Old 06-03-2007, 11:04 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
It may work but there could be unknown reasons as to why it would be better to use it some other way, like in onPlayerEnters().
__________________
Reply With Quote
  #7  
Old 06-04-2007, 12:29 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
My problem is when the player answers the question (saying test) nothing happens. It just stays the same.
Reply With Quote
  #8  
Old 06-04-2007, 12:38 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Have you took steps to debug it?
Have tried having it do something else, like changing the players text instead of changing the image?
You should break down the part of the script not working, adding little test lines until you can find out specifically what the problem is.
Reply With Quote
  #9  
Old 06-04-2007, 12:57 AM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by MrAnonymous_P2P View Post
My problem is when the player answers the question (saying test) nothing happens. It just stays the same.
PHP Code:
//#CLIENTSIDE
function onPlayerChats()
{
     if (
player.chat.trim() == "test")
     {
          
// Yadda yadda yadda.
     
}

__________________
What signature? I see no signature?
Reply With Quote
  #10  
Old 06-04-2007, 04:34 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
Ok now this is just being plain weird.
I got the script to work just fine except for one problem.

NPC Code:
//#CLIENTSIDE
function onCreated() {
showcharacter();
head = "head47.png";
colors[ 0] = "orange";
colors[ 1] = "black";
colors[ 2] = "darkred";
colors[ 3] = "white";
colors[ 4] = "black";
shield = "no-shield.png";
body = "body18.png";
dir = 2;
setcharani("niromia2_idle",NULL);

showtext( 1, this.x+1.5, this.y-.5, "Kartika", "cb", "Click me");
}

function onMouseDown(button)
{
if (button == "left" || button == "right") {
if (mousex in | 23, 26| && mousey in | 44, 46|) {
showtext( 1, this.x+1.5, this.y-.5, "Kartika", "cb", "If you can answer this question I will give you a prize.");
sleep(5);
showtext( 1, this.x+1.5, this.y-.5, "Kartika", "cb", "What are the two nations on Niromia?");
}
}
}
//#CLIENTSIDE
function onPlayerChats()
{
if (player.chat.trim() == "test")
{
showtext( 1, this.x+1.5, this.y-.5, "Kartika", "cb", "I will now present you with this weapon.");
sleep(5);
destroy();
}
}



Now this all works except when I click on the Baddy the showtext works ok but for some reason it also gives me a sign with the previous script which said to show a sign. And it does the same thing for when the player chats test. It shows me a sign and it changes the text above the baddy. Its like the script before this one and this modified one are conjoined together. Anybody know how to fix this?
Reply With Quote
  #11  
Old 06-04-2007, 05:07 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
ERROR! ERROR! ERROR!

You are using 2x //#CLIENTSIDE, terminating program.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #12  
Old 06-04-2007, 05:19 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
It still doesnt work even if I take the clientside out
Reply With Quote
  #13  
Old 06-04-2007, 05:31 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Is this NPC a class?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #14  
Old 06-04-2007, 02:46 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
I find it using findimg() would be better..

findimg(index).text = "foo";

instead of recreating the TShowImg object you can just change the vars of it..
__________________
Reply With Quote
  #15  
Old 06-04-2007, 05:08 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
reconnect? : )
__________________
**FLIP OUT**
Reply With Quote
  #16  
Old 06-04-2007, 06:45 PM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
I reconnected, and nothing happened, and yes it is an npc class.
Reply With Quote
  #17  
Old 06-06-2007, 03:06 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
showtext shows an image, which the engine generates with the characters given. It isn't a GuiTextCtrl, or such, and the text can't be changed like that ...

You need to reshow the text in order for it to change.
__________________
Reply With Quote
  #18  
Old 06-06-2007, 03:08 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by cbkbud View Post
showtext shows an image, which the engine generates with the characters given. It isn't a GuiTextCtrl, or such, and the text can't be changed like that ...

You need to reshow the text in order for it to change.
findimg(index).text
__________________
Reply With Quote
  #19  
Old 06-06-2007, 03:32 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by cbkbud View Post
showtext shows an image, which the engine generates with the characters given. It isn't a GuiTextCtrl, or such, and the text can't be changed like that ...

You need to reshow the text in order for it to change.
No you don't. In fact, let me show you something that the engine has in it.

PHP Code:
function showtext(inxnyfst) {
  
findimg(i).text t;
  
findimg(i).nx;
  
findimg(i).ny;
  
findimg(i).font f;
  
findimg(i).style s;

I may have gotten some of the variable names wrong but in essence, that is all that that function is doing.
__________________
Do it with a DON!
Reply With Quote
Reply


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 12:34 AM.


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