help with this command please
#1

^^^^^^^^
Reply
#2

pawn Код:
CMD:ad(playerid, params[])
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    SetPVarInt(playerid,"PillsTaken",1); // o look u set var... so as soon as the cmd is called the var is set to 1
// means that the player has already take the pill :O u need to put this after
    SetPVarInt(playerid,"PillsTaken",GetPVarInt(playerid,"PillTaken")+1); // :?
    if(isDead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
    if(iCanUse[playerid]-gettime() > 0) return SendClientMessage(playerid, COLOR_RED, "Please Wait Before Taking Another Adrenaline Pill.");
    if(health == 100) return SendClientMessage(playerid, COLOR_RED, "Your Health Is Already Full, You Cannot Take /ad.");
    if(GetPVarInt(playerid,"PillsTaken")> 0)return SendClientMessage(playerid, COLOR_RED, "You Can Only Use /ad Once In A Life Time.");
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
    ApplyAnimation(playerid,"SMOKING","M_smk_in",4.2,0,0,0,0,0,1);
    busyAnim[playerid] = true;
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Taken An Adrenaline Pill, Your Health Has Been Refilled.");
    SetPlayerChatBubble(playerid, "Has Taken Adrenaline Pill", COLOR_YELLOW, 60, 3000);
    SetPlayerHealth(playerid, 100.0);
    {

        iCanUse[playerid] = gettime() + 5; // 5 seconds
    }
    return 1;
}
pawn Код:
try this
CMD:ad(playerid, params[])
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    if(isDead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
    if(iCanUse[playerid]-gettime() > 0) return SendClientMessage(playerid, COLOR_RED, "Please Wait Before Taking Another Adrenaline Pill.");
    if(health == 100) return SendClientMessage(playerid, COLOR_RED, "Your Health Is Already Full, You Cannot Take /ad.");
    if(GetPVarInt(playerid,"PillsTaken")> 0)return SendClientMessage(playerid, COLOR_RED, "You Can Only Use /ad Once In A Life Time.");
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
    ApplyAnimation(playerid,"SMOKING","M_smk_in",4.2,0,0,0,0,0,1);
    busyAnim[playerid] = true;
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Taken An Adrenaline Pill, Your Health Has Been Refilled.");
    SetPlayerChatBubble(playerid, "Has Taken Adrenaline Pill", COLOR_YELLOW, 60, 3000);
    SetPlayerHealth(playerid, 100.0);
    {

        iCanUse[playerid] = gettime() + 5; // 5 seconds
    }
    SetPVarInt(playerid,"PillsTaken",1);
    SetPVarInt(playerid,"PillsTaken",GetPVarInt(playerid,"PillTaken")+1);
    return 1;
}
Reply
#3

^^^^^^^^
Reply
#4

dunno bout /kill but u never made a variables a timer to set the variable back to 0
Reply
#5

^^^^^^^^
Reply
#6

^^^^^^^^
Reply
#7

you forgot to delete the pvar when the callback OnPlayerDeath is called

try to add this on OnPlayerDeath

pawn Код:
OnPlayerDeath(playerid, killerid, reason)
{
    DeletePVar(playerid,"PillsTaken"); //Deletes the variable that you just set when player dies
    return 1;
}
Reply
#8

^^^^^^^^
Reply
#9

so as i never used Pvars before. so i recreated your code and make it into a normal variable

pawn Код:
new PillsTaken[MAX_PLAYERS];

CMD:ad(playerid, params[])
{
        new Float:health;
        GetPlayerHealth(playerid,health);
        if(isDead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
        if(iCanUse[playerid]-gettime() > 0) return SendClientMessage(playerid, COLOR_RED, "Please Wait Before Taking Another Adrenaline Pill.");
        if(health == 100) return SendClientMessage(playerid, COLOR_RED, "Your Health Is Already Full, You Cannot Take /ad.");
        //
        if(PillsTaken == 1)return SendClientMessage(playerid, COLOR_RED, "You Can Only Use /ad Once In A Life Time.");
        //
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
        ApplyAnimation(playerid,"SMOKING","M_smk_in",4.2,0,0,0,0,0,1);
        busyAnim[playerid] = true;
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Taken An Adrenaline Pill, Your Health Has Been Refilled.");
        SetPlayerChatBubble(playerid, "Has Taken Adrenaline Pill", COLOR_YELLOW, 60, 3000);
        SetPlayerHealth(playerid, 100);
        {
            iCanUse[playerid] = gettime() + 5; // 5 seconds
        }
        PillsTaken =1;//sets the variable pills taken to 1
        return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    PillsTaken =0;//sets the variable pills taken to 1
    return 1;
}
Reply
#10

Код:
CMD:ad(playerid, params[])
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    if(GetPVarInt(playerid,"PillsTaken")> 0)return SendClientMessage(playerid, COLOR_RED, "You Can Only Use /ad Once In A Life Time.");
    if(isDead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
    if(health == 100) return SendClientMessage(playerid, COLOR_RED, "Your Health Is Already Full, You Cannot Take /ad.");
    SetPVarInt(playerid,"PillsTaken",1);
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
    ApplyAnimation(playerid,"SMOKING","M_smk_in",4.2,0,0,0,0,0,1);
    busyAnim[playerid] = true;
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Taken An Adrenaline Pill, Your Health Has Been Refilled.");
    SetPlayerChatBubble(playerid, "Has Taken Adrenaline Pill", COLOR_YELLOW, 60, 3000);
    SetPlayerHealth(playerid, 100.0);
    return 1;
}

//Put this under OnPlayerSpawn
SetPVarInt(playerid,"PillsTaken",0);
OK so with this u can take it once "in a life-time" and thats it

Is that what u wanted?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)