SA-MP Forums Archive
Make an object appear with a command. - 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: Make an object appear with a command. (/showthread.php?tid=438956)



Make an object appear with a command. - KellyG - 23.05.2013

PS : I'm french, i'm sorry for my bad english

Good evening.

I want to make a command /malette for example.
As in GTA, the briefcase already exists (ID 1210):


I wish to "spawn" in my hand (after contact j'peux change) with the command / briefcase.

Assistance? An indication?
Bye.


Re: Make an object appear with a command. - Guest123 - 23.05.2013

strcmp version

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/malette", cmdtext, true, 10) == 0)
    {
        SetPlayerAttachedObject( playerid, 0, 1210, 6, 0.250000, 0.100000, 0.000000, 0.000000, 264.337768, 21.619852, 1.000000, 1.000000, 1.000000 );
        return 1;
    }
    return 0;
}
zcmd

pawn Код:
CMD:malette(playerid,params[])
{
    SetPlayerAttachedObject( playerid, 0, 1210, 6, 0.250000, 0.100000, 0.000000, 0.000000, 264.337768, 21.619852, 1.000000, 1.000000, 1.000000 );
    return 1;
}
EDIT: any bugs ?


Re : Make an object appear with a command. - KellyG - 23.05.2013

Thank you, and to remove I use destroyobject?


Re: Make an object appear with a command. - Guest123 - 23.05.2013

nope,

zcmd
pawn Код:
CMD:disable(playerid,params[])
{
for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
if(IsPlayerAttachedObjectSlotUsed(playerid, i)) RemovePlayerAttachedObject(playerid, i);
return 1;
}
strcmp

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/disable", cmdtext, true, 10) == 0)
    {
        for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
        if(IsPlayerAttachedObjectSlotUsed(playerid, i)) RemovePlayerAttachedObject(playerid, i);
        return 1;
    }
    return 0;
}



Re : Make an object appear with a command. - KellyG - 23.05.2013

Thank you, and how do you know the exact position to place the object?


Re : Make an object appear with a command. - KellyG - 23.05.2013

And disable with a timer is possible?


Re: Make an object appear with a command. - Strier - 23.05.2013

From Guest:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/disable", cmdtext, true, 10) == 0)
    {
        SetTimerEx("Disabled", 15000, false, "i", playerid);
        SendClientMessage(playerid, -1, "Disablying in 15 seconds!");
        return 1;
    }
    return 0;

//=================================Somewhere else//
    forward Disabled(playerid);
    public Disabled(playerid)
    {
         for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
        if(IsPlayerAttachedObjectSlotUsed(playerid, i)) RemovePlayerAttachedObject(playerid, i);
        return 1;
    }



Re: Make an object appear with a command. - Guest123 - 23.05.2013

yea..