SetPlayerHoldingObject
#1

When you use SetPlayerHoldingObject, is it created like a normal object? For example could I do
pawn Код:
new object;
object = SetPlayerHoldingObject(playerid, 1609, 2);
I'm going to try something really cool ^^
Reply
#2

https://sampwiki.blast.hk/wiki/SetPlayerHoldingObject

No, it does not return the object id, only 1 or 0.
Reply
#3

You can do something like:

nvm
Reply
#4

Quote:
Originally Posted by MartinDee
Посмотреть сообщение
You can do something like:

pawn Код:
new Shield[MAX_PLAYERS];
new WithShield[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/shield", cmdtext, true, 10) == 0)
    {
        if(WithShield[playerid] == 0)
        {
            ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,1,1,1);
            Shield[playerid] = CreateObject(1533,2470.573,-1660.366,14.271,0.0,0.0,-90.000);
            AttachObjectToPlayer(Shield[playerid],playerid,-0.8,0.5,-1.65,0.0,0,0.0);
            ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,1,1,1);
            DestroyObject(Shield[playerid]);
            SetTimerEx("SAnim", 500, 0, "i", playerid);
            WithShield[playerid] = 1;
            return 1;
        }
        else if(WithShield[playerid] == 1)
        {
            DestroyObject(Shield[playerid]);
            SendClientMessage(playerid,ROJO,"You have dropped the shield.");
            ClearAnimations(playerid);
            WithShield[playerid] = 0;
            return 1;
        }
    }
    return 0;
}

forward SAnim(playerid);
public SAnim(playerid)
{
    ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,1,1,1);
    return 1;
}
Thanks MartinDee, I'll try it like that and see if it works
Reply
#5

If you want this working:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP)
    {
        if(WithShield[playerid] == 1)
        {
            new Float: X, Float: Y, Float: Z;
            GetPlayerPos(playerid,X,Y,Z);
            SetPlayerPos(playerid,X,Y,Z);
            ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,1,1,1);
            SetTimerEx("SAnim", 500, 0, "i", playerid);
        }
    }
    if(newkeys == KEY_FIRE)
    {
        if(WithShield[playerid] == 1)
        {
            ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,1,1,1);
            SetTimerEx("SAnim", 500, 0, "i", playerid);
        }
    }
    if(newkeys == KEY_CROUCH)
    {
        if(WithShield[playerid] == 1)
        {
            new Float: X, Float: Y, Float: Z;
            GetPlayerPos(playerid,X,Y,Z);
            SetPlayerPos(playerid,X,Y,Z);
            ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,1,1,1);
            SetTimerEx("SAnim", 500, 0, "i", playerid);
        }
    }
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(WithShield[playerid] == 1)
        {
            WithShield[playerid] = 0;
            DestroyObject(Shield[playerid]);
            SendClientMessage(playerid,ROJO,"You have dropped the shield.");
            ClearAnimations(playerid);
        }
    }
    return 1;
}
Add this also
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)