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 01-08-2011, 04:14 PM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
Question Sethat with image :HELP

So my server need a normaly system when the playes chat sethat the image
so the player set the hat? I scripted and scripted my problem is when i chat sethat the image nothing comes!
pls help who can gice me so a script please?
-Twaina
______________
Reply With Quote
  #2  
Old 01-08-2011, 04:32 PM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Try something like this:

PHP Code:
function onPlayerChats() {
  
  if (
player.chat.starts(":sethat")) {
    
player.attr[1] = player.chat.substring(8);
 }


Last edited by cyan3; 01-08-2011 at 04:50 PM..
Reply With Quote
  #3  
Old 01-08-2011, 04:44 PM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
Dont working if i chat sethat or :sethat the image of hat with png/gif
i dont see a hat
Reply With Quote
  #4  
Old 01-08-2011, 04:50 PM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by Twaina View Post
Dont working if i chat sethat or :sethat the image of hat with png/gif
i dont see a hat
My mistake, I used player.attr[0] instead of player.attr[1].

I edited the script and it should be working now.
Reply With Quote
  #5  
Old 01-08-2011, 05:04 PM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
´Thanks
Reply With Quote
  #6  
Old 01-08-2011, 05:05 PM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
Dont working if i chat sethat or :sethat the image of hat with png/gif
i dont see a hat again :/
Reply With Quote
  #7  
Old 01-08-2011, 05:23 PM
gwFCCtennis gwFCCtennis is offline
Chaotic
gwFCCtennis's Avatar
Join Date: Aug 2010
Location: VA
Posts: 229
gwFCCtennis is on a distinguished road
Send a message via AIM to gwFCCtennis
Quote:
Originally Posted by Twaina View Post
Dont working if i chat sethat or :sethat the image of hat with png/gif
i dont see a hat again :/
Have you uploaded the image into levels/images or possibly levels/hats?

This should work, but the script Cyan posted should work.
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("sethat")) {
    
player.attr[1] = client.ishat player.chat.tokenize()[1];
  }

Reply With Quote
  #8  
Old 01-08-2011, 05:43 PM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
nope
Reply With Quote
  #9  
Old 01-08-2011, 05:57 PM
gwFCCtennis gwFCCtennis is offline
Chaotic
gwFCCtennis's Avatar
Join Date: Aug 2010
Location: VA
Posts: 229
gwFCCtennis is on a distinguished road
Send a message via AIM to gwFCCtennis
Quote:
Originally Posted by Twaina View Post
nope
Have you given yourself the weapon?
Reply With Quote
  #10  
Old 01-08-2011, 05:58 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
try saying /find imagename on rc, and see if it's "downloadable" (also post your result )
__________________
.
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 01-08-2011, 06:23 PM
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 gwFCCtennis View Post
Have you uploaded the image into levels/images or possibly levels/hats?

This should work, but the script Cyan posted should work.
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("sethat")) {
    
player.attr[1] = client.ishat player.chat.tokenize()[1];
  }

Tokenize isn't good for single-parameter commands, it just ends up requiring players to use "quotes" down the line.

onPlayerChats is also a "deprecated" (imo) way of checking for chat commands on the client-side considering we can access the ChatBar directly.

Here's a pretty generic "sethat" using the ChatBar method.

PHP Code:
//#CLIENTSIDE

// This event is called when the player presses enter with the ChatBar
// open. Which basically happens every time the player chats.
function ChatBar.onAction() {
  
// Define the Command to check for
  
temp.cmd "sethat ";
  
// Check if Text in ChatBar starts with the command
  
if (ChatBar.text.starts(temp.cmd)) {
    
// Determine the Command's Parameter
    
temp.param ChatBar.text.substring(temp.cmd.length()).trim();
    
// Make sure Hat name ends with .png, .gif, or .mng
    
if (checkHat(temp.param)) {
      
// Set the Player's Hat to the Passed Parameter
      
player.attr[1] = temp.param;
    }
    
// Reset ChatBar text to prevent the player from saying the command in chat
    
ChatBar.text "";
  }
}

function 
checkHat(hatimg) {
  if (
hatimg.ends(".png") || hatimg.ends(".gif") || hatimg.ends(".mng")) {
    return 
true;
  } else {
    return 
false;
  }

Quick demo of substring, and trim.

PHP Code:
function onCreated() {
  
// string_variable.substring(start_position, length)
  // start_position is the letter it starts with first. Like arrays this is 
  // also zero-based. So in our example start_position 2 is "l"
  // If you don't specify length it just uses everything after it.
  // Note: When you're using this in commands you want the starting
  // position to be after the space in your command.
  
temp.str "Hello World";
  echo(
temp.str.substring(6)); // echos "World"
  
echo(temp.str.substring(05)); // echos "Hello"
  
  // string_variable.trim()
  // Trims off spaces in the front and back of a string, useful for commands.
  
temp.str "  HELLO WORLD!  ";
  echo(
temp.str.trim()); // echos "HELLO WORLD!"

  // Due to the fact that both trim and substring return strings you can
  // use them in a chain like I did in my sethat example. I.e:
  
temp.str "sethat averystupidhat.png  ";
  echo(
temp.str.substring(7).trim()); // echos "averystupidhat.png"

If your hats still don't work, you're probably not giving the right folder access (button on the top-right corner next to server flags) to your server.

It'll need these lines added to it if you're uploading to levels/hats:

PHP Code:
file  hats/*.png
file  hats/*.gif
file  hats/*.mng 
__________________
Quote:
Reply With Quote
  #12  
Old 01-08-2011, 07:21 PM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
a normaly hat system :/ not that no thanks
Reply With Quote
  #13  
Old 01-08-2011, 07:57 PM
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 Twaina View Post
a normaly hat system :/ not that no thanks
You've been given more than enough information to create your own from the posts above.

If you aren't here to learn and only to beg for scripts please leave.
__________________
Quote:
Reply With Quote
  #14  
Old 01-08-2011, 08:26 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
Quote:
Originally Posted by Twaina View Post
a normaly hat system :/ not that no thanks
His hat system did exactly what you wanted it to do. If you're just looking for scripts and not even trying to learn please **** off. See you guys in another 3 months...
__________________
Reply With Quote
  #15  
Old 01-08-2011, 09:48 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 fowlplay4 View Post
If you aren't here to learn and only to beg for scripts please leave.
Quote:
Originally Posted by cbk1994 View Post
If you're just looking for scripts and not even trying to learn please **** off.
what they said.
__________________
.
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
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 04:30 PM.


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