Help again
#1

Код:
if (strcmp("/usedrug Heroin", cmdtext, true, 14) == 0)
    {
            if(Heroin[playerid] == 0) return SendClientMessage(playerid, -1, "Ти нямаш хероин иди си купи");
            SendClientMessage(playerid, 0xFF0000AA, "Ти изпозва 1 грам Хероин");
            SendClientMessage(playerid, 0xFF0000AA, "За да отмине ефекта напиши /drugsoff");
            Heroin[playerid]--;
            SetPlayerDrunkLevel(playerid, 900);
            SetPlayerWeather(playerid, 21);
            SetPlayerHealth(playerid, 100);
		    SetPlayerArmour(playerid, 100);
            return 1;
    }
How to make the effect to be lenght for 13 sec and then the player get's back to normal
Reply
#2

Use a timer.
Reply
#3

pawn Код:
new timer;

if (strcmp("/usedrug Heroin", cmdtext, true, 14) == 0)
    {
            if(Heroin[playerid] == 0) return SendClientMessage(playerid, -1, "Ти нямаш хероин иди си купи");
            SendClientMessage(playerid, 0xFF0000AA, "Ти изпозва 1 грам Хероин");
            SendClientMessage(playerid, 0xFF0000AA, "За да отмине ефекта напиши /drugsoff");
            Heroin[playerid]--;
            SetPlayerDrunkLevel(playerid, 900);
            SetPlayerWeather(playerid, 21);
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 100);
            timer = SetTimer("drunk",13000,false);
            return 1;
    }

forward drunk(playerid);
public drunk(playerid)
{
     SetPlayerDrunkLevel(playerid, 0);
     KillTimer(timer);
     return 1;
}
Not tested...
Reply
#4

pawn Код:
new bool:IsPlayerOnDrugs[MAX_PLAYERS] = false;
forward SetPlayerDrunkLevelEx(playerid, level);

if (strcmp("/usedrug Heroin", cmdtext, true, 14) == 0)
{
    if(Heroin[playerid] == 0) return SendClientMessage(playerid, -1, "Ти нямаш хероин иди си купи");
    if(IsPlayerOnDrugs[playerid]) return SendClientMessage(playerid, -1, "ON DRUGS ALREADY");
    SendClientMessage(playerid, 0xFF0000AA, "Ти изпозва 1 грам Хероин");
    SendClientMessage(playerid, 0xFF0000AA, "За да отмине ефекта напиши /drugsoff");
    Heroin[playerid]--;
    SetPlayerDrunkLevel(playerid, 900);
    SetPlayerWeather(playerid, 21);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    SetTimerEx("SetPlayerDrunkLevelEx", 13000, false, "ii", playerid, 0);
    IsPlayerOnDrugs[playerid] = true;
    return 1;
}

public SetPlayerDrunkLevelEx(playerid, level)
{
    SetPlayerDrunkLevel(playerid, level);
    if(level == 0) IsPlayerOnDrugs[playerid] = false;
    return 1;
}
Reply
#5

idk how to work with those
Reply
#6

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
pawn Код:
new timer;

if (strcmp("/usedrug Heroin", cmdtext, true, 14) == 0)
    {
            if(Heroin[playerid] == 0) return SendClientMessage(playerid, -1, "Ти нямаш хероин иди си купи");
            SendClientMessage(playerid, 0xFF0000AA, "Ти изпозва 1 грам Хероин");
            SendClientMessage(playerid, 0xFF0000AA, "За да отмине ефекта напиши /drugsoff");
            Heroin[playerid]--;
            SetPlayerDrunkLevel(playerid, 900);
            SetPlayerWeather(playerid, 21);
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 100);
            timer = SetTimer("drunk",13000,false);
            return 1;
    }

forward drunk(playerid);
public drunk(playerid)
{
     SetPlayerDrunkLevel(playerid, 0);
     KillTimer(timer);
     return 1;
}
Not tested...


it doesen't work
Reply
#7

Quote:
Originally Posted by coole210
Посмотреть сообщение
pawn Код:
new bool:IsPlayerOnDrugs[MAX_PLAYERS] = false;
forward SetPlayerDrunkLevelEx(playerid, level);

if (strcmp("/usedrug Heroin", cmdtext, true, 14) == 0)
{
    if(Heroin[playerid] == 0) return SendClientMessage(playerid, -1, "Ти нямаш хероин иди си купи");
    if(IsPlayerOnDrugs[playerid]) return SendClientMessage(playerid, -1, "ON DRUGS ALREADY");
    SendClientMessage(playerid, 0xFF0000AA, "Ти изпозва 1 грам Хероин");
    SendClientMessage(playerid, 0xFF0000AA, "За да отмине ефекта напиши /drugsoff");
    Heroin[playerid]--;
    SetPlayerDrunkLevel(playerid, 900);
    SetPlayerWeather(playerid, 21);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    SetTimerEx("SetPlayerDrunkLevelEx", 13000, false, "ii", playerid, 0);
    IsPlayerOnDrugs[playerid] = true;
    return 1;
}

public SetPlayerDrunkLevelEx(playerid, level)
{
    SetPlayerDrunkLevel(playerid, level);
    if(level == 0) IsPlayerOnDrugs[playerid] = false;
    return 1;
}
still doesen't work
Reply
#8

it worked thx i had to type this

Код:
public SetPlayerDrunkLevelEx(playerid, level)
{
    SetPlayerDrunkLevel(playerid, 0);
    SetPlayerWeather(playerid, 0);
    SendClientMessage(playerid, 0xAFAFAFAA, "Ефекта отмина");
    if(level == 0) IsPlayerOnDrugs[playerid] = false;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)