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 08-20-2009, 01:01 AM
littlekinky littlekinky is offline
Registered User
littlekinky's Avatar
Join Date: Sep 2007
Posts: 185
littlekinky has a little shameless behaviour in the past
Custom Chat System

Ok, Custom Chat system some people mgiht no what this is some people might not

Well on graal at the moment when a player talks text appears above the players head, i am wondering can it be done where when player talks a chat bubble appears above there head and text inside it could anyone give me a simple script to show this?

thanks
Reply With Quote
  #2  
Old 08-20-2009, 01:17 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
I am pretty sure you can disable chat being shown with the enablefeatures function, then have a script loop through the players in the level, and draw using your bubble chat function.

A crude example that should work:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
// Enablefeatures except for chat text
  
enablefeatures(allfeatures-0x80);
  
// Begin looping
  
setTimer(0.05);
}

function 
onTimeout() {
  
// Hide Last Drawn Chat
  
hideimgs(2001000);
  
// Loop through Players in the level
  
for (temp.pplayers) {
    
// Record their chat and trim it.
    
temp.player_chat temp.p.chat.trim();
    if (
temp.p.chat != "") {
      
// Draw the Text over the player.
      
with (findimg(200 temp.p.id)) {
        
temp.p.1.5;
        
temp.p.0.5;
        
style "c";
        
text temp.player_chat;
      }
    }
  }
  
// Continue Looping
  
setTimer(0.05);

Obviously build from this example, and try to optimize the drawing routine instead of hiding and redrawing every time.

Other functions that may be of help:

onRemotePlayerChats(player_obj, player_chat);
__________________
Quote:
Reply With Quote
  #3  
Old 08-20-2009, 01:37 AM
papajchris papajchris is offline
Zeus Condero
papajchris's Avatar
Join Date: Jan 2006
Location: Michigan
Posts: 1,600
papajchris is a splendid one to beholdpapajchris is a splendid one to beholdpapajchris is a splendid one to beholdpapajchris is a splendid one to behold
Its definitely possible as its been done numerous times on UC servers.
__________________
Reply With Quote
  #4  
Old 08-20-2009, 01:51 AM
littlekinky littlekinky is offline
Registered User
littlekinky's Avatar
Join Date: Sep 2007
Posts: 185
littlekinky has a little shameless behaviour in the past
Nice example thanks, also how to change the colour of it and also add a chat bubble ?
Reply With Quote
  #5  
Old 08-20-2009, 01:58 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by littlekinky View Post
Nice example thanks, also how to change the colour of it and also add a chat bubble ?
You'll have to write a script to draw a bubble behind the text, you will have to either:

- Use polygon in findimg, or:
- Use a bubble image, stretchx, and stretchy.

To change the color, you can change it like so:

PHP Code:
// Code
with (findimg(200)) {
  
text "Rawr.";
  
red 1;
  
green 0;
  
blue 0;
}
// Other Code 
But you should do some reading on your on now.
__________________
Quote:
Reply With Quote
  #6  
Old 08-20-2009, 02:16 AM
littlekinky littlekinky is offline
Registered User
littlekinky's Avatar
Join Date: Sep 2007
Posts: 185
littlekinky has a little shameless behaviour in the past
So i could make a bubble image and out the x and y
Reply With Quote
  #7  
Old 08-20-2009, 02:31 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Here's an example of how to draw an image and stretch it accordingly.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
// Draw Stretched Block
  
temp.img onDrawImage(200"block.png"4848);
  
// Adjust Blocks X + Y for example purposes.
  
with (temp.img) {
     
player.x;
     
player.y;
  }
}

// Draws an Image and stretches to the desired width and height.

function onDrawImage(img_idimg_nameimg_widthimg_height) {
  
// Initialize Image Object
  
with (findimg(img_id)) {
    
// Specify Image
    
image img_name;
    
// Determine Real Width & Height of Image
    
temp.real_width getimgwidth(image);
    
temp.real_height getimgheight(image);
    
// Default stretch values = 1, so if you want to stretch it twice it's width, you'd have to use 2.
    // Therefore: stretch = new_width / real_width;
    
stretchx img_width temp.real_width;
    
stretchy img_height temp.real_height;
  }
  
// Return Image Object for Manipulation
  
return findimg(img_id);

Instead of a block, you could use an image of a bubble instead, however a more complicated solution may be needed to make it look good.
__________________
Quote:
Reply With Quote
  #8  
Old 08-20-2009, 02:36 AM
littlekinky littlekinky is offline
Registered User
littlekinky's Avatar
Join Date: Sep 2007
Posts: 185
littlekinky has a little shameless behaviour in the past
Ok now can you make a complete script so it works for an example wud be very helpfull
Reply With Quote
  #9  
Old 08-20-2009, 02:54 AM
pooper200000 pooper200000 is offline
The Blackswan
Join Date: May 2006
Location: Asylum
Posts: 5,060
pooper200000 will become famous soon enough
Send a message via AIM to pooper200000
Just to quote the scripting forum rules, although I'm sure you all do not need the reminder.

Quote:
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.

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.
__________________
Always Watching!
Reply With Quote
  #10  
Old 08-20-2009, 02:09 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by littlekinky View Post
Ok now can you make a complete script so it works for an example wud be very helpfull
so u can copy/past?
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #11  
Old 10-20-2009, 08:30 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Old script, but I'm not getting on where the player chat should go after drawing the image.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #12  
Old 10-20-2009, 11:12 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Just a note:
On Maloria and other servers that have done this, the script for displaying the chat is done in a gani, so that the text doesn't lag behind when the player is moving.
Reply With Quote
  #13  
Old 10-20-2009, 11:15 PM
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
Text should not lag behind a player if scripted correctly. Stefan has also stated it is more efficient and faster to run a loop of all players and display things like chat that way rather than using a gani.
Reply With Quote
  #14  
Old 10-23-2009, 05:09 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
any pointers on where to run after getting the image drawn?
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #15  
Old 10-23-2009, 05:16 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Get the text in.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #16  
Old 10-23-2009, 06:51 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Nevermind
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 10-23-2009 at 06:52 PM..
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 05:37 PM.


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