Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-06-2016, 10:26 PM
defaultaccount defaultaccount is offline
Cassini
Join Date: Feb 2006
Location: HeLLifAX
Posts: 299
defaultaccount is on a distinguished road
Staff/SetAni

this script isn't working at all for me. I'm trying to make it so it sets animations for example : /ani PB_Gun21-Idle.gani

but its not working. Any help?

PHP Code:
function ChatBar.onAction() {
  
tokens ChatBar.text.tokenize();
 
  if (
tokens[0] == "/ani") {
    if (
tokens[1] == "idle") {
      
client.gani_idle tokens[2];
    } elseif (
tokens[1] == "walk") {
      
client.gani_walk tokens[2];
    }
  }

Reply With Quote
  #2  
Old 02-07-2016, 09:17 AM
xenow xenow is offline
Registered User
Join Date: Jun 2005
Location: Netherlands
Posts: 22
xenow is on a distinguished road
From what i have read online, these functions exist:

setani(str aniname, str aniparams) //Sets the gani of a player.

replaceani(str defaultaniname, str newaniname) //replaces the player's default ani with the new ani.

What you ofcourse can try to do, to narrow down your problem, is to use debugging logs with: echo(tokens);

Note: i haven't scripted for this game in a while, hope you figure it out.
Reply With Quote
  #3  
Old 02-07-2016, 11:16 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
- What you want to do is: just set a random gani (probably to check if it's alright?)
- What your script does (or what the main goal from the original source was): replace certain ganis (idle, walk, grab, ...) for a (most likely) custom movement

Considering you stuck with the default movement and just want the animation to be seen on your player and not have it replace any other ganis (walk, grab, ...) you would first need to trigger the function. You probably want it to be done via the chat, so there are two options you've got:

1. Using onPlayerChats() and player.chat
2. Using ChatBar.onAction() and ChatBar.text

An example with the first option (which is the most common) would look like this:
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
  echo(
player.chat);

This would log your players chat into the f2 console.

Next thing you might want to do is to check if your player is saying a command. That could be done like
PHP Code:
if (player.chat.starts("/ani ")) {
  echo(
player.chat);

So whenever your players chat starts with '/ani ', the f2 console would display your players chat.

So now, you might want to pull the file name of your gani out of your players chat (example: '/ani walkslow.gani'). This means, we still need to check the players chat BUT ignore the '/ani ' part. To do so, you could use the substring() function. It works like this:
PHP Code:
echo(player.chat.substring(5)); 
This would display 'walkslow.gani' for example, if that is the gani you want to set. How the substring works? Here's a small description:
Quote:
Originally Posted by wiki.graal.net
obj.substring(index[,length]) - returns the string starting at the index and ending after the length specified
As an alternative you could also replace the index with
PHP Code:
("/ani ").length() 
So now we know how to check the players chat, if the player is about to say a simple command including further "parameters", all we need to do is set the players ani, which can be done like setAni(gani, parameters), simple as that. As an alternative you could also use player.ani = "gani"
PHP Code:
setAni("ganiName"parameters);
//or
player.ani "ganiName"

Now you can go ahead, play around with those examples and put together the script. I didn't post the full script on purpose. If you want to add scripts, you should understand what you're doing
__________________
MEEP!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:03 PM.


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