08.04.2013, 16:38
This should be a pretty good start for you:
pawn Код:
#include <YSI\y_timers> // the timer I wrote uses y_timers, it's better than SetTimer and SetTimerEx IMHO
new
bool:requestingNewLife[MAX_PLAYERS], // create the boolean variable for determining if a player is requesting a new life
Timer:newLifeTimer[MAX_PLAYERS]; // create the timer variable to determine the timer ID at a later time
CMD:newlife(playerid, params[])
{
if(requestingNewLife[playerid]) // are they already requesting a new life?
return SendClientMessage(playerid, COLOR_RED, "ERROR: Please type \"/yes\" in order to start a new life."); // if so, send a message telling them to type /yes to accept it
requestingNewLife[playerid] = true; // tell the server that they're requesting a new life
newLifeTimer[playerid] = defer timerAutoCancelNewlife(playerid); // start an auto-cancellation timer
SendClientMessage(playerid, COLOR_WHITE, "In order to continue, type \"/yes\", otherwise, to cancel, you can type \"/no\"");
return 1;
}
CMD:no(playerid, params[])
{
if(!requestingNewLife[playerid])
return 1;
stop newLifeTimer[playerid]; // stop the timer
requestingNewLife[playerid] = false; // tell the server they're no longer requesting a new life
SendClientMessage(playerid, COLOR_WHITE, "You have cancelled your new life request.");
return 1;
}
CMD:yes(playerid, params[])
{
if(!requestingNewLife[playerid])
return 1;
stop newLifeTimer[playerid]; // stop the timer
requestingNewLife[playerid] = false; // tell the server they're no longer requesting a new life, you're going to process it below:
// use your saving/loading system functions to reset the player's vars
return 1;
}
timer timerAutoCancelNewLife[60000](playerid) // this timer will auto-cancel the request after a minute
{
requestingNewLife[playerid] = false;
SendClientMessage(playerid, COLOR_RED, "Your new life request has been automatically canceled.");
return 1;
}