05.02.2017, 17:59
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:
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!
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;
}
Anyone can help me? Thanks!

