Specific item(array) removal - 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: Specific item(array) removal (
/showthread.php?tid=634803)
Specific item(array) removal -
bencesz - 26.05.2017
Hey Guys.
I've restarted pawno scripting just a couple of months ago after some years of brake. I'm using an inventory system by Ivan_Ino's ArrayList method (
https://sampforum.blast.hk/showthread.php?tid=608635).
How can I get and remove one specific item from the inventory? I'm thinking about making a stock with this function, I just can't find the proper way to do it.
The thing would be that if someone's in a mission, has the proper item in his inventory, in a proper distance from the NPC (actor), and presses the proper key, he would give the item to the NPC (just lose it from the inventory). I know how to solve these things, my only problem is the specific item removal
I've figured it out that I will need to make the player "in a mission", so i've created
Код:
new inmission[MAX_PLAYERS];
To make sure about the proper item removal at the proper case, i've also created
Код:
new inmission_lunchbreak[MAX_PLAYERS];
Letting known that the player has the specific item I've created
Код:
new hassandwich[MAX_PLAYERS]; // and a couple of more for ex.: haschips, hasmap etc.
It would look like this:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys && KEY_SECONDARY_ATTACK) //pressing either "F" or "ENTER"
{
if(IsPlayerInRangeOfPoint(playerid, "distance", "x", "y", "z"))
{
if(inmission[playerid] == 1)
{
if(inmission_lunchbreak[playerid] == 1)
{
//couple of things happening
RemoveSpecificItemFromInventory(playerid, ?) // <-- not "slot" like the original removal function, but either item_name or idk ?
}
}
}
}
return 1;
}
Can you help me with this one?
EDIT:
RemoveSpecificItemFromInventory(playerid, ?) //<--- the '?' should refer to the item id or what?
Код:
new ItemArray[][]=
{
{1, "Sandwich"}
// couple more like {id, "name"}
};