Doesn't load object[MySQL]
#7

You can do two things:
  • Keep count on how many objects the player already has:
    PHP код:
    enum E_PLAYER_DATA {

        
    tagCount
    };
    new 
    PlayerInfo[MAX_PLAYERS][E_PLAYER_DATA];

    enum E_TAG_DATA {

        
    // enumerators
    };
    new 
    TagInfo[MAX_PLAYERS][MAX_TAGS_PER_PLAYER][E_TAG_DATA];

    CMD:create(playeridparams[]) 

        if(
    PlayerInfo[playerid][tagCount] >= MAX_TAGS_PER_PLAYER)
            return 
    SendClientMessage(playerid, -1"You have reached the maximum amount of tags per player.");
        
        new 
    tagIndex = ((PlayerInfo[playerid][tagCount] == 0) ? (PlayerInfo[playerid][tagCount]) : (PlayerInfo[playerid][tagCount] - 1));
        
    TagInfo[playerid][tagIndex][TagObject] = CreateDynamicObject(19482XYZ0.00.00.0, -1, -1, -1300.0300.0);
        return 
    1

  • Or via more sophisticated loops:
    PHP код:
    enum E_TAG_INFO {

        
    bool:tagExists
    };
    new 
    TagInfo[MAX_PLAYERS][MAX_TAGS_PER_PLAYER][E_TAG_INFO];

    function 
    SprayTag_GetFreeID(playerid) {

        for(new 
    0MAX_TAGS_PER_PLAYERi++) if(!TagInfo[playerid][i][tagExists]) {

            return 
    i// Return the free index
        
    }
        return -
    1// All tags are in use (= player has reached MAX_TAGS_PER_PLAYER tags).
    }

    CMD:create(playeridparams[]) 

        new 
    tagIndex SprayTag_GetFreeID(playerid);

        if(
    tagIndex == -1) {

            return 
    SendClientMessage(playerid, -1"You have reached the maximum amount of tags per player.");
        }

        
    TagInfo[playerid][tagIndex][TagObject] = CreateDynamicObject(19482XYZ0.00.00.0, -1, -1, -1300.0300.0);
        return 
    1

These are just short and incomplete examples on how you could tackle the problem.
Reply


Messages In This Thread
Doesn't load object[MySQL] - by vassilis - 27.10.2016, 11:54
Re: Doesn't load object[MySQL] - by AndySedeyn - 27.10.2016, 11:58
Re: Doesn't load object[MySQL] - by Konstantinos - 27.10.2016, 12:00
Re: Doesn't load object[MySQL] - by vassilis - 27.10.2016, 12:01
Re: Doesn't load object[MySQL] - by AndySedeyn - 27.10.2016, 12:04
Re: Doesn't load object[MySQL] - by vassilis - 27.10.2016, 12:07
Re: Doesn't load object[MySQL] - by AndySedeyn - 27.10.2016, 12:28
Re: Doesn't load object[MySQL] - by vassilis - 27.10.2016, 12:41
Re: Doesn't load object[MySQL] - by AndySedeyn - 27.10.2016, 12:56
Re: Doesn't load object[MySQL] - by vassilis - 27.10.2016, 12:59

Forum Jump:


Users browsing this thread: 3 Guest(s)