23.09.2017, 02:53
(
Последний раз редактировалось Naine; 29.09.2017 в 23:50.
)
PHP код:
// #memberList.pwn script
#if !defined isnull
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
#define FACTION_LIMIT 10 // #total maximo de organizaзхes;
#define MEMBERS_LIMIT 10 // #total maximo de membros em uma unica organizaзгo;
// ---
#define MEMBER_LEADER_LEVEL 6 // #nivel do lider;
#define MEMBER_SUBLEADER_LEVEL 5 // #nivel do sublider;
// ---
#define INVALID_FACTION_ID (FACTION_LIMIT + 1) // #id invalido para retorno;
#define INVALID_MEMBER_LIST_ID (MEMBERS_LIMIT + 1) // #id invalido para retorno;
enum E_MEMBER_LIST_DATA
{
MemberList_PlayerName[MAX_PLAYER_NAME],
MemberList_PlayerLevel,
}
new MemberList[FACTION_LIMIT][MEMBERS_LIMIT][E_MEMBER_LIST_DATA];
stock MemberList_Add(factionId, playerName[MAX_PLAYER_NAME], playerLevel) {
new str_tmp[MAX_PLAYER_NAME];
if(factionId => FACTION_LIMIT)
return false;
for(new i = 0; i < MEMBERS_LIMIT; i++)
{
getMemberListPlayerName(factionId, i, str_tmp);
if(isnull(str_tmp))
{
setMemberListPlayerName(factionId, i, playerName[MAX_PLAYER_NAME]);
setMemberListPlayerLevel(factionId, i, playerLevel);
return true;
}
}
return false;
}
stock MemberList_Remove(playerName[MAX_PLAYER_NAME])
{
new factionId = getPlayerFactionByName(playerName);
new memberListId = getPlayerMemberListByName(playerName);
if(factionId == FACTION_LIMIT)
return false;
if(memberListId == MEMBERS_LIMIT)
return false;
setMemberListPlayerName(factionId, memberListId, "");
setMemberListPlayerLevel(factionId, memberListId, 0);
return true;
}
// ** is
stock MemberList_IsLeader(playerName[MAX_PLAYER_NAME])
{
new factionId = getPlayerFactionByName(playerName);
new memberListId = getPlayerMemberListByName(playerName);
if(factionId == FACTION_LIMIT)
return false;
if(memberListId == MEMBERS_LIMIT)
return false;
if(getMemberListPlayerLevel(factionId, memberListId) == MEMBER_LEADER_LEVEL)
return true;
return false;
}
stock MemberList_IsSubLeader(playerName[MAX_PLAYER_NAME])
{
new factionId = getPlayerFactionByName(playerName);
new memberListId = getPlayerMemberListByName(playerName);
if(factionId == FACTION_LIMIT)
return false;
if(memberListId == MEMBERS_LIMIT)
return false;
if(getMemberListPlayerLevel(factionId, memberListId) == MEMBER_SUBLEADER_LEVEL)
return true;
return false;
}
// ** get
stock MemberList_GetName(factionId, memberListId, playerName[MAX_PLAYER_NAME])
{
if(factionId => FACTION_LIMIT)
return false;
if(memberListId => MEMBERS_LIMIT)
return false;
format(playerName, MAX_PLAYER_NAME, "%s", MemberList[factionId][memberListId][MemberList_PlayerName]);
return true;
}
stock MemberList_GetLevel(factionId, memberListId)
{
if(factionId => FACTION_LIMIT)
return false;
if(memberListId => MEMBERS_LIMIT)
return false;
return MemberList[factionId][memberListId][MemberList_PlayerLevel];
}
stock MemberList_GetFactionByName(playerName[MAX_PLAYER_NAME])
{
new str_tmp[MAX_PLAYER_NAME];
for(new factionId = 0; factionId < FACTION_LIMIT; factionId++)
{
for(new memberListId = 0; memberListId < MEMBERS_LIMIT; memberListId++)
{
getMemberListPlayerName(factionId, memberListId, str_tmp);
if(isnull(str_tmp))
return INVALID_FACTION_ID;
if(!strcmp(playerName, str_tmp, false)) {
return factionId;
}
}
}
return INVALID_FACTION_ID;
}
stock MemberList_GetIdByName(playerName[MAX_PLAYER_NAME])
{
new factionId = getPlayerFactionByName(playerName);
if(factionId == INVALID_FACTION_ID)
return INVALID_MEMBER_LIST_ID;
for(new memberListId = 0; memberListId < MEMBERS_LIMIT; memberListId++)
{
getMemberListPlayerName(factionId, memberListId, str_tmp);
if(isnull(str_tmp))
return INVALID_FACTION_ID;
if(!strcmp(playerName, str_tmp, false)) {
return memberListId;
}
}
return INVALID_MEMBER_LIST_ID;
}
// ** set
stock MemberList_SetName(factionId, memberListId, playerName[MAX_PLAYER_NAME])
{
if(factionId => FACTION_LIMIT)
return false;
if(memberListId => MEMBERS_LIMIT)
return false;
format(MemberList[factionId][memberListId][MemberList_PlayerName], MAX_PLAYER_NAME, "%s", playerName);
return true;
}
stock MemberList_SetLevel(factionId, memberListId, playerLevel)
{
if(factionId => FACTION_LIMIT)
return false;
if(memberListId => MEMBERS_LIMIT)
return false;
MemberList[factionId][memberListId][MemberList_PlayerLevel] = playerLevel;
return true;
}
PHP код:
/*
MemberList_Add(faction_id, string player_name, player_level)
MemberList_Remove(string player_name)
MemberList_IsLeader(string player_name)
MemberList_IsLeader(string player_name)
MemberList_IsSubLeader(string player_name)
MemberList_GetName(faction_id, member_list_id, string player_name)
MemberList_GetLevel(faction_id, member_list_id)
MemberList_GetFactionByName(string player_name)
MemberList_GetIdByName(string player_name)
MemberList_SetName(faction_id, member_list_id, string player_name)
MemberList_SetLevel(faction_id, member_list_id, player_level)
*/
PHP код:
hook OnGameModeInit() {
// for (loop em todos os jogadores armazenados)
// if (verificar se o jogador esta em uma organizacao)
// se o jogador estiver em uma organizacoes (inserir no sistema)
MemberList_Add(organizacao, nome_jogador, cargo_jogador);
return true;
}
nгo existe necessidade de armazenar os dados dos membros em um arquivo separado. pois todos esses dados ja estao armazenados na conta do jogador.
para sincronizar a lista de membros com os comandos /demitir /convidar /expulsar, basta fazer uso das funзхes acima.
---
seu cуdigo esta longe de um release para ser implementado em "qualquer" gamemode. mas a logica que vocк aplicou em si, pode sim ser usada para aplicar em qualquer gamemode. vocк disse que isso й o melhor que vocк pode fazer, eu acredito que isso esta longe das suas reais habilidades. vocк possui mais de 6 anos neste fуrum, tem certeza que isso й o melhor? nгo estou tretando.. apenas quero que vocк seja o melhor que possa ser.