09.12.2014, 19:53
yes sure
PHP код:
//Group filterscript by [HiC]TheKiller - Scripted because Weponz wanted it and I was bored :P.
//Friday 5 August 2011 - Saturday 6 August 2011.
#include <a_samp>
#include <zcmd> // https://sampforum.blast.hk/showthread.ph...0.10697677
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
//Variables
#define MAX_GROUPS 100 // Change this if you think you are going to ever have over 100 groups.
new PLAYERLIST_authed[MAX_PLAYERS];
enum ginfo
{
grname[75],
leader,
active
};
enum pginfo
{
gid,
order,
invited,
attemptjoin
};
new group[MAX_PLAYERS][pginfo];
new groupinfo[MAX_GROUPS][ginfo];
public OnFilterScriptInit()
{
for(new x; x<MAX_PLAYERS; x++)
{
group[x][gid] = -1;
group[x][order] = -1;
group[x][invited] = -1;
group[x][attemptjoin] = -1;
}
print(" Clan Commands ! ");
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(PLAYERLIST_authed[playerid] == 1)
{
dUserSet(PlayerName(playerid)).("Clan",group[playerid]);
}
return 1;
}
COMMAND:clan(playerid, params[])
{
if(group[playerid][gid] != -1) return SendClientMessage(playerid, 0xFF0000, "Dar Hale Hazer Shoma Dar Clani Hastid Va Nemitavanid Clan Besazid !");
if(strlen(params) > 49 || strlen(params) < 3) return SendClientMessage(playerid, 0xFF0000, "TariQe Estefade : /Clan [Name]");
if(IsGroupTaken(params)) return SendClientMessage(playerid, 0xFF0000, "In Name Qablan Sabt Shode ASt !");
if(GetPlayerMoney(playerid) < 20000000) return SendClientMessage(playerid, 0xFF0000, "Shoma MablaQ $20000000 Baraye Sakht Clan Nadarid !");
if(GetPlayerScore(playerid) < 250) return SendClientMessage(playerid, 0xFF0000, "Baraye Sakht Clan Shoma Niyaz Be 250 Score Darid !");
CreateGroup(params, playerid);
GivePlayerMoney(playerid,-20000000);
return 1;
}
COMMAND:khoruj(playerid, params[])
{
if(group[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "Shoma Dar Hich Clani Nistid !");
LeaveGroup(playerid, 0);
return 1;
}
COMMAND:davat(playerid, params[])
{
if(group[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "Shoma Leader clan Nistid Va Nemitavanid Kasi Ra Invite Dahid !");
new cid;
if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "TariQe Estefade : /Davat [ID]");
cid = strval(params);
if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "In Player Dar Server Nist !");
if(group[cid][gid] == group[playerid][gid]) return SendClientMessage(playerid, 0xFF0000, "In Player Hamaknon Dar Clan Shoma Mibashad !");
if(group[cid][invited] == group[playerid][gid]) return SendClientMessage(playerid, 0xFF0000, "Player Be Clan Shoma Davat Shode ASt !");
if(group[cid][attemptjoin] == group[playerid][gid]) return GroupJoin(cid, group[playerid][gid]);
group[cid][invited] = group[playerid][gid];
new string[125], pname[24];
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "Shoma Be Clan {FFFFFF}%s(%d){FFCC66} TavaSote Leader/Co Leader {FFFFFF}%s(%d) Davat Shodid !. /Join %d", groupinfo[group[playerid][gid]][grname], group[playerid][gid], pname, playerid, group[playerid][gid]);
SendClientMessage(cid, 0xFFCC66, string);
GetPlayerName(cid, pname, 24);
format(string, sizeof(string), "Shoma Player {FFFFFF}%s(%d){FFCC66} Ra Be Clane Khod Davat Kardid !", pname, cid);
SendClientMessage(playerid, 0xFFCC66, string);
return 1;
}
COMMAND:cleader(playerid, params[])
{
if(group[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "Shoma Leader Clan Nistid Va Nemitavanid Az In CMD Estefade Konid !");
new cid;
if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "TariQe Estefade : /CLeader [ID]");
cid = strval(params);
if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "In Player Dar Server Nist !");
if(cid == playerid) return SendClientMessage(playerid, 0xFF0000, "Shoma Leader Clan Hastid :|");
if(group[playerid][gid] != group[cid][gid]) return SendClientMessage(playerid, 0xFF0000, "In Player Dar Clan Shoma Nist !");
ChangeMemberOrder(group[playerid][gid], 1);
group[playerid][order] = GroupMembers(group[playerid][gid]);
return 1;
}
COMMAND:join(playerid, params[])
{
if(group[playerid][gid] != -1) return SendClientMessage(playerid, 0xFF0000, "Shoma Hamaknon Dar Yek Clan Hastid Aval Az Clan Kharej Shid Sepas Be Clan Jadid Join Shid !");
new grid;
if( (isnull(params) && group[playerid][invited] != -1 ) || ( strval(params) == group[playerid][invited] && group[playerid][invited] != -1) ) return GroupJoin(playerid, group[playerid][invited]);
if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "TariQe Estefade : {FFFFFF}/groupjoin{FF0000} (groupid)");
grid = strval(params);
if(!groupinfo[grid][active]) return SendClientMessage(playerid, 0xFF0000, "Clani Ke Shoma Mikhayd Dar An Join Shid Vojod Nadarad !");
group[playerid][attemptjoin] = grid;
new string[125], pname[24];
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "Shoma Darkhast Join Be Clan Darid ! ~~> %s(ID:%d)", groupinfo[grid][grname], grid);
SendClientMessage(playerid, 0xFFCC66, string);
format(string, sizeof(string), "{FFFFFF}%s(%d) {FFCC66} Darkhast Join Be Clane Shomara Darad Az CMD Estefade Konid ! ~~> /Joim %d to accept", pname, playerid, playerid);
SendMessageToLeader(grid, string);
return 1;
}
COMMAND:ekhraj(playerid, params[])
{
if(group[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "Shoma Leader Clan Nistid Va Nemitavanid Kasi Ra KiCk Konid !");
new cid;
if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/Ekhraj{FF0000} [ID]");
cid = strval(params);
if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "In Player Dar Server Nist !");
if(cid == playerid) return SendClientMessage(playerid, 0xFF0000, "Shoma Nemitavanid Khodetan Ra Az Clan KiCk Konid :|");
if(group[playerid][gid] != group[cid][gid]) return SendClientMessage(playerid, 0xFF0000, "In Player Dar Clan Shoma Nist !");
LeaveGroup(cid, 1);
return 1;
}
COMMAND:c(playerid, params[])
{
if(group[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "Shoma Dar HiCh Clani Nistid Va Nemitavanid Az In CMD Estefade Konid !");
if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "TariQe Estefade : {FFFFFF}/C{FF0000} [Text]");
new pname[24], string[140+24];
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "{00FF00}[Clan Chat] {00FFFF}%s(%d): {00FF00}%s", pname, playerid, params);
SendMessageToAllGroupMembers(group[playerid][gid], string);
return 1;
}
COMMAND:clanlist(playerid, params[])
{
if(isnull(params) && group[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "TariQe Estefade : {FFFFFF}/ClanList{FF0000} (group)");
if(isnull(params))
{
DisplayGroupMembers(group[playerid][gid], playerid);
return 1;
}
new grid = strval(params);
if(!groupinfo[grid][active]) return SendClientMessage(playerid, 0xFF0000, "ID Clani Ke Shoma Vared Kardid Vojod Nadarad !");
DisplayGroupMembers(grid, playerid);
return 1;
}
COMMAND:clans(playerid, params[])
{
ListGroups(playerid);
return 1;
}
COMMAND:grl(playerid, params[])
return cmd_khoruj(playerid, params);
COMMAND:grc(playerid, params[])
return cmd_clan(playerid, params);
COMMAND:gri(playerid, params[])
return cmd_davat(playerid, params);
COMMAND:grlead(playerid, params[])
return cmd_cleader(playerid, params);
COMMAND:grj(playerid, params[])
return cmd_join(playerid, params);
COMMAND:grk(playerid, params[])
return cmd_ekhraj(playerid, params);
COMMAND:gm(playerid, params[])
return cmd_c(playerid, params);
COMMAND:grlist(playerid, params[])
return cmd_clanlist(playerid, params);
stock DisplayGroupMembers(groupid, playerid)
{
new amount[2], string[200], shortstr[55], pname[24];
format(string, sizeof(string), "Group Members for %s(ID:%d)", groupinfo[groupid][grname], groupid);
SendClientMessage(playerid, 0xFFFFFF, string);
string = "";
for(new x; x<MAX_PLAYERS; x++)
{
if(group[x][gid] == groupid)
{
amount[0] ++;
amount[1] ++;
GetPlayerName(x, pname, 24);
if(groupinfo[groupid][leader] != x) format(shortstr, sizeof(shortstr), "%s(%d),", pname, x);
if(groupinfo[groupid][leader] == x) format(shortstr, sizeof(shortstr), "[LEADER]%s(%d),", pname, x);
if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
if(amount[0] == 6)
{
strdel(string, strlen(string)-1, strlen(string));
SendClientMessage(playerid, 0xFFCC66, string);
string = "";
amount[0] = 0;
}
}
}
strdel(string, strlen(string)-1, strlen(string));
if(amount[0] != 0) SendClientMessage(playerid, 0xFFCC66, string);
return 1;
}
stock ListGroups(playerid)
{
new amount[2], string[200], shortstr[55];
SendClientMessage(playerid, 0xFFFFFF, "Current groups:");
for(new x=0; x<MAX_GROUPS; x++)
{
if(groupinfo[x][active])
{
amount[0] ++;
amount[1] ++;
format(shortstr, sizeof(shortstr), "%s(ID:%d)", groupinfo[x][grname], x);
if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
if(amount[0] == 4)
{
SendClientMessage(playerid, 0xFFCC66, string);
string = "";
amount[0] = 0;
}
}
}
if(amount[1] == 0) SendClientMessage(playerid, 0xFFFF00, "There are currently no active groups!");
if(amount[1] != 0) SendClientMessage(playerid, 0xFFCC66, string);
return 1;
}
stock SendMessageToLeader(groupi, message[])
return SendClientMessage(groupinfo[groupi][leader], 0xFFCC66, message);
stock GroupJoin(playerid, groupi)
{
group[playerid][gid] = groupi;
group[playerid][order] = GroupMembers(groupi);
group[playerid][attemptjoin] = -1;
group[playerid][invited] = -1;
new pname[24], string[130];
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "%s Be Clan Shoma Join Shod !", pname);
SendMessageToAllGroupMembers(groupi, string);
format(string, sizeof(string), "Shoma Be Clan %s(ID:%d) Join Shodid !", groupinfo[groupi][grname] ,groupi);
SendClientMessage(playerid, 0xFFCC66, string);
return 1;
}
stock FindNextSlot()
{
new id;
while(groupinfo[id][active]) id ++;
return id;
}
stock IsGroupTaken(grpname[])
{
for(new x; x<MAX_GROUPS; x++) if(!strcmp(grpname, groupinfo[x][grname], true) && strlen(groupinfo[x][grname]) != 0 && groupinfo[x][active] == 1) return 1;
return 0;
}
stock GroupInvite(playerid, groupid)
return group[playerid][invited] = groupid;
stock CreateGroup(grpname[], owner)
{
new slotid = FindNextSlot();
groupinfo[slotid][leader] = owner;
format(groupinfo[slotid][grname], 75, "%s", grpname);
groupinfo[slotid][active] = 1;
group[owner][gid] = slotid;
group[owner][order] = 1;
new string[120];
format(string, sizeof(string), "{FF00FF}Shoma Clan {00FFFF}%s(ID:%d) {FF00FF} Ra Sakhtid !", grpname, slotid);
SendClientMessage(owner, 0xFFCC66, string);
return slotid;
}
stock LeaveGroup(playerid, reason)
{
new groupid = group[playerid][gid], orderid = group[playerid][order], string[100], pname[24];
group[playerid][gid] = -1;
group[playerid][order] = -1;
GroupCheck(groupid, orderid);
GetPlayerName(playerid, pname, 24);
if(reason == 0)
{
format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} Az Clan Shoma Kharej Shod !", pname, playerid);
SendClientMessage(playerid, 0xFFCC66, "Shoma Az Clanetan Kharej Shodid !");
}
if(reason == 1)
{
format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} Az Clan Shoma KiCk Shod !", pname, playerid);
SendClientMessage(playerid, 0xFFCC66, "Shoma Az Clan KiCk Shodid !");
}
if(reason == 2) format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} Az Clan Shoma Kharej Shod !", pname, playerid);
SendMessageToAllGroupMembers(groupid, string);
return 1;
}
stock GroupCheck(groupid, orderid)
{
new gmems = GroupMembers(groupid);
if(!gmems) groupinfo[groupid][active] = 0;
if(gmems != 0) ChangeMemberOrder(groupid, orderid);
return 1;
}
stock GroupMembers(groupid)
{
if(!groupinfo[groupid][active]) return 0;
new groupmembers;
for(new i; i<MAX_PLAYERS; i++) if(group[i][gid] == groupid) groupmembers++;
return groupmembers;
}
stock ChangeMemberOrder(groupid, orderid)
{
for(new x; x<MAX_PLAYERS; x++)
{
if(group[x][gid] != groupid || group[x][order] < orderid) continue;
group[x][order] --;
if(group[x][order] == 1)
{
groupinfo[groupid][leader] = x;
new string[128], pname[24];
GetPlayerName(x, pname, 24);
format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} Be Onvan Leader Jadid Clan Entekhab Shod", pname, x);
SendMessageToAllGroupMembers(groupid, string);
}
}
return 1;
}
stock SendMessageToAllGroupMembers(groupid, message[])
{
if(!groupinfo[groupid][active]) return 0;
for(new x; x<MAX_PLAYERS; x++) if(group[x][gid] == groupid) SendClientMessage(x, 0xFFCC66, message);
return 1;
}