Drink animation/special_action - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Drink animation/special_action (
/showthread.php?tid=628084)
Drink animation/special_action -
HidroDF - 05.02.2017
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!
Re: Drink animation/special_action -
Micko123 - 05.02.2017
PHP код:
CMD:use(playerid, params[])
{
if(Uses[playerid] > 0)
{
if(MyObject[playerid] == 1486) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER);
Uses[playerid] -= 1;
SetPlayerAttachedObject(playerid, 0, 1486, 6); //attach it again if player has more than 0
}
else
{
SCM(playerid, ERROR, "Your %s is empty.", GetObjectName(MyObject[playerid]));
}
return 1;
}
Try that out..