Carry animation - 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: Carry animation (
/showthread.php?tid=560693)
Carry animation -
jeffery30162 - 30.01.2015
How can i make a player pickup a box on the ground and carry it?
Re: Carry animation -
Abagail - 30.01.2015
Create a box object using CreateObject(or preferably using a streamer plug-in).
Then to make them "carry" the object, you'd need to find offsets for the skins you're intending on carrying said box. Then attach the box object using AttachObjectToPlayer accordingly. Then, use SPECIAL_ACTION_CARRY to set them in the carrying animation.
This might help you get started:
pawn Код:
SetPlayerCarry(playerid, bool: toggle)
{
if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
if(toggle == true)
{
SetPVarInt(playerid, "is_carrying_box", 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
return 1;
}
else
{
SetPVarInt(playerid, "is_carrying_box", 0);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
return 1;
}
return -1;
}
IsPlayerCarryingBox(playerid)
{
if(GetPVarInt(playerid, "is_carrying_box"))
{
return 1;
}
return 0;
}
Re: Carry animation -
ikey07 - 30.01.2015
on command/key apply pickup anim, then set avarage anim play time in the timer, at time set idle anim, and at drop, apply dropping anim.
Re: Carry animation -
jeffery30162 - 30.01.2015
ok thanks =), i may need help again later
Re: Carry animation -
Kar - 30.01.2015
Quote:
Originally Posted by Abagail
Create a box object using CreateObject(or preferably using a streamer plug-in).
Then to make them "carry" the object, you'd need to find offsets for the skins you're intending on carrying said box. Then attach the box object using AttachObjectToPlayer accordingly. Then, use SPECIAL_ACTION_CARRY to set them in the carrying animation.
This might help you get started:
pawn Код:
SetPlayerCarry(playerid, bool: toggle) { if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID; if(toggle == true) { SetPVarInt(playerid, "is_carrying_box", 1); SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY); return 1; } else { SetPVarInt(playerid, "is_carrying_box", 0); SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE); return 1; } return -1; }
IsPlayerCarryingBox(playerid) { if(GetPVarInt(playerid, "is_carrying_box")) { return 1; } return 0; }
|
How about we add less spice to this code?
For someone who knows what they are doing
pawn Код:
SetPlayerCarry(playerid, bool:toggle)
{
if(!IsPlayerConnected(playerid)) return 0;
return SetPlayerSpecialAction(playerid, (toggle == true) ? SPECIAL_ACTION_CARRY : SPECIAL_ACTION_NONE);
}
IsPlayerCarryingBox(playerid) return GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CARRY;
For someone who doesn't know what they are doing
pawn Код:
SetPlayerCarry(playerid, bool:toggle)
{
if(!IsPlayerConnected(playerid)) return 0;
if(toggle == true && GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_CARRY)
{
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
}
else
{
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
}
return 1;
}
IsPlayerCarryingBox(playerid)
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CARRY)
return 1;
return 0;
}