[Dr.Zero]
К переменным
Далее создаём publik самого апдейта очков энергии (отбираем очки энергии):
в public OnGameModeInit вставляем:
Создаём команду что бы проснуться. Добавляем в public OnPlayerCommandText(playerid, cmdtext[]):
И ко всем командам
PHP:
new psleep[MAX_PLAYERS]; // Создаёт каждому игроку счётчик Энергитических очков...
forward UpdateSleep(playerid); // Для паблика апдейта очков энергии...
PHP:
public UpdateSleep(playerid) { // Паблик апдейта очков энергии
psleep[playerid]++;
switch(psleep[playerid])
{
case 7 .. 9:
{
SendClientMessage(playerid, -1, "(( Вы устали, вам нужно поспать! ))");
}
case 10:
{
SendClientMessage(playerid, -1, "(( Вы уснули. (Проснуться - /unsleep). ))");
TogglePlayerControllable(playerid, 0);
SetPVarInt(playerid,"SLEEP",gettime()+120);
ApplyAnimation(playerid,"CRACK","crckidle2",4.1,0,1,1,1,1);
ApplyAnimation(playerid,"CRACK","crckidle2",4.1,0,1,1,1,1);
}
}
return 1; }
PHP:
SetTimer("UpdateSleep",300000,1);
PHP:
if (strcmp(cmd, "/unsleep", true) == 0) {
if(GetPVarInt(playerid,"SLEEP") > gettime()) {
SendClientMessage(playerid,-1,"(( Вы ещё не выспались... ))");
return 1; }
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid,-1,"(( Вы выспались... ))");
psleep[playerid] = 0;
return 1; }
PHP:
if (strcmp(cmd, "/sleep", true) == 0) {
if (!PlayerToPoint(3.0, playerid, X,Y,Z) { // X,Y,Z - Координаты кровати
SendClientMessage(playerid,-1,"(( Вы не на кровати! ))");
return 1; }
if (psleep[playerid] <= 3) {
SendClientMessage(playerid,-1,"(( Вы не устали, что-бы спать! ))");
return 1; }
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid,-1,"(( Вы легли спать... (1 минута) (Что-бы проснуться /unsleep) ))");
SetPVarInt(playerid,"SLEEP",gettime()+60);
ApplyAnimation(playerid,"CRACK","crckidle2",4.1,0,1,1,1,1); ApplyAnimation(playerid,"CRACK","crckidle2",4.1,0,1,1,1,1);
return 1; }
