13.06.2014, 12:24
Item Loot System Tutorial
Introduction
+This Is Loot Item But not inventory
Ok We Start
Firts
We need Include Item by me
or link :http://pastebin.com/F3YmW3xn
Ok.. part two
You need Define Max item drop
after use map editor get pos to create item
EX:
then use features createitem
and put it to OnGameModeInit()
Part three
public OnPlayerPickupItem(playerid)
or you can make cmd drop item
i use include zcmd to make cmd and use dropitem
Ok But item can create/drop random pos
then
Finish How to pickup item
use PRESSED key
Ok Complete
Introduction
+This Is Loot Item But not inventory
Ok We Start
Firts
We need Include Item by me
PHP код:
new DropObject[MAX_DROP_ITEMS]; // object drop id
new Text3D:Label[MAX_DROP_ITEMS]; // Label Model
//=================
enum ItemData
{
ItemModel,//Model object
ItemAmount,//Amount for gun
Float:ItemPosX,
Float:ItemPosY,
Float:ItemPosZ,
Float:ItemRotX,
Float:ItemRotY,
Float:ItemRotZ,
ItemVWorld,
ItemInterior,
};
new ItemInfo[MAX_DROP_ITEMS][ItemData];
forward OnPlayerPickupItem(playerid);
stock CreateItem(Model,Amount,Float:X, Float:Y, Float:Z,Float:RX,Float:RY,Float:RZ, world, interior)
{
if(Model != 0)
{
for(new i = 0; i < sizeof(ItemInfo); i++)
{
if(ItemInfo[i][ItemPosX] == 0.0 && ItemInfo[i][ItemPosY] == 0.0 && ItemInfo[i][ItemPosZ] == 0.0)
{
ItemInfo[i][ItemModel] = Model;
ItemInfo[i][ItemAmount] = Amount;
ItemInfo[i][ItemPosX] = X;
ItemInfo[i][ItemPosY] = Y;
ItemInfo[i][ItemPosZ] = Z;
ItemInfo[i][ItemRotX] = RX;
ItemInfo[i][ItemRotY] = RY;
ItemInfo[i][ItemRotZ] = RZ;
ItemInfo[i][ItemVWorld] = world;
ItemInfo[i][ItemInterior] = interior;
Label[i] = Create3DTextLabel("Item", 0x008080FF,X,Y,Z,5.0,world, 0);
DropObject[i] = CreateObject(Model, X, Y, Z,RX,RY,RZ, world);
return 1;
}
}
return 1;
}
return 1;
}
stock DropItem(Model,Amount, Float:X, Float:Y, Float:Z, world, interior)
{
if(Model != 0)
{
for(new i = 0; i < sizeof(ItemInfo); i++)
{
if(ItemInfo[i][ItemPosX] == 0.0 && ItemInfo[i][ItemPosY] == 0.0 && ItemInfo[i][ItemPosZ] == 0.0)
{
ItemInfo[i][ItemModel] = Model;
ItemInfo[i][ItemAmount] = Amount;
ItemInfo[i][ItemPosX] = X;
ItemInfo[i][ItemPosY] = Y;
ItemInfo[i][ItemPosZ] = Z;
ItemInfo[i][ItemVWorld] = world;
ItemInfo[i][ItemInterior] = interior;
Label[i] = Create3DTextLabel("Item", 0x008080FF,X,Y,Z, 5.0,world, 0);
DropObject[i] = CreateObject(Model, X, Y, Z-1,0.0, 0.0, 0.0, world);
return 1;
}
}
return 1;
}
return 1;
}
//=================//
Ok.. part two
You need Define Max item drop
PHP код:
#define MAX_DROP_ITEMS 100//or orther number
EX:
PHP код:
CreateObject(1582, 200.68184, 1910.63416, 16.71287, 0.00000, 0.00000, 0.00000);//1582 is Model pizza box
PHP код:
CreateItem(Model,Amount,Float:X, Float:Y, Float:Z,Float:RX,Float:RY,Float:RZ, world, interior)
PHP код:
CreateItem(1582,1,200.68184, 1910.63416, 16.71287, 0.00000, 0.00000, 0.00000, 0, 0);
Part three
public OnPlayerPickupItem(playerid)
PHP код:
public OnPlayerPickupItem(playerid)
{
for(new i = 0; i < sizeof(ItemInfo); i++)
{
if (IsPlayerInRangeOfPoint(playerid, 2.0,ItemInfo[i][ItemPosX],ItemInfo[i][ItemPosY],ItemInfo[i][ItemPosZ]))//when player in range of point item
{
if(GetPlayerVirtualWorld(playerid) == ItemInfo[i][ItemVWorld] && GetPlayerInterior(playerid) == ItemInfo[i][ItemInterior])
{
new istring[128];
ItemInfo[i][ItemPosX] = 0.0;
ItemInfo[i][ItemPosY] = 0.0;
ItemInfo[i][ItemPosZ] = 0.0;
ItemInfo[i][ItemRotX] = 0.0;
ItemInfo[i][ItemRotY] = 0.0;
ItemInfo[i][ItemRotZ] = 0.0;
format(istring, sizeof(istring), "Amount:%d",ItemInfo[i][ItemAmount]);
if(ItemInfo[i][ItemModel] == 1582)
{
Delete3DTextLabel(Label[i]);
DestroyObject(DropObject[i]);
SendClientMessage(playerid,-1,"You pickup item Pizza");
SendClientMessage(playerid,-1,istring);
ItemInfo[i][ItemAmount] = 0;
}
return 1;
}
}
}
return 1;
}
i use include zcmd to make cmd and use dropitem
PHP код:
DropItem(Model,Amount, Float:X, Float:Y, Float:Z, world, interior)
PHP код:
CMD:droptest(playerid,params[])
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
DropItem(1582,1,x,y,z,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
return 1;
}
PHP код:
new ItemRandom[2] = {
1582,1486};
PHP код:
CreateItem(ItemRandom[random(2)],1,200.68184, 1910.63416, 16.71287, 0.00000, 0.00000, 0.00000, 0, 0);
use PRESSED key
PHP код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_WALK)) // key ALT
{
OnPlayerPickupItem(playerid);
}
return 1;
}