Clan system -
Airblog - 28.01.2015
Hi all
i'm going to create a dynamic clan system
but it doesn't work
it should be good but...
enum
Код:
enum claninfo
{
ClanName[32],
ClanTag[6],
ClanRank,
ClanDes[256],
ClanMOTD[256],
ClanTaken,
CMembers,
}
new ClanInfo[MAX_CLANS][claninfo];
Stock SaveClans
Код:
stock SaveClans()
{
new idx = 0, File:file;
new string[128];
while(idx < MAX_CLANS)
{
format(string, sizeof(string), "%s|%s|%d|%s|%s|%d|%d\r\n",
ClanInfo[idx][ClanName],
ClanInfo[idx][ClanTag],
ClanInfo[idx][ClanRank],
ClanInfo[idx][ClanDes],
ClanInfo[idx][ClanMOTD],
ClanInfo[idx][ClanTaken],
ClanInfo[idx][CMembers]);
if(idx == 0)
{
file = fopen("CLANS.cfg", io_write);
}
else
{
file = fopen("CLANS.cfg", io_append);
}
fwrite(file, string);
fclose(file);
idx++;
}
print("Clans saved successfully.");
}
stock loadclans
Код:
stock LoadClans()
{
new cinfo[7][128];
new string[256];
new File:file = fopen("CLANS.cfg", io_read);
if(file)
{
new idx = 0;
while(idx < MAX_CLANS)
{
fread(file, string);
split(string, cinfo, '|');
format(ClanInfo[idx][ClanName], 32, "%s", cinfo[0]);
format(ClanInfo[idx][ClanTag], 6, "%s", cinfo[1]);
ClanInfo[idx][ClanRank] = strval(cinfo[2]);
format(ClanInfo[idx][ClanDes], 256, "%s", cinfo[3]);
format(ClanInfo[idx][ClanMOTD], 64, "%s", cinfo[4]);
ClanInfo[idx][ClanTaken] = strval(cinfo[5]);
ClanInfo[idx][CMembers] = strval(cinfo[6]);
idx++;
}
}
print("CLANS loaded successfully.");
return 1;
}
CMD:CreateClan
Код:
CMD:createclan(playerid,params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "First Login.");
if(ClanMaker[playerid] == 0) return SCM(playerid,COLOR_ALIREZA,"You Havent Clan Permission");
new cname[30], ctag[30],idx;
if(sscanf(params, "is[30]s[30]",idx, cname, ctag)) return SendClientMessage(playerid,-1,"USAGE: /createclan <slot> <clan-name> <clan-tag>");
{
if(ClanInfo[idx][ClanTaken]) return SendClientMessage(playerid, COLOR_GREY, "Clan slot is already in use.");
if(idx < 1 || idx > 20) return SendClientMessage(playerid, COLOR_GREY, "Clans are between 1 and 20.");
format(ClanInfo[idx][ClanName], 32, "%s", cname);
format(ClanInfo[idx][ClanTag], 6, "%s",ctag);
ClanInfo[idx][ClanTaken] = 1;
ClanInfo[idx][CMembers] ++;
PlayerInfo[playerid][pClan] = idx;
PlayerInfo[playerid][pClanRank] = 6;
return 1;
}
return 1;
}
and i have pClan and pClanRank in playerinfo
And stocks
Код:
stock GetPlayerClan(playerid)
{
return PlayerInfo[playerid][pClan];
}
stock GetPlayerClanTag(playerid)
{
return ClanInfo[PlayerInfo[playerid][pClan]][ClanTag];
}
stock GetPlayerClanRank(playerid)
{
return PlayerInfo[playerid][pClanRank];
}
stock SendPlayerClanMessage(playerid,color,string[])
{
foreach(Player, i)
{
if(IsPlayerLoggedIn(i) && PlayerInfo[i][pClan] == PlayerInfo[playerid][pClan])
{
SCM(i, color, string);
}
}
return 1;
}
and i put this under onplayerconnect
Код:
if(GetPlayerClan(playerid) == true)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new n_name[MAX_PLAYER_NAME];
format(n_name, sizeof(n_name), "[%s]%s", GetPlayerClanTag(playerid), name);
SetPlayerName(playerid, n_name);
}
but in line
if(GetPlayerClan(playerid) == true)
gives me warning tag mistmach
and when i connected clan tag won't add near my name
Please Help i'll give +Rep (Sry bad english)
Re: how to make stock -
Airblog - 28.01.2015
so what should i do?
Re: how to make stock -
Gammix - 28.01.2015
pawn Код:
if(GetPlayerClan(playerid) == 1)
This is because the function
GetPlayerClan(playerid) is not a boolean, its rather a integer; but not sure as you haven't provided the code related
PlayerInfo[playerid][pClan].
If its a boolean var, then here:
pawn Код:
stock bool:GetPlayerClan(playerid)
{
return PlayerInfo[playerid][pClan];
}