Thread: Staff/SetAni
View Single Post
  #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