Drink animation/special_action
#1

Hello. I've made a custom Inventory system and now I'm making the actions for the items. I've created a command called /use, this checks what object attached you have in your hand and applies an special action.

Fast code:

Код:
new MyObject[MAX_PLAYERS];
new Uses[MAX_PLAYERS];

CMD:buy(playerid, params[])
{
    // At this time, for testing I have only the beer object.
    SetPlayerAttachedObject(playerid, 0, 1486, 6);
    MyObject[playerid] = 1486;
    Uses[playerid] = 4;
    return 1;
}

CMD:use(playerid, params[])
{
    if(Uses[playerid] > 0)
    {
        if(MyObject[playerid] == 1486) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER);
        Uses[playerid] -= 1;
    }
    else
    {
        SCM(playerid, ERROR, "Your %s is empty.", GetObjectName(MyObject[playerid]));
    }
    return 1;
}

stock GetObjectName(object)
{
    new n[10];
    if(object == 1486) n = "beer";
    return n;
}
Ok, the SPECIAL_ACTION gives to the player another bottle of beer. Then I have to make left click to drink. What I want is, when I use /use, the player drinks automatically and no other bottle attached to hand.

Anyone can help me? Thanks!
Reply
#2

PHP код:
CMD:use(playeridparams[])
{
    if(
Uses[playerid] > 0)
    {
        if(
MyObject[playerid] == 1486SetPlayerSpecialAction(playeridSPECIAL_ACTION_DRINK_BEER);
        
Uses[playerid] -= 1;
        
SetPlayerAttachedObject(playerid014866); //attach it again if player has more than 0
    
}
    else
    {
        
SCM(playeridERROR"Your %s is empty."GetObjectName(MyObject[playerid]));
    }
    return 
1;

Try that out..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)