10.03.2014, 01:39
Hey there. I have two questions and if I get the answer I'm looking for then this will help me alot. I allways had problems with the codes like
Not really scripting problems cuz I use them sometimes when it comes to MAX_PLAYERS but I can say that I use them "blindly" like I don't really know how to use them more "profesionally" to let my imagination "float around".
Anyway, skipping the bullcrap Here's my question...
I made this saving and removing system and my inventory got like 20 slots... so far I have to call the Remove or Add function 20 times to fill the inv with the items the player had before he logged out or to remove all the inventory items.
First question!
It's a easy one...
When the player dies it's called this
Anyway, only ONE item it's deleted and not just all of them.
RemoveItemFromInventory works like
and INV_MAX_SLOTS it's defined 20
That being that here comes my
Second question!
I'd like to do the same thing with the saving system but it works with Y_INI
so far I only had 4 slots so I made 4 enums like Slot1, Slot2, Slot3, Slot4 and used 4 WriteInt to save them. Anyway I don't want to make 20 WriteInt to save all the items ... so how can I make this shorter?
I'll show ya parts of the code.
Saving the items
Loading the data (This part beated me ...)
And OnPlayerSpawn adding them back to the player inventory
If you got more question or need more parts of the code please tell me. Thank you
pawn Код:
for (new d = 0; d < INV_MAX_SLOTS; d++)
{
//blahblahblah
}
Anyway, skipping the bullcrap Here's my question...
I made this saving and removing system and my inventory got like 20 slots... so far I have to call the Remove or Add function 20 times to fill the inv with the items the player had before he logged out or to remove all the inventory items.
First question!
It's a easy one...
When the player dies it's called this
pawn Код:
for (new d = 0; d < INV_MAX_SLOTS; d++)
{
RemoveItemFromInventory(playerid, d);
}
RemoveItemFromInventory works like
pawn Код:
RemoveItemFromInventory(playerid, slot);
That being that here comes my
Second question!
I'd like to do the same thing with the saving system but it works with Y_INI
so far I only had 4 slots so I made 4 enums like Slot1, Slot2, Slot3, Slot4 and used 4 WriteInt to save them. Anyway I don't want to make 20 WriteInt to save all the items ... so how can I make this shorter?
I'll show ya parts of the code.
pawn Код:
enum yInfo
{
Slot0,
Slot1,
Slot2,
Slot3
}
new InvInfo[MAX_PLAYERS][yInfo];
pawn Код:
INI_WriteInt(File, "Slot0", GetItemType(GetInventorySlotItem(playerid, 0)));
INI_WriteInt(File, "Slot1", GetItemType(GetInventorySlotItem(playerid, 1)));
INI_WriteInt(File, "Slot2", GetItemType(GetInventorySlotItem(playerid, 2)));
INI_WriteInt(File, "Slot3", GetItemType(GetInventorySlotItem(playerid, 3)));
pawn Код:
GetInventorySlotItem(playerid, slot); //returns the id of an item
GetItemType(itemid); //Well ... it gets the type of an item...
pawn Код:
INI_Int("Slot0",InvInfo[playerid][Slot0]);
INI_Int("Slot1",InvInfo[playerid][Slot1]);
INI_Int("Slot2",InvInfo[playerid][Slot2]);
INI_Int("Slot3",InvInfo[playerid][Slot3]);
pawn Код:
AddItemToInventory(playerid, CreateItem(InvInfo[playerid][Slot0]), 1);
AddItemToInventory(playerid, CreateItem(InvInfo[playerid][Slot1]), 1);
AddItemToInventory(playerid, CreateItem(InvInfo[playerid][Slot2]), 1);
AddItemToInventory(playerid, CreateItem(InvInfo[playerid][Slot3]), 1);
If you got more question or need more parts of the code please tell me. Thank you