04.02.2018, 13:52
PHP код:
CMD:newitem(playerid, params[])
{
if (!IsPlayerAdmin(playerid))
{
return SendClientMessage(playerid, COLOR_TOMATO, "You must be RCON-Admin to use this command.");
}
new itemName[MAX_ITEM_NAME], itemModelid;
if (sscanf(params, "is[64]", itemModelid, itemName))
{
return SendClientMessage(playerid, COLOR_DEFAULT, "Usage: /newitem [modelid] [name]");
}
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new Float:ang;
GetPlayerFacingAngle(playerid, ang);
x += (1.5 * floatsin(-ang, degrees));
y += (1.5 * floatcos(-ang, degrees));
new itemid = Inv_AddItem(itemModelid, itemName, x, y, z);
if (itemid == -1)
{
return SendClientMessage(playerid, COLOR_TOMATO, "Cannot add anymore items, reached limit.");
}
Inv_EditItem(playerid, itemid);
new string[128];
format(string, sizeof string, "Item created: %s [itemid: %i | modelid: %i]", itemName, itemid, itemModelid);
SendClientMessage(playerid, COLOR_GREEN, string);
createdItems[createdItemsCount++] = itemid;
SendClientMessage(playerid, COLOR_DEFAULT, "Item added to /items list, If you want to duplicate this item, type /additem.");
return 1;
}