SA-MP Forums Archive
Easy adding object question - 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: Easy adding object question (/showthread.php?tid=393091)



Easy adding object question - jakejohnsonusa - 17.11.2012

How would I add an abject to where a player is. Like set it on the ground where they are? If someone could write the code out that would be great!

Thanks: jakejohnsonusa

(This will be for setting a boombox object when they use the boombox cmd)


Re: Easy adding object question - NumbSkull - 17.11.2012

pawn Код:
CMD:makeobject(playerid, params[])
{
    new Float:mX, Float:mY, Float:mZ;
    GetPlayerPos(playerid, mX, mY, mZ);
    CreateObject(3409, mX, mY, mZ-1.5, 0.0, 0.0, 0.0);
    return 1;
   
}



Re: Easy adding object question - jakejohnsonusa - 17.11.2012

And to remove it?


Re: Easy adding object question - ReneG - 17.11.2012

Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
And to remove it?
Store the object id into an array for later deletion.
pawn Код:
new playerBoombox[MAX_PLAYERS];

CMD:boombox(playerid, params[])
{
    new Float:mX, Float:mY, Float:mZ;
    GetPlayerPos(playerid, mX, mY, mZ);
    playerBoombox[playerid] = CreateObject(2103, mX, mY, mZ-1.5, 0.0, 0.0, 0.0);
    return 1;
}

CMD:removeboombox(playerid, params[])
{
    if(!IsValidObject(playerBoombox[playerid])) {
        return SendClientMessage(playerid, -1, "You haven't made a boombox!");
    }

    DestroyObject(playerBoombox[playerid]);
    SendClientMessage(playerid, -1, "Boombox removed.");
    return 1;
}



Re: Easy adding object question - jakejohnsonusa - 17.11.2012

Thanks!