#1

How do I make a drugs command?

I just want a simple one, where a player can take max 50 grams of drugs (the more you take, the longer you are on drugs).
When a player is on drugs, I want them to have their health slowly refilled.

Is this possible?
Reply
#2

Well, you could make a command like '/usedrugs' witch would check if the player has any drugs. If the player has drugs, take a certain amound away from the player and set a timer to refill his health. You could add drunk level as speacial effect.
Reply
#3

The thing is, I'm not so sure on how to do this
Reply
#4

Quote:
Originally Posted by Beginnercoder
Посмотреть сообщение
The thing is, I'm not so sure on how to do this
pawn Код:
new checkhealth;

forward WhenUsingDrugs(playerid);
public WhenUsingDrugs(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    if(health < 100)
    {
        SetPlayerHealth(playerid, health++);
    }
    else
    {
        KillTimer(checkhealth);
        SendClientMessage(playerid, -1, "You have now full health.");

    }
    return 1;
}

CMD:usedrugs(playerid, params[])
{
    new Float:health;
    GetPlayerHealth(playerid, health);
    if(health == 100)
    {
        SendClientMessage(playerid, -1, "You have full health, what is a need of drug then?");
    }
    else
    {
        SendClientMessage(playerid, -1, "You are now using drugs, your health will increase per second.");
        checkhealth = SetTimer("WhenUsingDrugs", 1000, true); // Set a timer of 1000 miliseconds (1 second)
    }
}
Really, I have no idea if this works. Give a try and anyone here if think it's wrong please feel free to edit and help him, i am on phone so i am not sure and write further .

-FalconX
Reply
#5

Hi, thanks for the reply.

That command puts my health down to like 1hp and then people can just kill me straight away.
It will then set my health to full after a while.

But I want it to go up, in stages, not just go to full health all at once.
Reply
#6

Quote:
Originally Posted by Beginnercoder
Посмотреть сообщение
Hi, thanks for the reply.

That command puts my health down to like 1hp and then people can just kill me straight away.
It will then set my health to full after a while.

But I want it to go up, in stages, not just go to full health all at once.
Sorry, EDited, please edit my previous callback of WhenUsingDrug to this one.

pawn Код:
public WhenUsingDrugs(playerid) // every second
{
    new Float:hp; // A new float that will store their health.
    GetPlayerHealth(playerid,hp); // Stores their health to the float.
    SetPlayerhealth(playerid,hp+10) // Increases their health by 10
    if(GetPlayerHealth(playerid) = 100)  // If they have 100 health
    {
        KillTimer(checkhealth); // then kill the timer.
        SendClientMessage(playerid, -1, "You have now full health.");
        return 1;
    }
    return 1;
}
Reply
#7

Hi, thanks for the reply.

I get the following errors.

error 017: undefined symbol "SetPlayerhealth"
error 001: expected token: ";", but found "if"
warning 202: number of arguments does not match definition
warning 211: possibly unintended assignment
error 022: must be lvalue (non-constant)
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
fatal error 107: too many error messages on one line
Reply
#8

Does this work?


pawn Код:
new checkhealth;
forward WhenUsingDrugs(playerid);
public WhenUsingDrugs(playerid) // every second
{
    new Float:Health; // A new float that will store their health.
        GetPlayerHealth(playerid, Health);
        if(Health < 100.00)
        {
            if(Health >= 98.000) SetPlayerHealth(playerid, 100.00);
            else SetPlayerHealth(playerid, Health+5.00);

        SendClientMessage(playerid, RED, "Your drugs have worn off!");
        SendClientMessage(playerid, RED, "You are no longer on drugs.");
        KillTimer(checkhealth);
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)