06.09.2011, 00:41
(
Последний раз редактировалось =WoR=G4M3Ov3r; 06.10.2011 в 17:52.
)
Using SetPlayerAttachedObject
- In this Tutorial, I will be showing you guys how to use SetPlayerAttachedObject, using this code is easy, but as it shows in the wiki, you might get confused, so this is the right way to use it.
- As you all know, in the previous SA-MP versions, we had SetPlayerHoldingObject, Now it was removed from SAMP version 0.3c, as stated in the wiki.
Quote:
Warning: This function was removed in SA-MP 0.3c |
- The current way of using SetPlayerAttachedObject is this way:
PHP код:
SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ);
- In order to use it like SetPlayerHoldingObject
PHP код:
SetPlayerHoldingObject(playerid, model, bone);
- You will need the following defines, posted on the top of your script, under the includes.
PHP код:
#define SetPlayerHoldingObject(%1,%2,%3,%4,%5,%6,%7,%8,%9) SetPlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1,%2,%3,%4,%5,%6,%7,%8,%9)
#define StopPlayerHoldingObject(%1) RemovePlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
#define IsPlayerHoldingObject(%1) IsPlayerAttachedObjectSlotUsed(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
- After defining it, it'll be able to be used this way:
PHP код:
SetPlayerAttachedObject(playerid, index, model, bone);
- Now you want to use it in a CMD of yours, For example a Redcone, I'll be giving an example of using it with ZCMD, and STRCMP.
PHP код:
CMD:redcone(playerid, params[])
{
SetPlayerAttachedObject(playerid,3, 1238, 6); // Bone 6 means Right handed
SendClientMessage(playerid, COLOR_GREEN, "You are holding a Redcone.");
return 1;
}
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/redcone", true))
{
SetPlayerAttachedObject(playerid, 3, 1238, 6);
SendClientMessage(playerid, COLOR_GREEN, "You are holding a Redcone");
return 1;
}
return 0;
}
- You can destroy the object, by simply using RemovePlayerAttachedObject, And you will need IsPlayerAttachedObjectSlotUsed.
PHP код:
RemovePlayerAttachedObject(playerid,index)
- Index here, refers to "slot", just like IsPlayerAttachedObjectSlotUsed.
PHP код:
IsPlayerAttachedObjectSlotUsed(playerid, slot)
- For Example, when you die, the item shouldn't be attached to the player anymore, use it this way:
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerAttachedObjectSlotUsed(playerid, slot)) RemovePlayerAttachedObject(playerid, slot);
return 1;
}
Whats bone ?
- bone is the part of the body you want to attach the object to.
If there's anything i missed, or you got any problems, please post.
Credits: The SA-MP Wiki.