Clan.inc, GetOnlineClanMembers - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Clan.inc, GetOnlineClanMembers (
/showthread.php?tid=662513)
Clan.inc, GetOnlineClanMembers -
xRadical3 - 03.01.2019
I want get online clan members but i dont know how to create the function to get online clan members from mysql. I use clan.inc
this show the all clan members:
pawn Code:
COMMAND:ocmembers(playerid, params[])
{
if(IsPlayerAnyClanMember(playerid) && GetPlayerClanRank(playerid) >= 5)
{
new MSG[256];
format(MSG, sizeof(MSG), "%s",GetClanMembers(GetPlayerClan(playerid)));
Dialog_Show(playerid, dialogUnused, DIALOG_STYLE_MSGBOX, "Offline Clan Members", MSG, "Ok", "");
} else return 0;
return 1;
}
stock GetClanMembers(clan[])
{
new clanquery[200];
new minfo[300], mreturn[300];
new string[300];
format(clanquery, sizeof(clanquery), "SELECT * FROM members WHERE clanname = '%s'", clan);
mysql_query(1,clanquery);
mysql_store_result();
while(mysql_fetch_row_format(clanquery,"|"))
{
mysql_fetch_field_row(string,"playername");
format(minfo,sizeof(minfo),"{FFFF00}%s\n",string);
strcat(mreturn, minfo);
}
mysql_free_result();
return mreturn;
}
Re: Clan.inc, GetOnlineClanMembers -
Kaliber - 04.01.2019
You can do it like this:
PHP Code:
stock IsUserOnline(const name[])
{
for(new i=GetPlayerPoolSize(),n[MAX_PLAYER_NAME]; i!=-1; i--)
{
if(GetPlayerName(i,n,MAX_PLAYER_NAME) && !strcmp(name,n)) return 1;
}
return 0;
}
And then write your format like this:
PHP Code:
format(minfo,sizeof(minfo),"{FFFF00}%s (%s)\n",string,(IsUserOnline(string)?("Online"):("Offline")));
Re: Clan.inc, GetOnlineClanMembers -
fiki574 - 04.01.2019
Code:
stock GetOnlinePlayersCount(clan[])
{
new count = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerConnected(i) == 1 && IsPlayerClanMember(i, clan) == 1)
count += 1;
return count;
}
stock GetOnlinePlayersList(clan[])
{
new count = GetOnlinePlayersCount(clan);
new minfo[32], mreturn[32 * count];
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerConnected(i) == 1 && IsPlayerClanMember(i, clan) == 1)
{
format(minfo, sizeof(minfo), "%s\n", string);
strcat(mreturn, minfo);
}
return mreturn;
}
Bit shitty and unoptimized, but does what you need.