squad/gang system - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: squad/gang system (
/showthread.php?tid=162267)
squad/gang system -
VictorMartinez - 22.07.2010
I'm trying to make a squad system and i found this forum.sa-mp.com/showthread.php?t=160733&highlight=gang but it's in some other language. Can someone translate it or explain it to me? There is no squas/gang system thread in english on the forums, i checked. I'm sure others need this as well so help would be nice.
Re: squad/gang system -
xfelipex - 22.07.2010
// TOP OF GM
Код:
#define MAX_GANGS 32
#define MAX_GANG_PLAYERS 16
#define WITHOUT_GANG 0
// YET ON THE TOP
Код:
new gangInvite[MAX_PLAYERS];
new PlayerInGang[MAX_PLAYERS];
new gangMembers[MAX_GANGS][MAX_GANG_PLAYERS];//Array to send message previously
ONPLAYERCOMMANDTEXT:
Код:
new cmd[128], idx;
cmd = comandos(cmdtext, idx);
if(strcmp(cmd, "/gangenter", true) == 0)
{
if(PlayerInGang[playerid]==0 && gangInvite[playerid] != 0) //
{
SetPlayerTeam(playerid,gangInvite[playerid]); // Put on the gang, as defined previously
SendClientMessage(playerid, 0xFFFFFFFF, "You entered in the gang");
PlayerInGang[playerid] = GetPlayerTeam(playerid);
gangInvite[playerid] = 0;//Resets the invite
}
return 1;
}
Now the invite
Код:
if(strcmp(cmd, "/ganginvite", true) == 0)
{
new tmp[128];
tmp = comandos(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage /GangInvite[ID]");
SendClientMessage(playerid, 0xFFFFFFFF, "you have been invited for the gang");
gangInvite[strval(tmp)] == PlayerInGang[playerid];//
return 1;
}
MAKE THE GANG
Код:
if(strcmp(cmd, "/gangcriar", true) == 0)
{
new tmp[128];
tmp = comandos(cmdtext, idx);
if(PlayerInGang[playerid]>0)//Se o player estive em uma gang
{
SendClientMessage(playerid, 0xFF8040FF, " Jб estбs em uma gang");
return 0;
}
for(new i = 1; i < MAX_GANGS; i++)//Esse serб o Loop que deve ser menor que MAX_GANGS
{
new string[128];
format(string, sizeof(string),"You made the gang: '%s' (%d)", tmp, i);//Irб Enviar MSG que a gang foi criada com ID
SendClientMessage(playerid, 0xFF8040FF, string);//Envia MSG
PlayerInGang[playerid]=i;//Irб Colocar o Player na Gang
SetPlayerTeam(playerid,PlayerInGang[playerid]);//Seta o Player a Uma Gang a Ativa Anti TK
}
return 1;
}
Save the gang :
Код:
new file[64];
format(file, sizeof(file), "%d.ini", GetPlayerTeam(playerid));// Salva Arquivo com ID_DA_GANG.ini
dini_Create(file);
dini_Set(file,"Nome",tmp);//Salvara Nome da Gang
End of GM :
Код:
stock ler_nome(gangid)
{
new arquivo[128];
format(arquivo,sizeof(arquivo),"%i.ini",gangid);
format(arquivo,sizeof(arquivo),dini_Get(arquivo,"Nome"));
return arquivo;
}
Код:
ler_nome(GetPlayerTeam(playerid));//Lк o nome da gang em arquivo
Gang chat :
Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '!') {//Se Tiver '!'
new string[128]; GetPlayerName(playerid,string,sizeof(string));//Geta Nome
format(string,sizeof(string),"Gang Chat: %s: %s",string,text[1]);//Formato da Mensagem
SendMessageToGang(playerid,0xFFFFFFFF,string);//Envia Mensagem
}
return 0;
}
END OF GM ALSO :
Код:
stock SendMessageToGang(playerid,color,const msg[])
{
for (new i=0; i<MAX_GANG_PLAYERS; i++)//Pega os Membros da Gang
{
if (IsPlayerConnected(i) && PlayerInGang[playerid] > 0)//se tiver conectado e for de um gang
{
SendClientMessage(gangMembers[GetPlayerTeam(playerid)][i],color,msg);//Envia MSG para os mesmos da gang
}
}
return 1;
}
Also end of GM lols
Код:
comandos(const string[], &index)//essa й a strtok modificada para nгo dar complicados com outras
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Tutorial by drakon - Brazil - PT
Re: squad/gang system -
VictorMartinez - 22.07.2010
thanks!