MySQL Faction
#1

Hi. I've added to my faction a mysql saving system

What should I add more? I need to save at leaving on the server those faction stats. And none of my mysql "Faction MYsql" datas are not defined or anything else, only my "User" table is.

PHP код:
#define MAX_FACTIONS 999 


PHP код:
enum factionstats
{
    
factionOwner[24],
    
factionMembers,
    
factionName[16],
    
factionID

PHP код:
new factions[MAX_FACTIONS][factionstats]; 

PHP код:
enum playerinfo
{
        
Leader
        IsPlayerInfaction
,
    
IsPlayerfactionOwner,
    
IsPlayerInfactionID,
    
IsPlayerInvited,
    
IsPlayerInvitedfactionID 
PHP код:
CMD:makefaction(playerid,params[])
{
 new 
factionnamecmd[16];
 if(
sscanf(params"s[16]"factionnamecmd)) return SendClientMessage(playerid,-1,"*"COL_RED" /makefaction [Nume Factiune] [16 Characters]");
    if(
gettime() - 480 pInfo[playerid][pfactionSpam]) return SendClientMessage(playerid,-1,"*"COL_RED" Asteapta 8 minute pana a deschide iar o factiune!");
    {
  if(
pInfo[playerid][Leader] == 1)
        {
            if(
pInfo[playerid][IsPlayerInfaction] == 0)
            {
       if(
strlen(params) > 16)
                {
                    
SendClientMessage(playerid,-1,"*"COL_RED" Numele factiunii este prea lung (Caractere maxime: 16)");
                }
                else
                {
                    
DayZSA_Createfaction(playerid,factionnamecmd,PlayerName(playerid));
                    
pInfo[playerid][pfactionSpam] = gettime();
                }
            }
            else return 
SendClientMessage(playerid,-1,"*"COL_RED" Esti deja intr-o factiune / esti liderul uneia!");
        }
        else return 
SendClientMessage(playerid,-1,"*"COL_RED" Ai nevoie de aprobarea unui HoF!");
    }
                    
format(querysizeof(query), "INSERT INTO `Factions` (FactionID, FactionName, LeaderName) VALUES(%d,'%s','%s)",
                    
factionstats[factionID][factionName][playerid]
                    
mysql_query(query);
    return 
1;




PHP код:
CMD:acceptfaction(playerid)
{
    if(
pInfo[playerid][IsPlayerInvited] == 1)
    {
        new 
str[230];
        
pInfo[playerid][IsPlayerInvited] = 0;
        
pInfo[playerid][IsPlayerInfaction] = 1;
        
pInfo[playerid][IsPlayerInfactionID] = pInfo[playerid][IsPlayerInvitedfactionID];
        
pInfo[playerid][IsPlayerInvitedfactionID] = 0;
        
factions[pInfo[playerid][IsPlayerInfactionID]][factionMembers]++;
        
format(str,sizeof(str),"*"COL_YELLOW" Jucatorul %s(%i) s-a alaturat factiunii %s(%i)",PlayerName(playerid), playeridfactions[pInfo[playerid][IsPlayerInfactionID]][factionName], pInfo[playerid][IsPlayerInfactionID]);
        
SendMessageToAllfactions(factions[pInfo[playerid][IsPlayerInfactionID]][factionID], str, -1);
    }
    
         
format(querysizeof(query), "INSERT INTO `users` (FactionID) VALUES(%d)",
           
factionstats[factionID]
         
mysql_query(query);
                    
    else return 
SendClientMessage(playerid,-1,"*"COL_RED" Nu ai nici o invitatie activa!");
    return 
1;




PHP код:
CMD:kickfaction(playerid,params[])
{
    new 
targetid;
    if(
sscanf(params"u"targetid)) return SendClientMessage(playerid,-1,"*"COL_RED" /kickfaction [playerid]");
    if(
pInfo[playerid][IsPlayerInfaction] == 1)
    {
        if(
pInfo[playerid][IsPlayerfactionOwner] == 1)
        {
            if(
pInfo[targetid][IsPlayerInfactionID] == pInfo[playerid][IsPlayerInfactionID])
            {
                new 
str[180],str2[128];
                
format(str,sizeof(str),"*"COL_RED" Ai primit kick de la factiunea %s(%i)",GetPlayerfactionName(targetid),pInfo[targetid][IsPlayerInfactionID]);
                
SendClientMessage(targetid,-1,str);
                
format(str2,sizeof(str2),"*"COL_RED" Ai dat kick lui %s(%i) din factiunea ta!",PlayerName(targetid),targetid);
                
SendClientMessage(playerid,-1,str2);
                
factions[pInfo[targetid][IsPlayerInfactionID]][factionMembers]--;
                
pInfo[targetid][IsPlayerInfaction] = 0;
                
pInfo[targetid][IsPlayerInfactionID] = 0;
            }
            else return 
SendClientMessage(playerid,-1,"*"COL_RED" Jucatorul nu este in factiunea ta!");
        }
        else return 
SendClientMessage(playerid,-1,"*"COL_RED" Trebuie sa fii leader!");
    }
    else return 
SendClientMessage(playerid,-1,"*"COL_RED" Trebuie sa fii intr-o factiune ca sa folosesti aceasta comanda!");
    
                
format(querysizeof(query), "REMOVE FROM `users` (FactionID) VALUES(%d)",
                  
factionstats[factionID]
                
mysql_query(query);
    return 
1;



PHP код:
CMD:leavefaction(playerid)
{
    if(
pInfo[playerid][IsPlayerInfaction] == 1)
    {
        new 
str[180];
        
format(str,sizeof(str),"*"COL_YELLOW" %s(%i) a parasit factiunea!",PlayerName(playerid),playerid);
        
SendMessageToAllfactions(factions[pInfo[playerid][IsPlayerInfactionID]][factionID], str, -1);
        
factions[pInfo[playerid][IsPlayerInfactionID]][factionMembers]--;
        
pInfo[playerid][IsPlayerInfaction] = 0;
        
pInfo[playerid][IsPlayerInfactionID] = 0;
    }
    
        
format(querysizeof(query), "REMOVE FROM `users` (FactionID) VALUES(%d)"
        
factionstats[factionID]
        
mysql_query(query);
    
    else return 
SendClientMessage(playerid,-1,"*"COL_RED" Trebuie sa fii intr-o factiune ca sa folosesti comanda!");
    return 
1;



PHP код:
CMD:destroyfaction(playerid,params[])
{
    new 
reason[105];
    if(
sscanf(params"s[105]"reason)) return SendClientMessage(playerid,-1,"*"COL_RED" /destroyfaction [motiv]");
    if(
pInfo[playerid][IsPlayerInfaction] == 1)
    {
        if(
pInfo[playerid][IsPlayerfactionOwner] == 1)
        {
            new 
str[24],gname[16],msg[280];
            
format(str,sizeof(str),"Destroyed");
            
format(gname,sizeof(gname),"Destroyed");
            
format(msg,sizeof(msg),"*"COL_YELLOW" %s(%i) a distrus factiunea %s [Motiv: %s]",PlayerName(playerid),playeridGetPlayerfactionName(playerid), reason);
            
SendClientMessageToAll(-1,msg);
            
factions[pInfo[playerid][IsPlayerInfactionID]][factionOwner] = str;
            
factions[pInfo[playerid][IsPlayerInfactionID]][factionName] = gname;
            
factions[pInfo[playerid][IsPlayerInfactionID]][factionMembers] = 0;
            foreach(
Player,i)
            {
                if(
pInfo[i][IsPlayerInfactionID] == pInfo[playerid][IsPlayerInfactionID])
                {
                    
pInfo[i][IsPlayerInfaction] = 0;
                    
pInfo[i][IsPlayerInfactionID] = 0;
                }
            }
            
pInfo[playerid][IsPlayerInfaction] = 0;
            
pInfo[playerid][IsPlayerfactionOwner] = 0;
            
pInfo[playerid][IsPlayerInfactionID] = 0;
        }
        else return 
SendClientMessage(playerid,-1,"*"COL_RED" Acel jucator nu este in factiunea ta!");
    }
    else return 
SendClientMessage(playerid,-1,"*"COL_RED" Trebuie sa fii leader-ul factiunii!");
            
format(querysizeof(query), "REMOVE FROM `Factions` (FactionID, FactionName, LeaderName) VALUES(%d,'%s','%s)",
            
factionstats[factionID][factionName][playerid]
            
mysql_query(query);
    return 
1;




PHP код:
stock DisconnectVars(playerid)
{
     
SaveInventory(playerid);
       if(
IsPlayerAttachedObjectSlotUsed(playerid1)) RemovePlayerAttachedObject(playerid0);
    if(
pInfo[playerid][IsPlayerfactionOwner] == 1)
    {
        new 
str[24],gname[16];
        
format(str,sizeof(str),"Destroyed");
        
format(gname,sizeof(gname),"Destroyed");
        
factions[pInfo[playerid][IsPlayerInfactionID]][factionID] = 0;
        
factions[pInfo[playerid][IsPlayerInfactionID]][factionOwner] = str;
        
factions[pInfo[playerid][IsPlayerInfactionID]][factionName] = gname;
        
factions[pInfo[playerid][IsPlayerInfactionID]][factionMembers] = 0;
        foreach(
Player,i)
        {
            if(
pInfo[i][IsPlayerInfactionID] == pInfo[playerid][IsPlayerInfactionID])
            {
                
pInfo[i][IsPlayerInfaction] = 0;
                
pInfo[i][IsPlayerInfactionID] = 0;
            }
        }
        
pInfo[playerid][IsPlayerInfaction] = 0;
        
pInfo[playerid][IsPlayerfactionOwner] = 0;
        
pInfo[playerid][IsPlayerInfactionID] = 0;
    }
    return 
1;



PHP код:
function DayZSA_Createfaction(playerid,factionname[],owner[])
{
    new 
str[24],gname[16];
    
factionCount += 1;
    
format(str,sizeof(str),"%s",owner);
    
format(gname,sizeof(gname),"%s",factionname);
    
factions[factionCount][factionID] = factionCount;
    
factions[factionCount][factionOwner] = str;
    
factions[factionCount][factionName] = gname;
    
factions[factionCount][factionMembers]++;
    
pInfo[playerid][IsPlayerInfaction] = 1;
    
pInfo[playerid][IsPlayerfactionOwner] = 1;
    
pInfo[playerid][IsPlayerInfactionID] = factionCount;
    new 
stra[256];
    
format(stra,sizeof(stra),"*"COL_LGREEN" Jucatorul %s(%i) a creat o factiune numita %s(%i)",PlayerName(playerid),playeridfactionnamefactionCount);
    
SendClientMessageToAll(-1,stra);
    return 
1;
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)