Quote:
Originally Posted by AndySedeyn
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(playerid, params[])
{
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(19482, X, Y, Z, 0.0, 0.0, 0.0, -1, -1, -1, 300.0, 300.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 i = 0; i < MAX_TAGS_PER_PLAYER; i++) 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(playerid, params[])
{
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(19482, X, Y, Z, 0.0, 0.0, 0.0, -1, -1, -1, 300.0, 300.0);
return 1;
}
These are just short and incomplete examples on how you could tackle the problem.
|
Thank you for taking into consideration my queries. I really had problems understanding how "houseids", "bizids" and other custom ids work. I think i understood a lot.
One last question? How could i use TagInfo[playerid][][tagExists] ?