13.11.2010, 17:58
(
Последний раз редактировалось marinov; 27.05.2011 в 22:34.
)
The code:
The line:
Код:
if(strcmp(cmd, "/team", true) == 0) { //teams new tmp[256]; new gangcmd, gangnum; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create/join/invite/quit] [name/id]"); return 1; } giveplayerid = strval(tmp); if(strcmp(tmp, "create", true)==0) gangcmd = 1; else if(strcmp(tmp, "invite", true)==0) gangcmd = 2; else if(strcmp(tmp, "join", true)==0) gangcmd = 3; else if(strcmp(tmp, "quit", true)==0) gangcmd = 4; tmp = strtok(cmdtext, idx); if(gangcmd < 3 && !strlen(tmp)) { if(gangcmd==0) SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create/join/invite/quit] [name/id]"); else if(gangcmd==1) SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create] [name]"); else if(gangcmd==2) SendClientMessage(playerid, COLOR_WHITE, "USE: /team [invite] [playerid]"); return 1; } //create if(gangcmd==1) { if(playerGang[playerid]>0) { SendClientMessage(playerid, COLOR_RED, "You're already in a team!"); return 1; } for(new i = 1; i < MAX_GANGS; i++) { if(gangInfo[i][0]==0) { format(gangNames[i], MAX_GANG_NAME, "%s", tmp); gangInfo[i][0]=1; gangInfo[i][1]=1; gangInfo[i][2]=playerColors[playerid]; gangMembers[i][0] = playerid; format(string, sizeof(string),"You created a team '%s' (id: %d)", gangNames[i], i); SendClientMessage(playerid, COLOR_GREEN, string); playerGang[playerid]=i; return 1; } } return 1; //joining team } else if (gangcmd==3) { gangnum = gangInvite[playerid]; if(playerGang[playerid]>0) { SendClientMessage(playerid, COLOR_RED, "You're already in a team!"); return 1; } if(gangInvite[playerid]==0) { SendClientMessage(playerid, COLOR_RED, "You weren't invited."); return 1; } if(gangInfo[gangnum][0]==0) { SendClientMessage(playerid, COLOR_RED, "This team does not exist!"); return 1; } if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS) { new i = gangInfo[gangnum][1]; gangInvite[playerid]=0; gangMembers[gangnum][i] = playerid; GetPlayerName(playerid, sendername, MAX_PLAYER_NAME); for(new j = 0; j < gangInfo[gangnum][1]; j++) { format(string, sizeof(string),"%s joined a team.", sendername); SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string); } gangInfo[gangnum][1]++; playerGang[playerid] = gangnum; SetPlayerColor(playerid,gangInfo[gangnum][2]); format(string, sizeof(string),"You joined a team'%s' (id: %d)", gangNames[gangnum], gangnum); SendClientMessage(playerid, COLOR_GREEN, string); return 1; } SendClientMessage(playerid, COLOR_RED, "This team is full."); return 1; //invite } else if (gangcmd==2) { giveplayerid = strval(tmp); if(playerGang[playerid]==0) { SendClientMessage(playerid, COLOR_RED, "You're not in a team!"); return 1; } if(gangMembers[playerGang[playerid]][0]!=playerid) { SendClientMessage(playerid, COLOR_RED, "You must be the team leader."); return 1; } if(IsPlayerConnected(giveplayerid)) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); format(string, sizeof(string),"You invited %s.", giveplayer); SendClientMessage(playerid, COLOR_GREEN, string); format(string, sizeof(string),"You were invited to join '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]); SendClientMessage(giveplayerid, COLOR_GREEN, string); gangInvite[giveplayerid]=playerGang[playerid]; } else SendClientMessage(playerid, COLOR_RED, "Player does not exist!"); //quit } else if (gangcmd==4) { PlayerLeaveGang(playerid); } return 1; } //info if(strcmp(cmd, "/teaminfo", true) == 0) { new tmp[256]; new gangnum; tmp = strtok(cmdtext, idx); if(!strlen(tmp) && playerGang[playerid]==0) { SendClientMessage(playerid, COLOR_WHITE, "USE: /teaminfo [name/number]"); return 1; } else if (!strlen(tmp)) gangnum = playerGang[playerid]; else gangnum = strval(tmp); if(gangInfo[gangnum][0]==0) { SendClientMessage(playerid, COLOR_RED, "This team does not exist!"); return 1; } format(string, sizeof(string),"'%s' Team Members (id: %d)", gangNames[gangnum], gangnum); SendClientMessage(playerid, COLOR_GREEN, string); for(new i = 0; i < gangInfo[gangnum][1]; i++) { GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer)); format(string, sizeof(string),"%s (%d)", giveplayer, gangMembers[gangnum][i]); SendClientMessage(playerid, COLOR_YELLOW, string); } return 1; } //teams if(strcmp(cmd, "/teams", true) == 0) { new AB; SendClientMessage(playerid, COLOR_GREEN, "Teams:"); for(new i=0; i < MAX_GANGS; i++) { if(gangInfo[i][0]==1) { format(string, sizeof(string), "%s%s(%d) - %d members", string,gangNames[i],i,gangInfo[i][1]); AB++; if(x > 2) { SendClientMessage(playerid, COLOR_YELLOW, string); AB = 0; format(string, sizeof(string), ""); } else { format(string, sizeof(string), "%s, ", string); } } } if(AB <= 2 && AB > 0) { string[strlen(string)-2] = '.'; SendClientMessage(playerid, COLOR_YELLOW, string); } return 1; } return 1; }
The line:
Код:
format(string, sizeof(string),"You created a team '%s' (id: %d)", gangNames[i], i);