Inventory Dropping
#1

Hello there,

Once again i am stuck on my Inventory system.
(Might be released soon as filterscript)

I have two questions regarding dropping and picking up an item.

I really have no idea, how i make the object pickupable.
Can anybody give me an example of this?
Maybe by creating some kind of invisible pickup and make it respond on the model ID?

Example of dropping an 9mm:
PHP код:
if(modelid == 346)
        {
        new 
str[128];
        
format(str,sizeof(str),"%s(%i) has dropped a 9mm from his inventory.",PlayerName(playerid),playerid);
        
SendNearbyMessage(playerid,30.0,str,ORANGE);
        
RemoveItem(playerid,modelid);
        
ShowInventoryDrop(playerid);
        new 
Float:XFloat:YFloat:Z;
        
GetPlayerPos(playeridXYZ);
        
CreateDynamicObject(modelidXYZ00178);
        } 
Can anybody give me an example of this?

Also i have a question about dropping the object.
When dropping the object it spawns in the middle of the air.
How do i make it actually lie on the ground?
Screenshots:



Thanks in advance!
Reply
#2

Hello!

Take CreatePickup with this model ids.
https://sampwiki.blast.hk/wiki/Pickup_IDs
Reply
#3

It works, Thank you

How can i make it ask if the players wants to pickup the item on entering the pickup, instead of giving the item?
Reply
#4

Do you want to know how you can check if the player pick up a pickup?
Sorry, I don't understood your question.
Reply
#5

Actually when you enter the pickup now, it picks up the gun.
I want to make the player press an key/make an command if he wants to pick it up.
The problem is that i don't know how to get modelid into OnPlayerKey.

Current code:
PHP код:
        if(modelid == 346)
        {
        new 
str[128];
        
format(str,sizeof(str),"%s(%i) has dropped a 9mm from their inventory.",PlayerName(playerid),playerid);
        
SendNearbyMessage(playerid,30.0,str,ORANGE);
        
RemoveItem(playerid,modelid);
        
ShowInventoryDrop(playerid);
        new 
Float:XFloat:YFloat:Z;
        
GetPlayerPos(playeridXYZ);
        
Dropped9mm=CreateDynamicPickup(346,19,X-2.1YZ,-1);
        }
if(
pickupid==Dropped9mm)
    {
        new 
str[128];
        
format(str,sizeof(str),"%s(%i) has picked up a 9mm from their surroundings.",PlayerName(playerid),playerid);
        
SendNearbyMessage(playerid,30.0,str,ORANGE);
        
AddItem(playerid,346);
    } 
How do i make this OnPlayerKey work? :
PHP код:
if(newkeys==KEY_CROUCH)
    {
        if(
modelid == 346)
        {
            new 
str[128];
            
format(str,sizeof(str),"%s(%i) has picked up a 9mm from their surroundings",PlayerName(playerid),playerid);
               
SendNearbyMessage(playerid,30.0,str,ORANGE);
            
AddItem(playerid,modelid);
        }

I need to know how to make modelid work in there.
If i get this to work, i can do it without a pickup, and do it with an object.
Reply
#6

Consider using the dynamic pickups because the streamer plugins stores all information in memory. You can use Streamer_GetIntData to query for the modelid.
PHP код:
new objectName[16];

switch(
Streamer_GetIntData(STREAMER_TYPE_PICKUPpickupidE_STREAMER_MODEL_ID))
{
    case 
346objectName "a 9mm";
    
// other cases
    
default: objectName "something";
}

format(str,sizeof(str),"%s(%i) has picked up %s from their surroundings",PlayerName(playerid),playeridobjectName); 
Reply
#7

I have done it different without pickups, but using objects.

But now i need to know how i define an item name for an modelid.
And then i need to know how i display it in a string.
How can i do this? does anyone have an example for me?

PHP код:
if(newkeys==KEY_CROUCH)
    {
        for(new 
0sizeof(ItemInfo); i++)
        {
            if (
IsPlayerInRangeOfPoint(playerid2.0,ItemInfo[i][ItemPosX],ItemInfo[i][ItemPosY],ItemInfo[i][ItemPosZ]))
            {
                if(
GetPlayerVirtualWorld(playerid) == ItemInfo[i][ItemVWorld] && GetPlayerInterior(playerid) == ItemInfo[i][ItemInterior])
                {
                    if(
ItemInfo[i][Toggled] == 0)
                    {
                        new 
modelid ItemInfo[i][ItemModelID];
                        
                        new 
str[128];
                        
format(str,sizeof(str),"%s(%i) has picked up a item from their surroundings.",PlayerName(playerid),playerid);
                        
SendNearbyMessage(playerid,30.0,str,ORANGE);
                        
AddItem(playerid,modelid);
                        
ItemInfo[i][Toggled] = 1;
                        
Delete3DTextLabel(Label2[i]);
                        
DestroyDynamicObject(Item[i]);
                        
NoCheat[playerid] = 1;
                        return 
1;
                    }
                }else return 
0;
            }
        }
    } 
Reply
#8

This is not how you build an inventory system modelid's should not dictate what an item is.
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение
This is not how you build an inventory system modelid's should not dictate what an item is.
Why not? It works after all...
And that is not what i asked.

I asked how i give the model ids a name and how to display these in a string.
Reply
#10

Take a look here at how you set up an inventory system.
http://forum.sa-mp.com/showpost.php?...07&postcount=3
Reply
#11

Well this works, so i won't change it.
Everybody scripts on their own way.

So anyone who can answer my question?
Reply
#12

Here you are.

Код:
stock GetItemName(itemid)
{
	new name[40];
	switch(ItemInfo[itemid][ItemModelID])
	{
		case 346: format(name, sizeof(name), "9mm");
		//other cases
	}
	
	return name;
}
Reply
#13

Thank you very much.
So i would just call the function like this right?
PHP код:
format(stringsizeof(string), "Has dropped a %s from their inventory.",GetItemName(modelid)); 
Edit:
PHP код:
format(str,sizeof(str),"%s(%i) has dropped a %s from their inventory.",PlayerName(playerid),playerid,GetItemName(modelid)); 
Doesn't display anything.
PHP код:
format(str,sizeof(str),"%s(%i) has dropped a %s from their inventory.",PlayerName(playerid),playerid,GetItemName(playerid)); 
This does show Industrial scraps instead of an 9mm.

PHP код:
case 346format(namesizeof(name), "9mm");
case 
849format(namesizeof(name), "Industrial Scraps"); 
How should i do it?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)