Hi...
Lets start!
Here is my code:
PHP Code:
new Array:g_itemsdata[4]
new Array:g_itemid
new g_item_count
public plugin_precache()
{
new a
for( a = 0; a < 4; a++ )g_itemsdata[a] = ArrayCreate( 1,1 )
g_itemid = create_array( 1,1 )
g_item_count = 0
}
stock g_add_item( itemdata[4] )
{
new a
for( a = 0; a < 4; a++ ) ArrayPushCell( g_itemsdata[a], itemdata[a])
ArrayPushCell( g_itemid, g_item_count)
g_item_count++
return g_item_count - 1
}
stock g_remove_item( itemid )
{
new a, b
for( a = 0; a < ArraySize(g_itemid); a++ )
{
if( itemid == ArrayGetCell( g_itemid, a ) )
{
for( b = 0; b < 4; b++ )ArrayDeleteItem(g_itemsdata[b], a)
ArrayDeleteItem(g_itemsdata[b], a)
ArrayDeleteItem(g_itemid, a)
break
}
}
}
This is how i usually do this.
This code is for example registering weapons, items, forwards, entities and everythings else.
Problem is, i feel that, there must be better method for doing this...
You see g_item_count get every times bigger and bigger if i for example add item...
If i remove item i can just do this: g_item_count--
and if i do, item index-s inside of g_itemid can have same values what also mean if i remove item again with that index then wrong item will be removed : /
( because of my gameplay, one map can last 1 - 3 hours, so that g_item_count can get very huge value and i think thats bad for cpu. )
Also can i somehow make this without loop ( loop in g_remove_item for searching right index... )
Thanks!