[Include] DS InfoOrg [Para qualquer GM]
#13

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(factionIdplayerName[MAX_PLAYER_NAME], playerLevel) { 
    new 
str_tmp[MAX_PLAYER_NAME]; 
    if(
factionId => FACTION_LIMIT
        return 
false
    for(new 
0MEMBERS_LIMITi++)  
    { 
        
getMemberListPlayerName(factionIdistr_tmp); 
        if(
isnull(str_tmp)) 
        { 
            
setMemberListPlayerName(factionIdiplayerName[MAX_PLAYER_NAME]); 
            
setMemberListPlayerLevel(factionIdiplayerLevel); 
            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(factionIdmemberListId""); 
    
setMemberListPlayerLevel(factionIdmemberListId0); 
    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(factionIdmemberListId) == 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(factionIdmemberListId) == MEMBER_SUBLEADER_LEVEL
        return 
true
    return 
false

// ** get 
stock MemberList_GetName(factionIdmemberListIdplayerName[MAX_PLAYER_NAME]) 

    if(
factionId => FACTION_LIMIT
        return 
false
    if(
memberListId => MEMBERS_LIMIT
        return 
false
    
format(playerNameMAX_PLAYER_NAME"%s"MemberList[factionId][memberListId][MemberList_PlayerName]); 
    return 
true

stock MemberList_GetLevel(factionIdmemberListId

    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 0factionId FACTION_LIMITfactionId++) 
    { 
        for(new 
memberListId 0memberListId MEMBERS_LIMITmemberListId++)  
        { 
            
getMemberListPlayerName(factionIdmemberListIdstr_tmp); 
            if(
isnull(str_tmp)) 
                return 
INVALID_FACTION_ID
            if(!
strcmp(playerNamestr_tmpfalse)) { 
                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 0memberListId MEMBERS_LIMITmemberListId++)  
    { 
        
getMemberListPlayerName(factionIdmemberListIdstr_tmp); 
        if(
isnull(str_tmp)) 
            return 
INVALID_FACTION_ID
        if(!
strcmp(playerNamestr_tmpfalse)) { 
            return 
memberListId
        } 
    } 
    return 
INVALID_MEMBER_LIST_ID

// ** set 
stock MemberList_SetName(factionIdmemberListIdplayerName[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(factionIdmemberListIdplayerLevel

    if(
factionId => FACTION_LIMIT
        return 
false
    if(
memberListId => MEMBERS_LIMIT
        return 
false
    
MemberList[factionId][memberListId][MemberList_PlayerLevel] = playerLevel
    return 
true

function list:
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)
*/ 
exemplo para inserir membros:
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(organizacaonome_jogadorcargo_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.
Reply


Messages In This Thread
DS InfoOrg [Para qualquer GM] - by Don_Speed - 15.09.2017, 12:10
Re: DS InfoOrg [Para qualquer GM] - by zCyan - 15.09.2017, 12:18
Re: DS InfoOrg [Para qualquer GM] - by Relaxed - 15.09.2017, 12:30
Re: DS InfoOrg [Para qualquer GM] - by Don_Speed - 15.09.2017, 14:30
Re: DS InfoOrg [Para qualquer GM] - by golzaum - 15.09.2017, 15:37
Re: DS InfoOrg [Para qualquer GM] - by C4rtm4n - 15.09.2017, 15:53
Re: DS InfoOrg [Para qualquer GM] - by IlanZ - 15.09.2017, 19:47
Re: DS InfoOrg [Para qualquer GM] - by C4rtm4n - 15.09.2017, 21:33
Re: DS InfoOrg [Para qualquer GM] - by Don_Speed - 15.09.2017, 23:51
Re: DS InfoOrg [Para qualquer GM] - by Jelly23 - 16.09.2017, 00:34
Re: DS InfoOrg [Para qualquer GM] - by JonathanFeitosa - 16.09.2017, 05:28
Re: DS InfoOrg [Para qualquer GM] - by Don_Speed - 17.09.2017, 12:30
Re: DS InfoOrg [Para qualquer GM] - by Naine - 23.09.2017, 02:53
Re: DS InfoOrg [Para qualquer GM] - by MediaCL - 13.10.2017, 02:42

Forum Jump:


Users browsing this thread: 2 Guest(s)