Item system help
#6

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Rule of thumb when designing dynamic systems.

- The return value for the creation function should be the INDEX in which the item was created.
- All slots full? return -1

Furthermore......

Код:
if(Item[i][ItemPosX] == 0 && Item[i][ItemPosY] == 0 && Item[i][ItemPosZ] == 0)
That is very silly to do and another rule of thumb never ever use == when checking floats!
What you should do is this.

Define your item types
Код:
#define ITEM_TYPE_NONE 0
#define ITEM_TYPE_DEAGLE 1
#define ITEM_TYPE_SPAS 2
No need for silly checks now it's nice and simple.
Код:
if(Item[i][ItemType] == ITEM_TYPE_NONE)
Other things don't create multiple functions that does the same thing as another function!
Код:
stock DropItem(model, amount, type, Float:X, Float:Y, Float:Z, world, interior)
Just call the create function when needed instead from this function.

This belongs in the enum not it's own variable!
Код:
DropObject[i] = CreateObject(model, X, Y, Z, RX, RY, RZ, world);
You should also return the index the object was created on after this line.
Код:
return i;
Could you explain this with a little more detail? I understand some of it, but stuff like the 'return i;' doesn't make sense to me.
Reply


Messages In This Thread
Item system help - by DTV - 20.04.2015, 16:08
Re: Item system help - by EiresJason - 20.04.2015, 16:10
Re: Item system help - by Fel486 - 20.04.2015, 16:12
Re: Item system help - by DTV - 20.04.2015, 16:16
Re: Item system help - by Pottus - 20.04.2015, 16:29
Re: Item system help - by DTV - 20.04.2015, 23:29

Forum Jump:


Users browsing this thread: 2 Guest(s)