їEncontrar la ranura vacнa?
#1

їCуmo se podrнa encontrar una ranura vacнa a esto?

PHP код:
#define MAX_TRUNK 11
#define MAX_TRUNK_SLOT 5
#define INVALID_TRUNK_OBJECT -1
#define ITEM_TRUNK_OBJECT 1
#define ITEM_TRUNK_DATOS 2
#define ITEM_TRUNK_DATOS1 3
enum myenumerator
{
objeto[MAX_TRUNK_SLOT],
datos[MAX_TRUNK_SLOT],
datos1[MAX_TRUNK_SLOT]
};
new 
TrunkInfo[MAX_TRUNK][myenumerator];
stock SetTrunkItem(trunkidSLOTitemmount)
{
...
switch(
item) {
case 
ITEM_TRUNK_OBJECTTrunkInfo[trunkid][objeto][SLOT] = mount;
case 
ITEM_TRUNK_DATOSTrunkInfo[trunkid][datos][SLOT] = mount;
case 
ITEM_TRUNK_DATOS1TrunkInfo[trunkid][datos1][SLOT] = mount;
}
return 
1;

Supongamos que tengo los 5 espacios ocupados, y desocupo uno usando
PHP код:
SetTrunkItem(14ITEM_TRUNK_OBJECTINVALID_TRUNK_OBJECT); 
Cуmo tendrнa que quedar una funciуn que retorne el nъmero cuatro, ya que estarнa vacнa al no tener un objeto.
Reply
#2

pawn Код:
new freeSlot = -1;
for (new i = 0; i < MAX_TRUNK; i++) {// Recorres todos los slots
    if (TrunkInfo[trunkid][dato][i] == INVALID_TRUNK_OBJECT) { // Si en el slot el item es 0 (osea, segun como lo tengas, nada)
        freeSlot = i;
        break;
    }
}
if (freeSlot == -1) // Si es -1 no encontro nignun slot vacio
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)