Allow players a set amount of time to type in a command?
#1

I've gotten back into coding as a little hobby and have ran into a road block sort of speak.

I need to find an option to where I can give a player a set amount of time to enter a command to perform an animation.

I've tried loops, loops with tickcount, timers, you name it, but all of them stop the player from being able to enter anything and execute an animation.

Example in words:
Send client message: You have 10 seconds to wave your hand
*As the next 10 seconds pass the player tries to enter /wave command and execute a looped animation*
After those 10 seconds pass then check player animation
If player is waving hand then
If player is not waving hand then
Reply
#2

Try SetTimer probably.
Reply
#3

Quote:
Originally Posted by Goldilox
Посмотреть сообщение
Try SetTimer probably.
Unfortunately, I have tried that. I was unable to type in my animation command while "waiting" for the timer function to go through.
Reply
#4

Quote:
Originally Posted by Noesis
Посмотреть сообщение
Unfortunately, I have tried that. I was unable to type in my animation command while "waiting" for the timer function to go through.
Why not? Make a stock and run it into the animation command.
Reply
#5

Quote:
Originally Posted by Goldilox
Посмотреть сообщение
Why not? Make a stock and run it into the animation command.
I've never used a stock before. I'll check out the wiki and report back later today. Thanks for the suggestion.
Reply
#6

Quote:
Originally Posted by Goldilox
Посмотреть сообщение
Why not? Make a stock and run it into the animation command.
So I've read through the wiki on stocks and I'm still unsure how this would be implemented for my needs. Could you provide a code example please? I read SetTimer can't use a stock and I'm not sure what you meant by "run it into"

Thanks in advance.
Reply
#7

Look at this, something like it should work.

pawn Код:
new WaveTimer[MAX_PLAYERS]; //Global Variable

SetTimerEx("wavetimer", 10000, false, "i", playerid); //Starts the timer
WaveTimer[playerid] = 1; //Sets the variable to 1
SendClientMessage(playerid, -1, "SERVER: In the next 10 seconds, wave to your friend!"); //Sends client message, informing what to do

CMD:wave(playerid, params[])
{
    if(WaveTimer[playerid] == 1) //If the timer has indeed started
    {
        //Do something here
    }
    return 1;
}

forward wavetimer(playerid);


public wavetimer(playerid)
{
    if(GetPlayerAnimationIndex(playerid) == value)
    {
        //Yay, the player is using that animation!
    }
    else
    {
        //Nay, the player is not using that animation!
    }
    return 1;
}
Good luck, though.
Reply
#8

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Look at this, something like it should work.
*code*
Good luck, though.
I feel like an idiot right now. I forgot to preload anims in my code. The timer wasn't preventing the anim from working, but rather I just needed to do it twice or preload it.

Either way, your code helped mine to become a little more organized. Thank you and Goldilox for the quick responses.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)