21.05.2018, 20:58
Hello, So I made this clan system but I can't get the members to load after the server restart.
here are more examples when a player joins a clan to help you under the code better.
and one more when a player accepts the invite.
I've tried everything I knew but I can't get the members to load.
PHP код:
OnPlayerConnect...
if(PlayerInfo[playerid][pClanID] > 0)
{
PlayerClan[playerid]= PlayerInfo[playerid][pClanID];
for(new o; o < MAX_CLANS; o ++) {
new i = ClanInfo[o][1];
ClanMembers[o][i] = PlayerInfo[playerid][pClanID]; }
}
PHP код:
CMD:createclan(playerid, params[])
{
new string[64], clanname[64];
if(Spawned[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not spawned.");
if(sscanf(params, "s", clanname)) return SendClientMessage(playerid, COLOR_GRAY, "Usage: /createclan [name]");
if(GetPlayerScore(playerid) < 500) return SendClientMessage(playerid, COLOR_ERROR, "Error: You must have 500 score in order to make a clan");
if(GetPlayerCash(playerid) < 500000) return SendClientMessage(playerid, COLOR_ERROR, "Error: You must have atleast $500,000 in order to make a clan");
if(strlen(clanname) > 64 || strlen(clanname) < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: Clan name must be less than 64 characters and more than 1 character.");
if(PlayerClan[playerid] > 0) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are already in a clan!");
for(new i = 1; i < MAX_CLANS; i++) {
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(string, sizeof(string),"You've created clan '%s' (ID: %d)", ClanNames[i], i);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), " %s (%d) created clan %s (Clan ID: %d)", GetName(playerid), playerid, ClanNames[i], i);
SendDC(CLANS, string);
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(playerid, GetPlayerCash(playerid) - 500000);
SaveCrews();
SaveAccountStats(playerid);
return 1;
}
PHP код:
CMD:acceptinvite(playerid, params[])
{
new clannum, string[64];
clannum = ClanInvite[playerid];
if(PlayerClan[playerid] > 0) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are already in a clan.");
if(ClanInvite[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not invited in a clan.");
if(ClanInfo[clannum][0] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Error: Clan doesn't exist.");
if(ClanInfo[clannum][1] < MAX_CLAN_MEMBERS) {
new i = ClanInfo[clannum][1];
ClanInvite[playerid] = 0;
ClanMembers[clannum][i] = playerid;
for(new j = 0; j < ClanInfo[clannum][1]; j++) {
format(string, sizeof(string),"%s joined the clan!", GetName(playerid));
SendClientMessage(ClanMembers[clannum][j], COLOR_ORANGE, string); }
format(string, sizeof(string), " %s (%d) has joined clan %s (Clan ID: %d)", GetName(playerid), playerid, ClanNames[clannum], clannum);
SendDC(CLANS, string);
ClanInfo[clannum][1]++;
PlayerClan[playerid] = clannum;
PlayerInfo[playerid][pClanID] = clannum;
PlayerInfo[playerid][pClan] = ClanNames[clannum];
format(string, sizeof(string),"You joined the clan '%s'(id: %d)", ClanNames[clannum], clannum);
SendClientMessage(playerid, COLOR_YELLOW, string); }
SaveAccountStats(playerid);
return 1;
}