PDA

View Full Version : HALLLLPPPP


YouShootIDodge
15/05/2019, 12:27 PM
Here is the code:

stock PickupItem (playerid, itemid)
{
new message [250],

ammount, ammo,

slot, destroy,

s_id, s_type, s_ammount, s_ammo;


if (ItemInfo [itemid][item_ammo] == -1)
{
for (new i = 0; i < (PlayerInfo [playerid][slots_used]); i++)
{
if (sscanf (PlayerInventory [playerid][i][item], "iiii", s_type, s_id, s_ammount, s_ammo))
{
if (s_type == ItemInfo [itemid][item_type])
{
if (s_id == ItemInfo [itemid][item_static_id])
{
slot = i;
ammount = (s_ammount + ItemInfo [itemid][item_ammount]);
}
}

s_type = 0;
s_id = 0;
s_ammount = 0;
s_ammo = 0;
}

if (i == PlayerInfo [playerid][slots_used] && ammount == 0)
{

slot = PlayerInfo [playerid][slots_used];
ammount = ItemInfo[itemid][item_ammount];

PlayerInfo [playerid][slots_used]++;
}
}

ammo = -1;

DestroyObject (itemid);
}
else
{

slot = PlayerInfo [playerid][slots_used];

ammount = 1;
ammo = ItemInfo [itemid][item_ammo];

PlayerInfo [playerid][slots_used]++;

ItemInfo [itemid][item_ammount]--;

if (ItemInfo [itemid][item_ammount] == 0) { destroy = 1; }

}

new value_set;

if (value_set == 0)
{
value_set = 1;
format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], ammount, ammo);
}

printf ("%d", slot);
print (PlayerInventory [playerid][slot][item]);

switch (ItemInfo [itemid][item_type])
{
case 1: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, UsableItems [ItemInfo [itemid][item_static_id]][name]);
case 2: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, RigidItems [ItemInfo [itemid][item_static_id]][name]);
case 3: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, WeaponItems [ItemInfo [itemid][item_static_id]][name]);
}

SendClientMessage (playerid, COLOR_MAIN, message);

if (destroy == 1) { DestroyObject (itemid); }
return 1;
}

This line is responsible for formatting the string in the PlayerInventory[playerid][slot][item], but its setting the string for all the 'slots' from 0 - 7.

format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], ammount, ammo);

I even used an extra variable to make sure its not being executed more than once. Is it because I set the 'slot' = 'i' ?