Talking Animation OnPlayerText based with length of the message. -
JaKe Elite - 06.12.2012
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"
Re: Talking Animation OnPlayerText based with length of the message. -
LarzI - 07.12.2012
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
Re: Talking Animation OnPlayerText based with length of the message. -
Lordzy - 07.12.2012
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;
}
Re: Talking Animation OnPlayerText based with length of the message. -
JaKe Elite - 07.12.2012
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.
Re: Talking Animation OnPlayerText based with length of the message. -
JaKe Elite - 07.12.2012
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.
Re: Talking Animation OnPlayerText based with length of the message. -
Lordzy - 07.12.2012
Try setting a timer according to the string and clear the animations.
Re: Talking Animation OnPlayerText based with length of the message. -
LarzI - 07.12.2012
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.