Graal Forums  

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

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

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?

Graal Script 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
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
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
2. Using ChatBar.onAction() and ChatBar.text

An example with the first option (which is the most common) would look like this:
Graal Script Code:
function onPlayerChats() {

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
Graal Script Code:
if ("/ani ")) {

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:
Graal Script Code:
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:
Originally Posted by
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
Graal Script 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"
Graal Script Code:
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
Reply With Quote

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 06:14 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.