SA-MP Forums Archive
Inventory Dropping - 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: Inventory Dropping (/showthread.php?tid=631210)



Inventory Dropping - jasperschellekens - 25.03.2017

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!


Re: Inventory Dropping - Mencent - 25.03.2017

Hello!

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


Re: Inventory Dropping - jasperschellekens - 25.03.2017

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?


Re: Inventory Dropping - Mencent - 25.03.2017

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


Re: Inventory Dropping - jasperschellekens - 25.03.2017

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.


Re: Inventory Dropping - Vince - 25.03.2017

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); 



Re: Inventory Dropping - jasperschellekens - 25.03.2017

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;
            }
        }
    } 



Re: Inventory Dropping - Pottus - 25.03.2017

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


Re: Inventory Dropping - jasperschellekens - 25.03.2017

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.


Re: Inventory Dropping - Pottus - 25.03.2017

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


Re: Inventory Dropping - jasperschellekens - 25.03.2017

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

So anyone who can answer my question?


Re: Inventory Dropping - raydx - 26.03.2017

Here you are.

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



Re: Inventory Dropping - jasperschellekens - 26.03.2017

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?