Talking Animation OnPlayerText based with length of the message.
#1

I know how to apply the animation

"PED", "IDLE_CHAT"

However, I don't know how to make the animation play based in the text length.
Also i saw some server. The IDLE_CHAT can be apply when player is crouching.

But when i try it. It doesn't apply when crouching..

Back to topic..

"How to make the animation play based in the text length"
Reply
#2

If you want it as realistic as possible you should check what the average human words/minute rate is. After some googling I found that the average adult reads 250-300 words/minute.

Then you could use a loop to check for number of spaces in a chat message sent and then start counting words, and then make a timer based on number of words and the reading rate.

Example code:

pawn Код:
new
        wordCount;
for( new i = 0; i < strlen( text ); i ++ )
{
    if( text[ i ] == ' ' )
        wordCount ++;
}
wordCount += 1; //There will always be an extra word as there is not a space after the last word.

ApplyAnimation( playerid, "PED", "IDLE_CHAT", 1.0, 1, 1, 1, 0, ( 0.24 * wordCount )); //250 words per 60 seconds = 1 word per 0.24 seconds
Reply
#3

I didn't get what are you talking about, but I think you're saying that when a player types something(eg:anim name) and it's length is to your specific value, it'll apply an animation then. If yes, here's a kinda example:

pawn Код:
public OnPlayerText(playerid, text[])
{
 if(strfind(text, "Anim", true) != -1 && strlen(text) == 5)
 {
  //Code here.
 }
 return 0;
}
Reply
#4

Quote:
Originally Posted by LarzI
Посмотреть сообщение
If you want it as realistic as possible you should check what the average human words/minute rate is. After some googling I found that the average adult reads 250-300 words/minute.

Then you could use a loop to check for number of spaces in a chat message sent and then start counting words, and then make a timer based on number of words and the reading rate.

Example code:

pawn Код:
new
        wordCount;
for( new i = 0; i < strlen( text ); i ++ )
{
    if( text[ i ] == ' ' )
        wordCount ++;
}
wordCount += 1; //There will always be an extra word as there is not a space after the last word.

ApplyAnimation( playerid, "PED", "IDLE_CHAT", 1.0, 1, 1, 1, 0, ( 0.24 * wordCount )); //250 words per 60 seconds = 1 word per 0.24 seconds
Receive tag mismatch in the ApplyAnimation line.
Reply
#5

i try to use this

pawn Код:
new wordCount;
    for(new i = 0; i < strlen(text); i ++ )
    {
        if(text[i] == ' ')
            wordCount++;
    }
    wordCount += 1;
    new seconds = floatround(0.24, floatround_round);
    ApplyAnimation(playerid, "PED", "IDLE_CHAT", 1.0, 1, 1, 1, 0, (seconds * wordCount), 1);
no errors but it play the animation for ever.
Reply
#6

Try setting a timer according to the string and clear the animations.
Reply
#7

Quote:
Originally Posted by Romel
Посмотреть сообщение
Receive tag mismatch in the ApplyAnimation line.
Quote:
Originally Posted by ******
Посмотреть сообщение
That's because "wordCount" is an integer, as is the last parameter in "ApplyAnimation"; however, "0.24" is a float.
Honest mistake. And it should also be multiplied by 60000 as it's milliseconds. I was tired when I made the snippet, I apologize.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)