08.03.2014, 23:52
Hi, I'm creating player groups script and I don't know how to do multiple groups for one player, I have this code:
Now I can use only one group per player, I asking how to edit this code that I can use 1, 2, 3 etc. groups per player like this:
And some make GetPlayerGroups, who gets maybe array of player groups or some, who can I use for codes like this:
Код:
#define SetPlayerGroup(%0,%1) SetPVarString(%0, "Group", %1) #define GetPlayerGroup(%0) GetPVarString(%0, "Group", group) return group; #define SendMessageToGroup(%0,%1,%2) for(new i=0; i<MAX_PLAYERS; i++) GetPVarString(i, "Group", group); if(!strcmp(%0, group)) SendClientMessage(i, %1, %2) #define SendFormmatedMessageToGroup(%0,%1,%2,%3) format(formattedMessage, sizeof(formattedMessage), %2, %3); for(new i=0; i<MAX_PLAYERS; i++) GetPVarString(i, "Group", group); if(!strcmp(%0, group)) SendClientMessage(i, %1, formattedMessage) #define CountOnlineGroupPlayers(%0) new count=0; for(new i=0; i<MAX_PLAYERS; i++) { GetPVarString(i, "Group", group); if(!strcmp(%0, group)) count++; } return count; #define IsPlayerInAnyGroup(%0) GetPVarString(%0, "Group", group); if(strlen(group) > 0) return true;
Код:
SetPlayerGroup(playerid, "Group One"); SetPlayerGroup(playerid, "Group Two"); SetPlayerGroup(playerid, "Group Three");
Код:
if(!strcmp(GetPlayerGroups(playerid), "Group One")) if(!strcmp(GetPlayerGroups(playerid), "Group One") || !strcmp(GetPlayerGroups(playerid), "Group Two")) if(!strcmp(GetPlayerGroups(playerid), "Group One") && !strcmp(GetPlayerGroups(playerid), "Group Three"))