Raised This Month: $51 Target: $400
 12% 

can someone make this to work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheRealMeDa
New Member
Join Date: Jul 2023
Old 07-28-2023 , 01:33   can someone make this to work
Reply With Quote #1

plugin should work like this:

Players will able to create their own teams by using a command like "/createteam [team name]". The system will store the team information, including the team name and the players in the team.

Players will able to join an existing team by using a command like "/jointeam [team name]". The system will check if the team exists and if there are any available slots for new players.

Players will be able to leave their current team by using a command like "/leaveteam". The system will remove the player from the team and update the team information accordingly.

Players will be able to chat in the same team can communicate with each other using a team chat. They can use a command like "/t [message]" to send a message to their team members only.

Team management: The system will provide commands for team leaders to manage their teams, such as adding or removing players, promoting or demoting team members, and disbanding the team.


THIS IS THE CODE WHICH ONE I USE TO MAKE IT WORK BUT IT DOESN"T


#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >

new const MAX_TEAMS = 10;
new const MAX_TEAM_NAME = 32;
new const MAX_TEAM_MEMBERS = 10;

enum TeamError {
TEAM_SUCCESS,
TEAM_ERROR_INVALID_TEAM,
TEAM_ERROR_TEAM_FULL,
TEAM_ERROR_ALREADY_IN_TEAM,
TEAM_ERROR_NOT_IN_TEAM,
TEAM_ERROR_TEAM_NOT_FOUND,
TEAM_ERROR_INSUFFICIENT_PERMISSIONS
};

enum TeamRank {
TEAM_RANK_MEMBER,
TEAM_RANK_LEADER
};

enum TeamChatMode {
TEAM_CHAT_OFF,
TEAM_CHAT_ON
};

enum {
MAX_TEAM_CHAT_MESSAGE = 128
};

new TeamData[MAX_TEAMS][MAX_TEAM_NAME];
new TeamMembers[MAX_TEAMS][MAX_TEAM_MEMBERS][2]; // [0] = playerid, [1] = rank
new TeamChatMode[MAX_TEAMS];

stock GetTeamId(const teamName[]) {
for (new i = 0; i < MAX_TEAMS; i++) {
if (!strcmp(TeamData[i], teamName, true)) {
return i;
}
}
return -1;
}

stock GetTeamName(teamId, teamName[], size) {
if (teamId < 0 || teamId >= MAX_TEAMS) {
return false;
}
format(teamName, size, "%s", TeamData[teamId]);
return true;
}

stock GetTeamMemberRank(teamId, playerid) {
for (new i = 0; i < MAX_TEAM_MEMBERS; i++) {
if (TeamMembers[teamId][i][0] == playerid) {
return TeamMembers[teamId][i][1];
}
}
return -1;
}

stock GetTeamMemberCount(teamId) {
new count = 0;
for (new i = 0; i < MAX_TEAM_MEMBERS; i++) {
if (TeamMembers[teamId][i][0] != INVALID_PLAYER_ID) {
count++;
}
}
return count;
}

stock AddTeamMember(teamId, playerid, rank) {
for (new i = 0; i < MAX_TEAM_MEMBERS; i++) {
if (TeamMembers[teamId][i][0] == INVALID_PLAYER_ID) {
TeamMembers[teamId][i][0] = playerid;
TeamMembers[teamId][i][1] = rank;
return true;
}
}
return false;
}

stock RemoveTeamMember(teamId, playerid) {
for (new i = 0; i < MAX_TEAM_MEMBERS; i++) {
if (TeamMembers[teamId][i][0] == playerid) {
TeamMembers[teamId][i][0] = INVALID_PLAYER_ID;
TeamMembers[teamId][i][1] = -1;
return true;
}
}
return false;
}

stock IsPlayerInTeam(playerid) {
for (new i = 0; i < MAX_TEAMS; i++) {
for (new j = 0; j < MAX_TEAM_MEMBERS; j++) {
if (TeamMembers[i][j][0] == playerid) {
return true;
}
}
}
return false;
}

stock CreateTeam(playerid, const teamName[]) {
if (GetTeamId(teamName) != -1) {
return TEAM_ERROR_INVALID_TEAM;
}

new teamId = -1;
for (new i = 0; i < MAX_TEAMS; i++) {
if (TeamData[i][0] == '\0') {
teamId = i;
break;
}
}

if (teamId == -1) {
return TEAM_ERROR_TEAM_FULL;
}

TeamData[teamId][0] = teamName;
TeamMembers[teamId][0][0] = playerid;
TeamMembers[teamId][0][1] = TEAM_RANK_LEADER;

return TEAM_SUCCESS;
}

public plugin_init() {
register_plugin("Team Management", "1.0", "");
}

public client_putinserver(id) {
// Assign player to a team if not already in a team
if (!IsPlayerInTeam(id)) {
CreateTeam(id, "Default Team");
}
}

public client_disconnect(id) {
// Remove player from their team upon disconnection
for (new i = 0; i < MAX_TEAMS; i++) {
for (new j = 0; j < MAX_TEAM_MEMBERS; j++) {
if (TeamMembers[i][j][0] == id) {
TeamMembers[i][j][0] = INVALID_PLAYER_ID;
TeamMembers[i][j][1] = -1;
break;
}
}
}
}

public client_command(id, cmd[], args[]) {
if (cmd == "jointeam") {
if (args[0] != "") {
new teamId = GetTeamId(args[0]);
if (teamId != -1) {
if (GetTeamMemberCount(teamId) < MAX_TEAM_MEMBERS) {
if (!IsPlayerInTeam(id)) {
AddTeamMember(teamId, id, TEAM_RANK_MEMBER);
client_print(id, print_chat, "You have joined team %s.", args[0]);
} else {
client_print(id, print_chat, "You are already in a team.");
}
} else {
client_print(id, print_chat, "The team is full.");
}
} else {
client_print(id, print_chat, "Invalid team name.");
}
} else {
client_print(id, print_chat, "Usage: jointeam <teamname>");
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
TheRealMeDa is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 07-30-2023 , 18:42   Re: can someone make this to work
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?p=351664
you need something like this, i cant guarantee if this plugin would work considering when it was posted
__________________
bigdaddy424 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode