Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //====================================================================[includes]
- #include <a_samp>
- #include <a_mysql>
- #include <izcmd>
- #include <sscanf2>
- #include <easydialog>
- #include <foreach>
- #include <y_iterate>
- #include <strlib>
- //=================================================================[definitions]
- //root 7IMe0bx7BrG4dexg
- #define mysql_host "164.132.4.245"
- #define mysql_user "paruni_samp"
- #define mysql_pass "2fkFEAQ3TAeqU4Vp"
- #define mysql_data "ParUni_V5.2"
- #define MAX_PERMISSION 5
- #define MAX_GROUPP 10
- #define SCM SendClientMessage
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_RED 0xB22222FF
- #define COLOR_GREEN 0x9ACD32AA
- #define SERVER_CLIENT 0x22A1E0FF
- #define COLOR_FIREBRICK 0xC90000FF
- #define MAX_RANKS 5000//increase this if you like. Tho i'd prefer to put a limit for max player's group ranks.
- #define MAX_GROUPS 500//you can change it, if you know what you are doing.
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100
- #if !defined isnull
- #define isnull(%1) \
- ((%1[0] == 0) || (%1[0] == 1 && %1[1] == 0))
- #endif
- //=======================[variables etc]========================================
- new RankSelected[MAX_PLAYERS];
- new TempGroupID[MAX_PLAYERS];
- new InfoOnly[MAX_PLAYERS];
- new MySQL:SQL;
- new PerkUpgrading[MAX_PLAYERS];
- //==============================================================================
- enum groupsDATA
- {
- ORM:ORM_ID,
- gID,
- gName[128],
- gLeaderName[32],
- gchat,
- gCredits,
- gResources,
- gSkillpoints,//ised as skill points atm
- gWarWins,
- gWarlosses,
- gScore,
- gLevel,
- perk1,
- perk2,
- perk3,
- perk4,
- perk5
- };
- new GroupInfo[MAX_GROUPS][groupsDATA];
- enum ranksDATA
- {
- ORM:ORM_ID2,
- rID,
- rgID,//group id
- rName[56],
- rLevel,
- rPermission[MAX_PERMISSION]// 0-NO 1-YES
- };
- new RankInfo[MAX_RANKS][ranksDATA];
- //==============================================================================
- enum playerDATA
- {
- ORM:ORM_ID3,
- pID,
- pName[MAX_PLAYER_NAME],
- grouppid[MAX_GROUPP],//here [MAX_GROUPP] represents maximum number of groups for a player
- prID[MAX_GROUPP],//useful for locating rank id instead of name.
- groupcontribution,
- gWarKills,
- pGroups //should be limited to the number of MAX player groups.
- };
- new pInfo[MAX_PLAYERS][playerDATA];
- new groupvariables[MAX_PLAYERS][2];
- new Iterator:Groups<MAX_PLAYERS>;
- new Iterator:Ranks<MAX_RANKS>;
- //==============================================================================
- //==========================[USEFUL FUNCTIONS]==================================
- //==============================================================================
- GetGroupID(gropname[])//very useful for getting the groupid for the functions below and in cmds.
- {
- foreach(new x : Groups)
- {
- if(!strcmp(gropname, GroupInfo[x][gName], true) && strlen(GroupInfo[x][gName]) != 0) return x;
- }
- return -1;
- }
- GroupLoopCheckName(playerid, grpname[]) //I rarely use this.
- {
- for(new i=0; i < (MAX_GROUPP-1); ++i)
- {
- if(!strcmp(grpname, GroupInfo[pInfo[playerid][grouppid][i]][gName], true))
- {
- return i; //returns the group slotid of player, [grouppid][slotid]
- }
- }
- return 11; //11 = invalid as the max loop is 10
- }
- GroupLoopCheck(playerid, groupid)//a must to use.
- {
- for(new i=0; i < (MAX_GROUPP-1); ++i)
- {
- if(pInfo[playerid][grouppid][i] == GroupInfo[groupid][gID])
- {
- return i; //returns the group slotid of player, [grouppid][slotid]
- }
- }
- return 11;//11 = invalid
- }
- ReturnGroupName(playerid, groupslot) //1-10
- {
- new name[128];
- if(pInfo[playerid][grouppid][groupslot] > -1)
- {
- name = GroupInfo[pInfo[playerid][grouppid][groupslot]][gName];
- return name;
- }
- return 0;
- }
- forward DisplayGroupMembers(groupid, playerid);
- public DisplayGroupMembers(groupid, playerid)
- {
- new query[200], dialogstr[556];
- mysql_format(SQL, query, sizeof(query), "SELECT * FROM `players2` WHERE `grouppid1` = %d OR `grouppid2` = %d OR `grouppid3` = %d OR `grouppid4` = %d OR `grouppid5` = %d OR `grouppid6` = %d OR `grouppid7` = %d OR `grouppid8` = %d OR `grouppid9` = %d OR `grouppid10` = %d", groupid);
- new Cache:result = mysql_query(SQL, query, true);
- new strings[76];
- format(strings,sizeof(strings),"Group Members for %s(%d)",GroupInfo[groupid][gName],groupid);
- new row;
- cache_get_result_count(row);
- if(row > 0)
- {
- new field_name[32];
- new TempString[MAX_PLAYER_NAME], tempid, levelf, groupstr[32], rankname[56], ralevel;
- cache_get_field_name(row, field_name);
- strtrim(field_name, "grouppid");
- strimplode("", groupstr, sizeof(groupstr), "prID", field_name);
- for(new r = 0; r < row; r++)
- {
- cache_get_value_name(r, "pName", TempString);
- cache_get_value_name_int(r, groupstr, levelf);
- foreach(new ra : Ranks)
- {
- if(RankInfo[ra][rID] == levelf)
- {
- format(rankname,sizeof(rankname),RankInfo[ra][rName]);
- ralevel = RankInfo[ra][rLevel];
- }
- }
- tempid = GetID(TempString);
- if(IsPlayerConnected(tempid))
- {
- strcat(dialogstr, "{33EE22}(ONLINE) ");
- }
- else
- {
- strcat(dialogstr, "{FF8080}(OFFLINE) ");
- }
- strcat(dialogstr, sprintf("{FFFF00}(Level:%d)%s {FFFFFF}%s(%d)\n", rankname, ralevel, TempString, tempid));
- }
- ShowDialog(playerid,0, DIALOG_STYLE_TABLIST, strings, dialogstr, "Select", "Close");
- cache_delete(result);
- }
- return 1;
- }
- forward CheckPlayerGroup(playerid, groupid);//groupid = group array in foreach iterator
- public CheckPlayerGroup(playerid, groupid)
- {
- new i = GroupLoopCheck(playerid, groupid);
- if(i == 11)
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- forward CheckPlayerGroupPermission(playerid, groupid, permission);//should be used for checking rank's permission
- public CheckPlayerGroupPermission(playerid, groupid, permission)//returns 1 if everything matches
- {
- new i = GroupLoopCheck(playerid, groupid);
- if(i == 11)
- {
- return 0;
- }
- else
- {
- foreach(new r : Ranks)
- {
- if(RankInfo[r][rID] == pInfo[playerid][prID][i] && RankInfo[r][rgID] == pInfo[playerid][grouppid][i])
- {
- if(RankInfo[r][rPermission][permission] == 1) //if he has the permission
- {
- return 1;
- }
- }
- }
- }
- return 0;
- }
- forward CheckPlayerGroupRankLevel(playerid,groupid,level);//any usage?
- public CheckPlayerGroupRankLevel(playerid,groupid,level)
- {
- new i = GroupLoopCheck(playerid, groupid);
- if(i == 11)
- {
- return 0;
- }
- else
- {
- foreach(new r : Ranks)
- {
- if(RankInfo[r][rID] == pInfo[playerid][prID][i] && RankInfo[r][rgID] == pInfo[playerid][grouppid][i])//RankInfo[r][rgID] == pInfo[playerid][grouppid][i] .... you can remove this.. its just an extra check.
- {
- if(RankInfo[r][rLevel] == level) //level
- {
- return 1;
- }
- }
- }
- }
- return 0;
- }
- forward ReturnGroupLevel(playerid, groupid); //same as above but returns level
- public ReturnGroupLevel(playerid, groupid)
- {
- new count = 0;
- new i = GroupLoopCheck(playerid, groupid);
- if(i == 11)
- {
- return 0;
- }
- else
- {
- foreach(new r : Ranks)
- {
- if(RankInfo[r][rID] == pInfo[playerid][prID][i] && RankInfo[r][rgID] == pInfo[playerid][grouppid][i])//RankInfo[r][rgID] == pInfo[playerid][grouppid][i] .... you can remove this.. its just an extra check.
- {
- count = RankInfo[r][rLevel];
- break;
- }
- }
- }
- return count;
- }
- //==============================================================================
- forward PlayerLoaded(playerid);
- public PlayerLoaded(playerid)
- {
- switch(orm_errno(pInfo[playerid][ORM_ID3]))
- {
- case ERROR_OK:
- {
- //stuff
- }
- case ERROR_NO_DATA:
- {
- orm_insert(pInfo[playerid][ORM_ID3], "CreatePlayerData", "d", playerid);
- }
- }
- orm_setkey(pInfo[playerid][ORM_ID3], "pID");
- return 1;
- }
- forward CreatePlayerData(playerid);
- public CreatePlayerData(playerid)
- {
- orm_update(pInfo[playerid][ORM_ID3]);
- pInfo[playerid][grouppid][0] = -1;
- pInfo[playerid][prID][0] = -1;
- pInfo[playerid][grouppid][1] = -1;
- pInfo[playerid][prID][1] = -1;
- pInfo[playerid][grouppid][2] = -1;
- pInfo[playerid][prID][2] = -1;
- pInfo[playerid][grouppid][3] = -1;
- pInfo[playerid][prID][3] = -1;
- pInfo[playerid][grouppid][4] = -1;
- pInfo[playerid][prID][4] = -1;
- pInfo[playerid][grouppid][5] = -1;
- pInfo[playerid][prID][5] = -1;
- pInfo[playerid][grouppid][6] = -1;
- pInfo[playerid][prID][6] = -1;
- pInfo[playerid][grouppid][7] = -1;
- pInfo[playerid][prID][7] = -1;
- pInfo[playerid][grouppid][8] = -1;
- pInfo[playerid][prID][8] = -1;
- pInfo[playerid][grouppid][9] = -1;
- pInfo[playerid][prID][9] = -1;
- pInfo[playerid][groupcontribution] = 0;
- pInfo[playerid][gWarKills] = 0;
- pInfo[playerid][pGroups] = 0;
- orm_save(pInfo[playerid][ORM_ID3]);
- return 1;
- }
- stock SavePlayerGStats(playerid)
- {
- if(pInfo[playerid][pID] != 0)
- {
- orm_update(pInfo[playerid][ORM_ID3]);
- }
- return 1;
- }
- forward ShowRankEditingMenu(playerid, rank);
- public ShowRankEditingMenu(playerid, rank)
- {
- new dialogstr[556], string1[56], string2[56];
- format(string1,sizeof(string1),"Rank Name\t%s\n",RankInfo[rank][rName]);
- format(string2,sizeof(string2),"Rank Level\t%d\n",RankInfo[rank][rLevel]);
- strcat(dialogstr,string1);
- strcat(dialogstr,string2);
- if(RankInfo[rank][rPermission][0] == 1)
- {
- strcat(dialogstr,"Use Group Chat?\t{00FF00}YES\n");
- }
- else
- {
- strcat(dialogstr,"Use Group Chat?\t{FF0000}NO\n");
- }
- if(RankInfo[rank][rPermission][1] == 1)
- {
- strcat(dialogstr,"Invite Members to the Group?\t{00FF00}YES\n");
- }
- else
- {
- strcat(dialogstr,"Invite Members to the Group?\t{FF0000}NO\n");
- }
- if(RankInfo[rank][rPermission][2] == 1)
- {
- strcat(dialogstr,"Kick Members from the Group?\t{00FF00}YES\n");
- }
- else
- {
- strcat(dialogstr,"Kick Members from the Group?\t{FF0000}NO\n");
- }
- if(RankInfo[rank][rPermission][3] == 1)
- {
- strcat(dialogstr,"Change members rank?\t{00FF00}YES\n");
- }
- else
- {
- strcat(dialogstr,"Change members rank?\t{FF0000}NO\n");
- }
- if(RankInfo[rank][rPermission][4] == 1)
- {
- strcat(dialogstr,"Edit Group rank? And stuff.\t{00FF00}YES\n");
- }
- else
- {
- strcat(dialogstr,"Edit Group rank? And stuff.\t{FF0000}NO\n");
- }
- ShowDialog(playerid,GroupEditRank,DIALOG_STYLE_TABLIST,"Edit Rank Permissions",dialogstr,"Change","Close");
- return 1;
- }
- // =============================================================================
- public OnFilterScriptInit()
- {
- print("_________________________________________________________________________");
- print("> Group System by Heller");
- print("> Script Name : Group System");
- print("> Script Version : BETA");
- print("> Script Coder : Heller");
- print("> Last Update : 7/31/2017");
- print("> mySQL Version : R41 - ORM queries");
- print("_________________________________________________________________________");
- mysql_log();
- SQL = mysql_connect(mysql_host, mysql_user, mysql_data, mysql_pass);
- //load groups & ranks
- mysql_tquery(SQL, "SELECT * FROM `groups2`", "GroupsInformation", "");
- mysql_tquery(SQL, "SELECT * FROM `ranks2`", "RanksInformation", "");
- return 1;
- }
- public OnFilterScriptExit()
- {
- foreach(new b : Groups)
- {
- if(GroupInfo[b][gID] != 0) {
- orm_update(GroupInfo[b][ORM_ID]);
- }
- orm_destroy(GroupInfo[b][ORM_ID]);
- for(new groupsDATA:e; e < groupsDATA; ++e)
- GroupInfo[b][e] = 0;
- }
- foreach(new i : Ranks)
- {
- if(RankInfo[i][rID] != 0) {
- orm_update(RankInfo[i][ORM_ID2]);
- }
- orm_destroy(RankInfo[i][ORM_ID2]);
- for(new ranksDATA:e; e < ranksDATA; ++e)
- RankInfo[i][e] = 0;
- }
- foreach(new players : Player)
- {
- if(pInfo[players][pID] != 0)
- {
- orm_update(pInfo[players][ORM_ID3]);
- }
- orm_destroy(pInfo[players][ORM_ID3]);
- for(new playerDATA:e; e < playerDATA; ++e)
- pInfo[players][e] = 0;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- groupvariables[playerid][0] = -1;
- groupvariables[playerid][1] = 0;
- GetPlayerName(playerid, pInfo[playerid][pName], MAX_PLAYER_NAME);
- new ORM:ormid = pInfo[playerid][ORM_ID3] = orm_create("players2", SQL);
- orm_addvar_int(ormid, pInfo[playerid][pID], "pID");
- orm_addvar_string(ormid, pInfo[playerid][pName], 32, "pName");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][0], "grouppid1");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][1], "grouppid2");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][2], "grouppid3");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][3], "grouppid4");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][4], "grouppid5");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][5], "grouppid6");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][6], "grouppid7");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][7], "grouppid8");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][8], "grouppid9");
- orm_addvar_int(ormid, pInfo[playerid][grouppid][9], "grouppid10");
- orm_addvar_int(ormid, pInfo[playerid][prID][0], "prID1");
- orm_addvar_int(ormid, pInfo[playerid][prID][1], "prID2");
- orm_addvar_int(ormid, pInfo[playerid][prID][2], "prID3");
- orm_addvar_int(ormid, pInfo[playerid][prID][3], "prID4");
- orm_addvar_int(ormid, pInfo[playerid][prID][4], "prID5");
- orm_addvar_int(ormid, pInfo[playerid][prID][5], "prID6");
- orm_addvar_int(ormid, pInfo[playerid][prID][6], "prID7");
- orm_addvar_int(ormid, pInfo[playerid][prID][7], "prID8");
- orm_addvar_int(ormid, pInfo[playerid][prID][8], "prID9");
- orm_addvar_int(ormid, pInfo[playerid][prID][9], "prID10");
- orm_addvar_int(ormid, pInfo[playerid][groupcontribution], "groupcontribution");
- orm_addvar_int(ormid, pInfo[playerid][gWarKills], "gWarKills");
- orm_addvar_int(ormid, pInfo[playerid][pGroups], "pGroups");
- orm_setkey(ormid, "pName");
- orm_select(ormid, "PlayerLoaded", "d", playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid,reason)
- {
- groupvariables[playerid][0] = -1;
- groupvariables[playerid][1] = 0;
- RankSelected[playerid] = -1;
- TempGroupID[playerid] = -1;
- if(pInfo[playerid][pID] != 0)
- {
- orm_update(pInfo[playerid][ORM_ID3]);
- }
- orm_destroy(pInfo[playerid][ORM_ID3]);
- for(new playerDATA:e; e < playerDATA; ++e)
- pInfo[playerid][e] = 0;
- return 1;
- }
- stock SendGroupMessage(color, groupID, string[])
- {
- foreach(new i : Player)
- {
- if(pInfo[i][grouppid][GroupLoopCheck(i, groupID)] == groupID)
- {
- SendClientMessage(i, color, string);
- }
- }
- return 1;
- }
- forward RanksInformation();
- public RanksInformation()
- {
- new row;
- cache_get_row_count(row);
- for(new r=0; r < row; ++r)
- {
- new ORM:ormid = RankInfo[r][ORM_ID2] = orm_create("ranks2", SQL);
- orm_addvar_int(ormid, RankInfo[r][rID], "rID"); //this is the key
- orm_setkey(ormid, "rID"); //here we declare it as the key
- orm_addvar_string(ormid, RankInfo[r][rName],128, "rName");
- orm_addvar_int(ormid, RankInfo[r][rgID], "rgID");
- orm_addvar_int(ormid, RankInfo[r][rLevel], "rLevel");
- orm_addvar_int(ormid, RankInfo[r][rPermission][0], "rPermission1");
- orm_addvar_int(ormid, RankInfo[r][rPermission][1], "rPermission2");
- orm_addvar_int(ormid, RankInfo[r][rPermission][2], "rPermission3");
- orm_addvar_int(ormid, RankInfo[r][rPermission][3], "rPermission4");
- orm_addvar_int(ormid, RankInfo[r][rPermission][4], "rPermission5");
- orm_apply_cache(ormid, r);
- orm_select(ormid, "LoadGroupRank", "d", r);
- }
- return 1;
- }
- forward LoadGroupRank(rid);
- public LoadGroupRank(rid)
- {
- switch(orm_errno(RankInfo[rid][ORM_ID2]))
- {
- case ERROR_OK:
- {
- Iter_Add(Ranks, rid);//active ranks
- }
- case ERROR_NO_DATA:
- {
- }
- }
- return 1;
- }
- forward GroupsInformation();
- public GroupsInformation()
- {
- new row;
- cache_get_row_count(row);
- for(new r=0; r < row; ++r)
- {
- new ORM:ormid = GroupInfo[r][ORM_ID] = orm_create("groups2", SQL);
- orm_addvar_int(ormid, GroupInfo[r][gID], "gID"); //this is the key
- orm_setkey(ormid, "gID"); //here we declare it as the key
- orm_addvar_string(ormid, GroupInfo[r][gName],128, "gName");
- orm_addvar_string(ormid, GroupInfo[r][gLeaderName],32, "gLeaderName");
- orm_addvar_int(ormid, GroupInfo[r][gchat], "gchat");
- orm_addvar_int(ormid, GroupInfo[r][gCredits], "gCredits");
- orm_addvar_int(ormid, GroupInfo[r][gResources], "gResources");
- orm_addvar_int(ormid, GroupInfo[r][gWarWins], "gWarWins");
- orm_addvar_int(ormid, GroupInfo[r][gWarLosses], "gWarLosses");
- orm_addvar_int(ormid, GroupInfo[r][gSkillPoints], "gSkillPoints");
- orm_addvar_int(ormid, GroupInfo[r][gScore], "gScore");
- orm_addvar_int(ormid, GroupInfo[r][perk1], "perk1");
- orm_addvar_int(ormid, GroupInfo[r][perk2], "perk2");
- orm_addvar_int(ormid, GroupInfo[r][perk3], "perk3");
- orm_addvar_int(ormid, GroupInfo[r][perk4], "perk4");
- orm_addvar_int(ormid, GroupInfo[r][perk5], "perk5");
- orm_apply_cache(ormid, r);
- orm_select(ormid, "LoadGroup", "d", r);
- }
- return 1;
- }
- forward LoadGroup(gid);
- public LoadGroup(gid)
- {
- switch(orm_errno(GroupInfo[gid][ORM_ID]))
- {
- case ERROR_OK:
- {
- Iter_Add(Groups, gid);//active groups
- }
- case ERROR_NO_DATA:
- {
- }
- }
- return 1;
- }
- forward MYSQL_SaveGroups(b);
- public MYSQL_SaveGroups(b)
- {
- if(GroupInfo[b][gID] != 0)
- {
- orm_update(GroupInfo[b][ORM_ID]);
- }
- return 1;
- }
- forward GroupCreated(id, playerid, str[], playeridz);
- public GroupCreated(id, playerid, str[], playeridz)
- {
- orm_update(GroupInfo[id][ORM_ID]);
- GroupInfo[id][gchat] = 0;
- format(GroupInfo[id][gName],128,str);
- format(GroupInfo[id][gLeaderName],32,GetPlayerNamee(playerid));
- orm_save(GroupInfo[id][ORM_ID]);
- pInfo[playeridz][grouppid][pInfo[playeridz][pGroups]-1] = GroupInfo[id][gID];
- printf("New Group is created: [%d]", id);
- return 1;
- }
- forward RankCreated(id, gid, name[], levl, playeridz);
- public RankCreated(id, gid, name[], levl, playeridz)
- {
- orm_update(RankInfo[id][ORM_ID2]);
- RankInfo[id][rgID] = GroupInfo[gid][gID];
- RankInfo[id][rLevel] = levl;
- format(RankInfo[id][rName],32,name);
- RankInfo[id][rPermission][0] = 1;
- RankInfo[id][rPermission][1] = 1;
- RankInfo[id][rPermission][2] = 1;
- RankInfo[id][rPermission][3] = 1;
- RankInfo[id][rPermission][4] = 1;
- orm_save(RankInfo[id][ORM_ID2]);
- pInfo[playeridz][prID][pInfo[playeridz][pGroups]-1] = RankInfo[id][rID];
- printf("New Rank is created for Group id:%d: [%d]",gid, id );
- return 1;
- }
- forward RankCreated2(id, gid, name[], levl, playeridz);
- public RankCreated2(id, gid, name[], levl, playeridz)
- {
- orm_update(RankInfo[id][ORM_ID2]);
- RankInfo[id][rgID] = GroupInfo[gid][gID];
- RankInfo[id][rLevel] = levl;
- format(RankInfo[id][rName],32,name);
- RankInfo[id][rPermission][0] = 1;
- RankInfo[id][rPermission][1] = 1;
- RankInfo[id][rPermission][2] = 1;
- RankInfo[id][rPermission][3] = 1;
- RankInfo[id][rPermission][4] = 1;
- orm_save(RankInfo[id][ORM_ID2]);
- printf("New Rank is created for Group id:%d: [%d]",gid, id );
- return 1;
- }
- stock GetPlayerNamee(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
- //===========================[Commands]=========================================
- CMD:grouphelp(playerid,params[])
- {
- SCM(playerid,COLOR_GREY,"Group Commands");
- SCM(playerid,COLOR_GREY,"/groups /groupinfo(ID) /creategroup /groupinvite /g /groupkick /groupranks");
- SCM(playerid,COLOR_GREY,"/GroupEditRank /GroupSetRank /GroupMembers /GCP");
- return 1;
- }
- CMD:groups(playerid,params[])
- {
- if(Iter_Count(Groups) > 0)
- {
- foreach(new i : Groups)
- {
- new string[56];
- format(string,sizeof(string),"Groups:[%d]%s",i,GroupInfo[i][gName]);
- SCM(playerid,COLOR_GREEN,string);
- }
- }
- else
- {
- SCM(playerid,COLOR_RED,"ERROR: No groups were found.");
- }
- return 1;
- }
- CMD:groupinfoid(playerid, params[])
- {
- new id, string[250];
- if(sscanf(params, "i", id)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupInfoID [Group ID]");
- else if(!Iter_Contains(Groups, id)) return SendClientMessage(playerid,COLOR_RED,"[SERVER]: Group Does not exist");
- else
- {
- format(string,sizeof(string),"Group[%d]:%s\nLeader:%s\nGroup Score:%d\nWar Wins:%d\nWar Losses:%d\nDraws:%d\nCredits:%d\nResources:%d\n",
- GroupInfo[id][gID],
- GroupInfo[id][gName],
- GroupInfo[id][gLeaderName],
- GroupInfo[id][gScore],
- GroupInfo[id][gWarWins],
- GroupInfo[id][gWarLosses],
- GroupInfo[id][gSkillPoints],
- GroupInfo[id][gCredits],
- GroupInfo[id][gResources]);
- }
- return ShowDialog(playerid,GroupInfoDialog, DIALOG_STYLE_MSGBOX, "{808080}Group Info", string, "Close", "");
- }
- CMD:groupinfo(playerid, params[])
- {
- new str[128], string[250];
- if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupInfo [Group Name]");
- else if(IsGroupNameTaken(str) == 0) return SendClientMessage(playerid,COLOR_RED,"[SERVER]: Group Does not exist");
- else
- {
- new i = GetGroupID(str);
- format(string,sizeof(string),"Group[%d]:%s\nLeader:%s\nGroup Score:%d\nWar Wins:%d\nWar Losses:%d\SkillPoints:%d\nCredits:%d\nResources:%d\n",
- GroupInfo[i][gID],
- GroupInfo[i][gName],
- GroupInfo[i][gLeaderName],
- GroupInfo[i][gScore],
- GroupInfo[i][gWarWins],
- GroupInfo[i][gWarLosses],
- GroupInfo[i][gSkillPoints],
- GroupInfo[i][gCredits],
- GroupInfo[i][gResources]);
- }
- return ShowDialog(playerid,GroupInfoDialog, DIALOG_STYLE_MSGBOX, "{808080}Group Info", string, "Close", "");
- }
- CMD:creategroup(playerid, params[])
- {
- new player,str[128];
- if(!IsPlayerAdmin(playerid)) return 0;
- if(sscanf(params, "us[128]", player, str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /creategroup [Player ID/Player Name] [Group Name]");
- if(!IsPlayerConnected(player)) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Player hasn't connected to server yet.");
- if(pInfo[player][pGroups] == 10) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Player's Max Group Limit Reached.");
- if(IsGroupNameTaken(str) == 1) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Group Name is already taken.");
- pInfo[playerid][pGroups] += 1;
- new i = Iter_Free(Groups);
- Iter_Add(Groups, i);
- new ORM:ormid1 = GroupInfo[i][ORM_ID] = orm_create("groups2", SQL);
- orm_addvar_int(ormid1, GroupInfo[i][gID], "gID"); //this is the key
- orm_setkey(ormid1, "gID"); //here we declare it as the key
- orm_addvar_string(ormid1, GroupInfo[i][gName],128, "gName");
- orm_addvar_string(ormid1, GroupInfo[i][gLeaderName],32, "gLeaderName");
- orm_addvar_int(ormid1, GroupInfo[i][gchat], "gchat");
- orm_addvar_int(ormid1, GroupInfo[i][gCredits], "gCredits");
- orm_addvar_int(ormid1, GroupInfo[i][gResources], "gResources");
- orm_addvar_int(ormid1, GroupInfo[i][gWarWins], "gWarWins");
- orm_addvar_int(ormid1, GroupInfo[i][gWarLosses], "gWarLosses");
- orm_addvar_int(ormid1, GroupInfo[i][gSkillPoints], "gSkillPoints");
- orm_addvar_int(ormid1, GroupInfo[i][gScore], "gScore");
- orm_apply_cache(ormid1, i);
- orm_insert(GroupInfo[i][ORM_ID], "GroupCreated", "ddsi", i, player, str, player);
- new string[158];
- format(string,sizeof(string),"[SUCCESS]: '%s' named group has been created for '%s'.",str,GetPlayerNamee(playerid));
- SendClientMessage(playerid,COLOR_GREEN,string);
- new o = Iter_Free(Ranks);
- Iter_Add(Ranks, o);
- new ORM:ormid = RankInfo[o][ORM_ID2] = orm_create("ranks2", SQL);
- orm_addvar_int(ormid, RankInfo[o][rID], "rID"); //this is the key
- orm_setkey(ormid, "rID"); //here we declare it as the key
- orm_addvar_string(ormid, RankInfo[o][rName],128, "rName");
- orm_addvar_int(ormid, RankInfo[o][rgID], "rgID");
- orm_addvar_int(ormid, RankInfo[o][rLevel], "rLevel");
- orm_addvar_int(ormid, RankInfo[o][rPermission][0], "rPermission1");
- orm_addvar_int(ormid, RankInfo[o][rPermission][1], "rPermission2");
- orm_addvar_int(ormid, RankInfo[o][rPermission][2], "rPermission3");
- orm_addvar_int(ormid, RankInfo[o][rPermission][3], "rPermission4");
- orm_addvar_int(ormid, RankInfo[o][rPermission][4], "rPermission5");
- orm_apply_cache(ormid, o);
- orm_insert(RankInfo[o][ORM_ID2], "RankCreated", "ddsdi", o, i, "Leader", 100, player);
- return 1;
- }
- CMD:groupinvite(playerid, params[])
- {
- new grpname[128],player, str[158];
- if(sscanf(params, "s[128]u",grpname,player)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /groupinvite [Group Name] [Player ID]");
- {
- new i = GetGroupID(grpname);
- if(i != -1)
- {
- if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
- else if(CheckPlayerGroup(player, i)) return SCM(playerid,COLOR_RED,"Player is already in your group.");
- else if(pInfo[player][pGroups] == 10) return SCM(playerid,COLOR_RED,"Player max group limit reached.");
- else if(!CheckPlayerGroupPermission(playerid, i, 1)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
- else
- {
- groupvariables[player][0] = playerid;
- groupvariables[player][1] = i;
- format(str,sizeof(str),"'%s' named group member is inviting you to '%s' named group, what is your answer?",GetPlayerNamee(playerid),GroupInfo[i][gName]);
- ShowDialog(player,GInviteDialog, DIALOG_STYLE_MSGBOX, "{808080}Group System", str, "Accept", "Decline");
- }
- }
- else return SCM(playerid,COLOR_RED,"Group Does not exists.");
- }
- return 1;
- }
- CMD:g(playerid,params[])
- {
- new grpname[128],str[128];
- if(sscanf(params, "s[128]s[128]",grpname,str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /g [Group Name] [Chat]");
- {
- new i = GetGroupID(grpname);
- if(i != -1)
- {
- if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
- else if(!CheckPlayerGroupPermission(playerid, i, 0)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
- else
- {
- new string[128];
- format(string,sizeof(string),"[%s][%s(%d)]:{FFFFFF}%s.",GroupInfo[i][gName],GetPlayerNamee(playerid),playerid,str);
- SendGroupMessage(COLOR_GREEN,i,string);
- }
- }
- else return SCM(playerid,COLOR_RED,"Group Does not exists.");
- }
- return 1;
- }
- CMD:groupkick(playerid, params[])
- {
- new grpname[128],player, str[158];
- if(sscanf(params, "s[128]u",grpname,player)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /groupkick [Group Name] [Player ID]");
- {
- new i = GetGroupID(grpname);
- if(i != -1)
- {
- if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
- else if(!CheckPlayerGroup(player, i)) return SCM(playerid,COLOR_RED,"Player is not in your group.");
- else if(!CheckPlayerGroupPermission(playerid, i, 2)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
- else if(ReturnGroupLevel(playerid, i) < ReturnGroupLevel(player, i)) return SCM(playerid,COLOR_RED,"You cannot kick your seniors.");
- else
- {
- format(str,sizeof(str),"[%s]:%s(%d) has been kicked from the group.",grpname,GetPlayerNamee(player),player);
- SendGroupMessage(COLOR_RED,pInfo[playerid][grouppid][i],str);
- pInfo[player][grouppid][GroupLoopCheck(playerid, i)] = -1;
- pInfo[player][prID][GroupLoopCheck(playerid, i)] = -1;
- }
- }
- else return SCM(playerid,COLOR_RED,"Group Does not exists.");
- }
- return 1;
- }
- CMD:gcp(playerid,params[])
- {
- new grpname[128];
- if(sscanf(params, "s[128]",grpname)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GCP [Group Name]");
- {
- new i = GetGroupID(grpname);
- if(i != -1)
- {
- if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
- else if(!CheckPlayerGroupPermission(playerid, i, 5)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
- else
- {
- TempGroupID[playerid] = i;
- GroupPanel(playerid,i);
- }
- }
- else return SCM(playerid,COLOR_RED,"Group Does not exists.");
- }
- return 1;
- }
- stock Name(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
- stock GetID(const name[])
- {
- foreach(new i : Player)
- {
- if(!strcmp(name, Name(i)))
- return i;
- }
- return -1;
- }
- IsGroupNameTaken(grpname[])
- {
- foreach(new x : Groups)
- {
- if(!strcmp(grpname, GroupInfo[x][gName], true) && strlen(GroupInfo[x][gName]) != 0) return 1;
- }
- return 0;
- }
- ReturnGroupID(grpname[])
- {
- foreach(new x : Groups)
- {
- if(!strcmp(grpname, GroupInfo[x][gName], true) && strlen(GroupInfo[x][gName]) != 0) return GroupInfo[x][gID];
- }
- return 0;
- }
- ReturnGroupArray(grpname[])
- {
- foreach(new x : Groups)
- {
- if(!strcmp(grpname, GroupInfo[x][gName], true) && strlen(GroupInfo[x][gName]) != 0) return x;
- }
- return -1;
- }
- CMD:groupranks(playerid, params[])
- {
- new str[128];
- if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupRanks [Group Name]");
- else if(IsGroupNameTaken(str) == 0) return SendClientMessage(playerid,COLOR_RED,"[SERVER]: Group Does not exist");
- else
- {
- new dialogstr[512];
- foreach(new r : Ranks)
- {
- if(ReturnGroupID(str) == RankInfo[r][rgID])
- {
- strcat(dialogstr,sprintf("(Level:%d) %s\n",RankInfo[r][rLevel], RankInfo[r][rName]));
- }
- }
- ShowDialog(playerid,groupranklist,DIALOG_STYLE_TABLIST,"Group Ranks",dialogstr,"Close","");
- }
- return 1;
- }
- CMD:groupmembers(playerid, params[])
- {
- new str[128];
- if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupMembers [Group Name]");
- else if(IsGroupNameTaken(str) == 0) return SendClientMessage(playerid,COLOR_RED,"[SERVER]: Group Does not exist");
- else
- {
- DisplayGroupMembers(ReturnGroupArray(str),playerid);
- }
- return 1;
- }
- CMD:groupcreaterank(playerid,params[])
- {
- new grpname[128],str[32], level;
- if(sscanf(params, "s[128]s[32]i",grpname, str, level)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupCreateRank [Group Name] [New Rank Name] [Level]");
- else if(level < 100 && level > 0)
- {
- new i = GetGroupID(grpname);
- if(i != -1)
- {
- if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
- else if(!CheckPlayerGroupPermission(playerid, i, 4)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
- else if(ReturnGroupLevel(playerid, i) < level) return SCM(playerid,COLOR_RED,"Rank must be of lower level to that of yours.");
- else
- {
- new o = Iter_Free(Ranks);
- Iter_Add(Ranks, o);
- new ORM:ormid = RankInfo[o][ORM_ID2] = orm_create("ranks2", SQL);
- orm_addvar_int(ormid, RankInfo[o][rID], "rID"); //this is the key
- orm_setkey(ormid, "rID"); //here we declare it as the key
- orm_addvar_string(ormid, RankInfo[o][rName],128, "rName");
- orm_addvar_int(ormid, RankInfo[o][rgID], "rgID");
- orm_addvar_int(ormid, RankInfo[o][rLevel], "rLevel");
- orm_addvar_int(ormid, RankInfo[o][rPermission][0], "rPermission1");
- orm_addvar_int(ormid, RankInfo[o][rPermission][1], "rPermission2");
- orm_addvar_int(ormid, RankInfo[o][rPermission][2], "rPermission3");
- orm_addvar_int(ormid, RankInfo[o][rPermission][3], "rPermission4");
- orm_addvar_int(ormid, RankInfo[o][rPermission][4], "rPermission5");
- orm_apply_cache(ormid, o);
- orm_insert(RankInfo[o][ORM_ID2], "RankCreated2", "ddsd", o, i, str, level);
- new string[158];
- format(string,sizeof(string),"[%s]: Successfully created the rank %s(Level:%d).",grpname,str,level);
- SendGroupMessage(COLOR_GREEN,pInfo[playerid][grouppid][i],string);
- }
- }
- else return SCM(playerid,COLOR_RED,"Group Does not exists.");
- }
- else return SCM(playerid,COLOR_RED,"Level limit is between 0 to 100.");
- return 1;
- }
- CMD:groupeditrank(playerid,params[])
- {
- new grpname[128],str[32];
- if(sscanf(params, "s[128]s[32]",grpname, str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupEditRank [Group Name] [Rank Name]");
- else
- {
- new i = GetGroupID(grpname);
- if(i != -1)
- {
- if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
- else if(!CheckPlayerGroupPermission(playerid, i, 4)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
- else
- {
- foreach(new rn : Ranks)
- {
- if(RankInfo[rn][rID] == pInfo[playerid][prID][GroupLoopCheck(playerid,i)] && RankInfo[rn][rgID] == i && !strcmp(RankInfo[rn][rName], str,true))
- {
- if(ReturnGroupLevel(playerid, i) < RankInfo[rn][rLevel]) return SCM(playerid,COLOR_RED,"Rank must be of lower level to that of yours.");
- else
- {
- RankSelected[playerid] = rn;
- TempGroupID[playerid] = i;
- ShowRankEditingMenu(playerid, rn);
- break;
- }
- }
- else if(i == Iter_Last(Ranks))
- {
- SCM(playerid,COLOR_RED,"Invalid Rank.");
- }
- }
- }
- }
- else return SCM(playerid,COLOR_RED,"Group Does not exists.");
- }
- return 1;
- }
- CMD:groupsetrank(playerid,params[])
- {
- new grpname[128],str[32], player;
- if(sscanf(params, "us[128]s[32]",player, grpname, str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupSetRank [playerid] [Group Name] [Rank Name]");
- else
- {
- new i = GetGroupID(grpname);
- if(i != -1)
- {
- if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
- else if(!CheckPlayerGroup(player, i)) return SCM(playerid,COLOR_RED,"Player is not in your group.");
- else if(!CheckPlayerGroupPermission(playerid, i, 3)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
- else if(ReturnGroupLevel(playerid, i) < ReturnGroupLevel(player, i)) return SCM(playerid,COLOR_RED,"You cannot boss your seniors.");
- else
- {
- foreach(new rn : Ranks)
- {
- if(RankInfo[rn][rID] == pInfo[playerid][prID][GroupLoopCheck(playerid,i)] && RankInfo[rn][rgID] == i)
- {
- pInfo[player][prID][GroupLoopCheck(playerid, i)] = RankInfo[rn][rID];
- new string[158];
- format(string,sizeof(string),"[%s]:Rank of %s(%d) has been changed to %s.",grpname,GetPlayerNamee(player),player,str);
- SendGroupMessage(COLOR_GREEN,pInfo[playerid][grouppid][i],string);
- break;
- }
- else if(i == Iter_Last(Ranks))
- {
- SCM(playerid,COLOR_RED,"Invalid Rank.");
- }
- }
- }
- }
- else return SCM(playerid,COLOR_RED,"Group Does not exists.");
- }
- return 1;
- }
- //=========================================================================[END]
- Dialog:GInviteDialog(playerid, dialogid, response, listitem, inputtext[])
- {
- new str[128];
- if(!response)
- {
- format(str,sizeof(str),"[SYSTEM]: '%s' has declined your invite.",GetPlayerNamee(playerid));
- SendClientMessage(groupvariables[playerid][0],COLOR_RED,str);
- SendClientMessage(playerid,COLOR_RED,"[SERVER]: You have declined the invite.");
- groupvariables[playerid][0] = -1;
- groupvariables[playerid][1] = 0;
- }
- if(response)
- {
- format(str,sizeof(str),"[SYSTEM]: '%s' has accepted your invite.",GetPlayerNamee(playerid));
- SendClientMessage(groupvariables[playerid][0],COLOR_GREEN,str);
- SendClientMessage(playerid,COLOR_RED,"[SERVER]: You have accepted the invite.");
- pInfo[playerid][grouppid][pInfo[playerid][pGroups]-1] = groupvariables[playerid][1];
- groupvariables[playerid][0] = -1;
- groupvariables[playerid][1] = 0;
- }
- return 1;
- }
- Dialog:GroupEditRank(playerid, dialogid, response, listitem, inputtext[])
- {
- if(!response)
- {
- return 0;
- }
- else if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- ShowDialog(playerid,RankNameChange,DIALOG_STYLE_INPUT,"Change Rank Name","Are you Sure about changing rank name?","Change","No");
- }
- case 1:
- {
- ShowDialog(playerid,RankLevelChange,DIALOG_STYLE_INPUT,"Change Rank Level","Are you Sure about changing rank level?","Change","No");
- }
- case 2:
- {
- if(RankInfo[RankSelected[playerid]][rPermission][0] == 1)
- {
- RankInfo[RankSelected[playerid]][rPermission][0] = 0;
- }
- else
- {
- RankInfo[RankSelected[playerid]][rPermission][0] = 1;
- }
- ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- case 3:
- {
- if(RankInfo[RankSelected[playerid]][rPermission][1] == 1)
- {
- RankInfo[RankSelected[playerid]][rPermission][1] = 0;
- }
- else
- {
- RankInfo[RankSelected[playerid]][rPermission][1] = 1;
- }
- ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- case 4:
- {
- if(RankInfo[RankSelected[playerid]][rPermission][2] == 1)
- {
- RankInfo[RankSelected[playerid]][rPermission][2] = 0;
- }
- else
- {
- RankInfo[RankSelected[playerid]][rPermission][2] = 1;
- }
- ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- case 5:
- {
- if(RankInfo[RankSelected[playerid]][rPermission][3] == 1)
- {
- RankInfo[RankSelected[playerid]][rPermission][3] = 0;
- }
- else
- {
- RankInfo[RankSelected[playerid]][rPermission][3] = 1;
- }
- ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- case 6:
- {
- if(RankInfo[RankSelected[playerid]][rPermission][4] == 1)
- {
- RankInfo[RankSelected[playerid]][rPermission][4] = 0;
- }
- else
- {
- RankInfo[RankSelected[playerid]][rPermission][4] = 1;
- }
- ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- }
- }
- return 1;
- }
- Dialog:RankNameChange(playerid, dialogid, response, listitem, inputtext[])
- {
- if(!response)
- {
- return ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- else if(response)
- {
- strcat(RankInfo[RankSelected[playerid]][rName],inputtext);
- ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- return 1;
- }
- Dialog:RankLevelChange(playerid, dialogid, response, listitem, inputtext[])
- {
- if(!response)
- {
- return ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- else if(response)
- {
- new level = strval(inputtext);
- if(level > 100 || level < 1)
- {
- ShowDialog(playerid,RankLevelChange,DIALOG_STYLE_INPUT,"Change Rank Level","Rank level should be between 1 to 100.","Change","No");
- }
- else
- {
- RankInfo[RankSelected[playerid]][rLevel] = level;
- ShowRankEditingMenu(playerid, RankSelected[playerid]);
- }
- }
- return 1;
- }
- //============================[Group panel]=====================================
- stock SendGroupChatMessage(groupid, message[])
- {
- foreach(new i : Player)
- {
- if(CheckPlayerGroup(i, groupid))
- {
- SendClientMessage(i, SERVER_CLIENT, message);
- }
- }
- return 1;
- }
- GroupPanel(playerid, groupid)
- {
- new dialogstr[556], i = GroupInfo[groupid][gLevel];
- if(i == 0)
- {
- i = 1;
- }
- strcat(dialogstr, "{59D983}Option\tValue\n");
- strcat(dialogstr, sprintf("{59D983}Group Name\t%s(ID:%d)\n", GroupInfo[groupid][gName], groupid));
- strcat(dialogstr, sprintf("{22A1E0}Group Leader\t%s\n", GroupInfo[groupid][gLeaderName]));
- strcat(dialogstr, sprintf("{59D983}Credits\t%i\n", GroupInfo[groupid][gCredits]));
- strcat(dialogstr, sprintf("{59D983}Resources\t%i\n", GroupInfo[groupid][gResources]));
- strcat(dialogstr, sprintf("{59D983}Perks\n"));
- strcat(dialogstr, sprintf("{59D983}Color\n"));
- strcat(dialogstr, sprintf("{59D983}War Wins\t%i\n", GroupInfo[groupid][gWarWins]));
- strcat(dialogstr, sprintf("{22A1E0}Group Level\t%i\n", GroupInfo[groupid][gLevel]));
- strcat(dialogstr, sprintf("{22A1E0}Group Scores\t[%i / %i]\n", GroupInfo[groupid][gScore], ((50+i)*i)));
- strcat(dialogstr, sprintf("{22A1E0}Group Points\t%i\n", GroupInfo[groupid][gWarWins]));
- strcat(dialogstr, sprintf("{59D983}Group Members\n"));
- return ShowDialog(playerid,groupcontrolpanelV, DIALOG_STYLE_TABLIST_HEADERS, "Group Control Panel", dialogstr, "Select", "Close");
- }
- //admin group panel check
- //functions
- ReturnPerkCost(perk, level)
- {
- new amount;
- if(level == 0)
- {
- level = 1;
- }
- switch(perk)
- {
- case 0: amount = (1*level);
- case 1: amount = (10*level);
- case 2: amount = (4*level);
- case 3: amount = (6*level);
- case 4: amount = (10*level);
- }
- return amount;
- }
- ReturnGroupPerkLevel(groupid, perk)
- {
- new level;
- if(perk == 0)
- {
- level = GroupInfo[groupid][perk1];
- }
- if(perk == 1)
- {
- level = GroupInfo[groupid][perk2];
- }
- if(perk == 2)
- {
- level = GroupInfo[groupid][perk3];
- }
- if(perk == 3)
- {
- level = GroupInfo[groupid][perk4];
- }
- if(perk == 4)
- {
- level = GroupInfo[groupid][perk5];
- }
- return level;
- }
- UpgradeGroupPerk(groupid, perk)
- {
- if(perk == 0)
- {
- GroupInfo[groupid][perk1]++;
- }
- if(perk == 1)
- {
- GroupInfo[groupid][perk2]++;
- }
- if(perk == 2)
- {
- GroupInfo[groupid][perk3]++;
- }
- if(perk == 3)
- {
- GroupInfo[groupid][perk4]++;
- }
- if(perk == 4)
- {
- GroupInfo[groupid][perk5]++;
- }
- return 1;
- }
- GroupPerkMsgInfo(perk, groupid)
- {
- new level = ReturnGroupPerkLevel(groupid, perk);
- new output[156];
- if(perk == 0)
- {
- strcat(output,"Squad Bonus allows players in the same team to earn rewards on each other's kill\n");
- new strings[128];
- format(strings,sizeof(strings),"The current level of this perk is %i, upgrade Cost %i skillpoints. Upgrading will increase the bonus variant.\n",level, ReturnPerkCost(perk, level));
- strcat(output,strings);
- }
- if(perk == 1)
- {
- strcat(output,"Group Score Kill Bonus allows the group to earn scores upon player's kill.\n");
- new strings[128];
- format(strings,sizeof(strings),"The current level of this perk is %i, upgrade Cost %i skillpoints. Upgrading will increase the bonus ratio.\n",level, ReturnPerkCost(perk, level));
- strcat(output,strings);
- }
- //more to come edit here
- return output;
- }
- ShowPlayerGroupPerk(playerid)
- {
- new dialogstr[556];
- strcat(dialogstr,"{7F40FF}Perk\tLevel\n");
- new string[56];
- format(string,sizeof(string),"{59D983}Squad Bonus\t[%i / 5]\n", GroupInfo[TempGroupID[playerid]][perk1]);
- strcat(dialogstr, string);
- new string2[56];
- format(string2,sizeof(string2),"{59D983}Group Score Kill Bonus\t%i\n", GroupInfo[TempGroupID[playerid]][perk2]);
- strcat(dialogstr, string2);
- return ShowDialog(playerid,perkgroupperkV, DIALOG_STYLE_TABLIST_HEADERS, "Group Perks", dialogstr, "Select", "Back");
- }
- ShowPlayerResourceDialog(playerid)
- {
- new dialogstr[556];
- strcat(dialogstr,"{7F40FF}Resource Objects\tCost\n");
- strcat(dialogstr, "{59D983}Barbed Grill\t1000R\n"); //0
- strcat(dialogstr, "{59D983}Medic Chamber\t5000R\n"); //1
- strcat(dialogstr, "{59D983}Bunker\t15000R\n"); //2
- strcat(dialogstr, "{59D983}Ladder\t100R\n"); //3
- strcat(dialogstr, "{59D983}Gate\t10000R\n"); //7
- strcat(dialogstr, "{59D983}Reinforced Wall\t3000R\n"); //9
- strcat(dialogstr, "{59D983}Tower\t12000R\n"); //10
- strcat(dialogstr, "{59D983}Rein Wodden Wall\t500R\n"); //11
- strcat(dialogstr, "{59D983}Rein Barbed Grill\t3000R\n"); //12
- strcat(dialogstr, "{59D983}Rein Gate\t15000R\n"); //13
- strcat(dialogstr, "{59D983}Wodden Roof\t200R\n"); //15
- return ShowDialog(playerid,perkresourcediaV, DIALOG_STYLE_TABLIST_HEADERS, "Resource Objects", dialogstr, "Purchase", "Back");
- }
- ReturnPObjectCost(array)
- {
- new cost;
- switch(array)
- {
- case 0: cost = 1000;
- case 1: cost = 5000;
- case 2: cost = 15000;
- case 3: cost = 100;
- case 7: cost = 10000;
- case 9: cost = 3000;
- case 10: cost = 12000;
- case 11: cost = 500;
- case 12: cost = 3000;
- case 13: cost = 15000;
- case 15: cost = 200;
- }
- return cost;
- }
- //[dialogs]
- //resources
- Dialog:perkresourcediaV(playerid, response, listitem, inputtext[])
- {
- if(!response)
- {
- return GroupPanel(playerid, TempGroupID[playerid]);
- }
- if(response)
- {
- new array;
- if(listitem >= 0 && listitem < 4)
- {
- array = (listitem);
- }
- if(listitem == 4)
- {
- array = 7;
- }
- if(listitem >= 5 && listitem < 10)
- {
- array = (listitem+4);
- }
- if(listitem == 10)
- {
- array = 15;
- }
- new cost = ReturnPObjectCost(array);
- if(GroupInfo[TempGroupID[playerid]][gResources] >= cost)
- {
- new strings[128];
- format(strings,sizeof(strings),"[GROUP NOTIFICATION]: {FFFFFF}%s(%d) has Successfully bought a %s. Cost %i resources.",GetPlayerNameEx(playerid),playerid, "item",cost);
- SendGroupChatMessage(GroupInfo[TempGroupID[playerid]][gID], strings);
- GroupInfo[TempGroupID[playerid]][gResources] -= cost;
- }
- else
- {
- SCM(playerid,SERVER_CLIENT,"SERVER: Not enough resources are available.");
- }
- }
- return 1;
- }
- stock GetPlayerNameEx(playerid)
- {
- new name[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid,name,sizeof(name));
- return name;
- }
- //perks
- Dialog:perkgroupperkV(playerid, response, listitem, inputtext[])
- {
- if(!response)
- {
- return GroupPanel(playerid, TempGroupID[playerid]);
- }
- if(response)
- {
- if(!CheckPlayerGroupPermission(playerid, TempGroupID[playerid], 4)) return SendClientMessage(playerid, COLOR_FIREBRICK, "You do not have the permission, you cannot use this Panel!");
- PerkUpgrading[playerid] = listitem;
- ShowDialog(playerid,perkupgradeV, DIALOG_STYLE_MSGBOX, inputtext, GroupPerkMsgInfo(listitem, TempGroupID[playerid]), "Upgrade", "Back");
- }
- return 1;
- }
- Dialog:perkupgradeV(playerid, response, listitem, inputtext[])
- {
- if(!response)
- {
- return ShowPlayerGroupPerk(playerid);
- }
- if(response)
- {
- new groupids = TempGroupID[playerid];
- new cost = ReturnPerkCost(PerkUpgrading[playerid], ReturnGroupPerkLevel(groupids, PerkUpgrading[playerid]));
- new credits = GroupInfo[groupids][gWarWins];
- if(credits >= cost)
- {
- UpgradeGroupPerk(groupids, PerkUpgrading[playerid]);
- ShowPlayerGroupPerk(playerid);
- GroupInfo[groupids][gWarWins] -= cost;
- new strings[128];
- format(strings,sizeof(strings),"[GROUP NOTIFICATION]: {FFFFFF}%s(%d) has Successfully upgraded group perk %i. Cost %i Skillpoints.",GetPlayerNameEx(playerid),playerid,(PerkUpgrading[playerid]+1),cost);
- SendGroupChatMessage(GroupInfo[TempGroupID[playerid]][gID], strings);
- }
- else
- {
- SCM(playerid,SERVER_CLIENT,"SERVER: Not enough skill points are available.");
- }
- }
- return 1;
- }
- //main panel
- Dialog:groupcontrolpanelV(playerid, response, listitem, inputtext[])
- {
- if(!response)
- {
- TempGroupID[playerid] = -1;
- return 0;
- }
- if(response)
- {
- if(InfoOnly[playerid] == 1) return 0;
- if(listitem == 0)//group name
- {
- if(!CheckPlayerGroupPermission(playerid, TempGroupID[playerid], 5)) return SendClientMessage(playerid, COLOR_FIREBRICK, "You do not have the permission, you cannot use this Panel!");
- ShowDialog(playerid,grouprenamedialogV,DIALOG_STYLE_INPUT,"Enter New Name","Character limit is 3-25","Enter","Back");
- }
- if(listitem == 2)//credits
- {
- if(!CheckPlayerGroupPermission(playerid, TempGroupID[playerid], 5)) return SendClientMessage(playerid, COLOR_FIREBRICK, "You do not have the permission, you cannot use this Panel!");
- ShowDialog(playerid,creditconvertV,DIALOG_STYLE_INPUT,"Credit Conversion","1 credit = 1000$","Convert","Back");
- }
- if(listitem == 3)//resources
- {
- if(!CheckPlayerGroupPermission(playerid, TempGroupID[playerid], 5)) return SendClientMessage(playerid, COLOR_FIREBRICK, "You do not have the permission, you cannot use this Panel!");
- ShowPlayerResourceDialog(playerid);
- }
- if(listitem == 4)//perks
- {
- ShowPlayerGroupPerk(playerid);
- }
- if(listitem == 5)//color
- {
- if(!CheckPlayerGroupPermission(playerid, TempGroupID[playerid], 5)) return SendClientMessage(playerid, COLOR_FIREBRICK, "You do not have the permission, you cannot use this Panel!");
- SCM(playerid,SERVER_CLIENT,"SERVER: Please use the following command. /EditGroupColor");
- }
- if(listitem == 6)//war wins
- {
- //
- }
- if(listitem == 10) //group members
- {
- new params[5];
- format(params,5,"%d",TempGroupID[playerid]);
- return cmd_groupmembers(playerid, params);
- }
- }
- return 1;
- }
- //credit convert
- Dialog:creditconvertV(playerid, response, listitem, inputtext[])
- {
- if(!response)
- {
- GroupPanel(playerid, TempGroupID[playerid]);
- }
- if(response)
- {
- new amount = strval(inputtext);
- if(amount <= GroupInfo[TempGroupID[playerid]][gCredits] && amount > 0)
- {
- new strings[128];
- format(strings,sizeof(strings),"[GROUP NOTIFICATION]: {FFFFFF}%s(%d) has Successfully converted %i credits to %i$.",GetPlayerNameEx(playerid),playerid,amount,amount*1000);
- SendGroupChatMessage(GroupInfo[TempGroupID[playerid]][gID], strings);
- GroupInfo[TempGroupID[playerid]][gCredits] -= amount;
- GivePlayerMoney(playerid,amount*1000);
- }
- else if(amount < 0 && GetPlayerMoney(playerid) >= (-1*amount*1000))
- {
- new strings[128];
- format(strings,sizeof(strings),"[GROUP NOTIFICATION]: {FFFFFF}%s(%d) has Successfully converted %i$ to %i Credits.",GetPlayerNameEx(playerid),playerid,-amount*1000,-amount);
- SendGroupChatMessage(GroupInfo[TempGroupID[playerid]][gID], strings);
- GroupInfo[TempGroupID[playerid]][gCredits] += -amount;
- GivePlayerMoney(playerid,amount*1000);
- }
- else
- {
- ShowDialog(playerid,creditconvertV,DIALOG_STYLE_INPUT,"Credit Conversion","Not Enough credits are avilable","Convert","Back");
- }
- }
- return 1;
- }
- //army status
- //group name
- Dialog:grouprenamedialogV(playerid, response, listitem, inputtext[])
- {
- if(!response)
- {
- GroupPanel(playerid, TempGroupID[playerid]);
- }
- if(response)
- {
- if(strlen(inputtext) > 2 || strlen(inputtext) < 26)
- {
- format(GroupInfo[TempGroupID[playerid]][gName],128,"%s",inputtext);
- GroupPanel(playerid, TempGroupID[playerid]);
- }
- else
- {
- ShowDialog(playerid,grouprenamedialogV,DIALOG_STYLE_INPUT,"Enter New Name","Character limit is 3-25","Enter","Back");
- }
- }
- return 1;
- }
- //==============================================================================
Add Comment
Please, Sign In to add comment