Help with clan system.
#1

Hello, So I made this clan system but I can't get the members to load after the server restart.


PHP код:
OnPlayerConnect...
if(
PlayerInfo[playerid][pClanID] > 0)
    {
       
PlayerClan[playerid]= PlayerInfo[playerid][pClanID];
       for(new 
oMAX_CLANS++) {
       new 
ClanInfo[o][1];
       
ClanMembers[o][i] = PlayerInfo[playerid][pClanID]; }
    } 
here are more examples when a player joins a clan to help you under the code better.
PHP код:
CMD:createclan(playeridparams[])
{
    new 
string[64], clanname[64];
    if(
Spawned[playerid] == 0) return SendClientMessage(playeridCOLOR_ERROR"Error: You are not spawned.");
    if(
sscanf(params"s"clanname)) return SendClientMessage(playeridCOLOR_GRAY"Usage: /createclan [name]");
    if(
GetPlayerScore(playerid) < 500) return SendClientMessage(playeridCOLOR_ERROR"Error: You must have 500 score in order to make a clan");
    if(
GetPlayerCash(playerid) < 500000) return SendClientMessage(playeridCOLOR_ERROR"Error: You must have atleast $500,000 in order to make a clan");
    if(
strlen(clanname) > 64 || strlen(clanname) < 1) return SendClientMessage(playeridCOLOR_ERROR"Error: Clan name must be less than 64 characters and more than 1 character.");
    if(
PlayerClan[playerid] > 0) return SendClientMessage(playeridCOLOR_ERROR"Error: You are already in a clan!");
    for(new 
1MAX_CLANSi++) {
    if(
ClanInfo[i][0]==0)
    {
       
format(ClanNames[i], MAX_CLAN_NAME"%s"clanname);
       
ClanInfo[i][0]=1;
       
ClanInfo[i][1]=1;
       
ClanMembers[i][0] = playerid;
       
format(stringsizeof(string),"You've created clan '%s' (ID: %d)"ClanNames[i], i);
       
SendClientMessage(playerid, -1string);
       
format(stringsizeof(string), " %s (%d) created clan %s (Clan ID: %d)"GetName(playerid), playeridClanNames[i], i);
        
SendDC(CLANSstring);
       
PlayerClan[playerid]=i;
       
PlayerInfo[playerid][pClan] = clanname;
       
PlayerInfo[playerid][pClanID] = i;
       
PlayerInfo[playerid][pLeader] = 1;
       new 
INI:File INI_Open(CrewPath(i));
       
INI_SetTag(File"Clan Data");
       
INI_WriteInt(File"cID"i);
       
INI_WriteString(File"cName"clanname);
       
INI_WriteString(File"cLeader"GetName(playerid));
       
INI_Close(File);
       break; }
    }
    
SetPlayerCash(playeridGetPlayerCash(playerid) - 500000);
    
SaveCrews();
    
SaveAccountStats(playerid);
    return 
1;

and one more when a player accepts the invite.
PHP код:
CMD:acceptinvite(playeridparams[])
{
    new 
clannumstring[64];
    
clannum ClanInvite[playerid];
    if(
PlayerClan[playerid] > 0) return SendClientMessage(playeridCOLOR_ERROR"Error: You are already in a clan.");
    if(
ClanInvite[playerid] == 0) return SendClientMessage(playeridCOLOR_ERROR"Error: You are not invited in a clan.");
    if(
ClanInfo[clannum][0] == 0) return SendClientMessage(playeridCOLOR_ERROR"Error: Clan doesn't exist.");
    if(
ClanInfo[clannum][1] < MAX_CLAN_MEMBERS) {
    new 
ClanInfo[clannum][1];
    
ClanInvite[playerid] = 0;
    
ClanMembers[clannum][i] = playerid;
    for(new 
0ClanInfo[clannum][1]; j++) {
    
format(stringsizeof(string),"%s joined the clan!"GetName(playerid));
    
SendClientMessage(ClanMembers[clannum][j], COLOR_ORANGEstring); }
     
format(stringsizeof(string), " %s (%d) has joined clan %s (Clan ID: %d)"GetName(playerid), playeridClanNames[clannum], clannum);
     
SendDC(CLANSstring);
    
ClanInfo[clannum][1]++;
    
PlayerClan[playerid] = clannum;
    
PlayerInfo[playerid][pClanID] = clannum;
    
PlayerInfo[playerid][pClan] = ClanNames[clannum];
    
format(stringsizeof(string),"You joined the clan '%s'(id: %d)"ClanNames[clannum], clannum);
    
SendClientMessage(playeridCOLOR_YELLOWstring); }
    
SaveAccountStats(playerid);
    return 
1;

I've tried everything I knew but I can't get the members to load.
Reply
#2

Can you show your load code under OnPlayerConnect? Are the files saving properly?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)