[Tutorial] Item Loot System
#1

Item Loot System Tutorial
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:XFloat:YFloat:Z,Float:RX,Float:RY,Float:RZworldinterior)
{
    if(
Model != 0)
    {
        for(new 
0sizeof(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,world0);
                
DropObject[i] = CreateObject(ModelXYZ,RX,RY,RZworld);
                return 
1;
            }
        }
        return 
1;
    }
    return 
1;
}
stock DropItem(Model,AmountFloat:XFloat:YFloat:Zworldinterior)
{
    if(
Model != 0)
    {
        for(new 
0sizeof(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,Z5.0,world0);
                
DropObject[i] = CreateObject(ModelXYZ-1,0.00.00.0world);
                return 
1;
            }
        }
        return 
1;
    }
    return 
1;
}
//=================// 
or link :http://pastebin.com/F3YmW3xn
Ok.. part two
You need Define Max item drop
PHP код:
#define MAX_DROP_ITEMS 100//or orther number 
after use map editor get pos to create item
EX:
PHP код:
CreateObject(1582200.681841910.6341616.71287,   0.000000.000000.00000);//1582 is Model pizza box 
then use features createitem
PHP код:
CreateItem(Model,Amount,Float:XFloat:YFloat:Z,Float:RX,Float:RY,Float:RZworldinterior
PHP код:
CreateItem(1582,1,200.681841910.6341616.71287,   0.000000.000000.0000000); 
and put it to OnGameModeInit()
Part three
public OnPlayerPickupItem(playerid)
PHP код:
public OnPlayerPickupItem(playerid)
{
    for(new 
0sizeof(ItemInfo); i++)
    {
        if (
IsPlayerInRangeOfPoint(playerid2.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(istringsizeof(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;

or you can make cmd drop item
i use include zcmd to make cmd and use dropitem
PHP код:
 DropItem(Model,AmountFloat:XFloat:YFloat:Zworldinterior
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;

Ok But item can create/drop random pos
PHP код:
new ItemRandom[2] = {
1582,1486}; 
then
PHP код:
CreateItem(ItemRandom[random(2)],1,200.681841910.6341616.71287,   0.000000.000000.0000000); 
Finish How to pickup item
use PRESSED key
PHP код:
#define PRESSED(%0) \
        
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) 
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
        if (
PRESSED(KEY_WALK)) // key ALT
        
{
        
OnPlayerPickupItem(playerid);
        }
        return 
1;

Ok Complete
Reply
#2

Lack of explanation!
Reply
#3

))))))))))) +repped
Reply
#4

You need to explain in more details.Either edit it or delete and go learn it.
Reply
#5

Thank you for your contribution and I will edit it to learn more
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)