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-01-2012, 06:29 PM
brokk brokk is offline
Registered User
Join Date: May 2012
Posts: 84
brokk is on a distinguished road
NPC Drop w/ value

How do I set the text in the NPC of a clientr.var.

Here is the NPC script

PHP Code:
function onCreated()
{
  
showText(205188115$pref::graal::defaultfontname"c""" @(player.clientr.hp));

//all the show text stuff that comes with it
 
setTimer(0.2);
 }
 
function 
onTimeOut()
{
destroy();


and the place script

PHP Code:
      temp.npc this.level.putNPC2(player.x+4.5player.y""); 
      
temp.npc.join("healthdisplay"); 
Reply With Quote
  #2  
Old 06-01-2012, 06:50 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Firstly, there's some things you could improve with your code. There's not really any consitancy with your styling, and instead of using a timeout you can use scheduleEvent()

Secondly, you just have to set the text of the NPC to what you want it to say using this.chat;

PHP Code:
function onCreated() {
  
this.chat player.clientr.hp;
  
scheduleEvent(2"onDestroy");
}

function 
onDestroy() {
  
this.destroy();

If that's what you mean.
Reply With Quote
  #3  
Old 06-01-2012, 07:09 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
There's no player within the scope of onCreated on the server-side.

If there is a player in the scope that is creating the NPC, then you can do e.g., temp.npc.chat = player.clientr.hp;.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #4  
Old 06-01-2012, 07:11 PM
brokk brokk is offline
Registered User
Join Date: May 2012
Posts: 84
brokk is on a distinguished road
Quote:
Firstly, there's some things you could improve with your code. There's not really any consitancy with your styling, and instead of using a timeout you can use scheduleEvent()

Secondly, you just have to set the text of the NPC to what you want it to say using this.chat;
but the NPC doesn't know which player. Basically when you touch a a certain NPC (let's call it npcA) it created the NPC drawing the player.hp (npcB)

so npcA is creating npcB but I want it to display the player who touched npcA their hp.
Doesn't it have to do with params?
Reply With Quote
  #5  
Old 06-01-2012, 07:27 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Tolnaftate2004 View Post
There's no player within the scope of onCreated on the server-side.

If there is a player in the scope that is creating the NPC, then you can do e.g., temp.npc.chat = player.clientr.hp;.
Oh crap! My bad, I wasn't thinking. Sorry for any confusion caused.
Reply With Quote
  #6  
Old 06-01-2012, 07:50 PM
brokk brokk is offline
Registered User
Join Date: May 2012
Posts: 84
brokk is on a distinguished road
Quote:
Oh crap! My bad, I wasn't thinking. Sorry for any confusion caused.
Sooooo is there any solution to my problem??
Reply With Quote
  #7  
Old 06-01-2012, 07:56 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by brokk View Post
Sooooo is there any solution to my problem??
Just set some property of the npc (say, player_hp) by doing temp.npc.player_hp = player.clientr.hp; when creating the npc (i.e., below putnpc2). Then, when you want to display the number, just use this.player_hp instead of player.clientr.hp in your class.

You could also just do temp.npc.showtext(...), if you wanted.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
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 01:10 AM.


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