Allow players a set amount of time to type in a command? -
Noesis - 22.06.2013
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
Re: Allow players a set amount of time to type in a command? -
Goldilox - 22.06.2013
Try SetTimer probably.
Re: Allow players a set amount of time to type in a command? -
Noesis - 22.06.2013
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.
Re: Allow players a set amount of time to type in a command? -
Goldilox - 22.06.2013
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.
Re: Allow players a set amount of time to type in a command? -
Noesis - 22.06.2013
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.
Re: Allow players a set amount of time to type in a command? -
Noesis - 22.06.2013
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.
Re: Allow players a set amount of time to type in a command? -
Kindred - 22.06.2013
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.
Re: Allow players a set amount of time to type in a command? -
Noesis - 22.06.2013
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.