[TUT] Criando Gangs (/gang criar)
#1

Antes vou dizer que o Tutorial esta muito bem explicado, sу precisa prestar atenзгo nos comentбrios dentro do Cуdigo, se tiver algum erro comunique-me por PM, caso contrario esta me incentivando cada vez mais de parar de fazer tutos!
Bom vou postar aqui um tutorial inйdito de como criar um sistema de Gang Criбveis..
Primeiramente Vamos definir algumas coisinhas para posteriormente fazermos as Gangs, Lembrando que usarei SetPlayerTeam portando teremos o AntiTeamKill Feito jб
Topo GM:
pawn Код:
#define MAX_GANGS 32
#define MAX_GANG_PLAYERS 16
#define SEM_GANG 0
Nesta duas Diretivas acima iremos definir o nъmero mбximo que o Loop para criar Gang pode chegar (32) e o numero mбximo de players em uma gang (16), enquanto a SEM_GANG й a diretiva dos players que serгo sem gang (0)

Vamos agora fazer as Arrays para a Gang:
Ainda no Topo:
pawn Код:
new gangInvite[MAX_PLAYERS];
new PlayerInGang[MAX_PLAYERS];
new gangMembers[MAX_GANGS][MAX_GANG_PLAYERS];//Array para Enviar Mensagem posteriormente
Essa Array serб usada para definir se o player esta pronto ou nгo para entrar para Gang, e a Array 'PlayerInGang' й para ver o ID da gang do player...
Claro que isso pode ser substituido por PVARS para ficar mais otimizado,enfim.


Em OnGameModeInit
pawn Код:
if(!dini_Exists(Archivo))
{
dini_Create(Archivo);
dini_IntSet(Archivo, "GangsCreates", 0);
}
[i] Isso daqui cria o Arquivo para fazer o ID da Gang Posteriormente

Agora vamos ao comando em OnPlayerCommandTex:
GangEntrar:
pawn Код:
new cmd[128], idx;
cmd = comandos(cmdtext, idx);
if(strcmp(cmd, "/gangentrar", true) == 0)
  {
if(PlayerInGang[playerid]==0 && gangInvite[playerid] != 0) //Se o Convite for Diferente de '0' que seria a gang padrao  e  ele estiver fora da gang
{
SetPlayerTeam(playerid,gangInvite[playerid]); // coloca na gang como definido anteriormente
SendClientMessage(playerid, 0xFFFFFFFF, "vocк foi entrou na gang");
PlayerInGang[playerid] = GetPlayerTeam(playerid);
gangInvite[playerid] = 0;//Reseta o Convite
}
return 1;
}

Enfim Vamos ao Convite:
pawn Код:
if(strcmp(cmd, "/gangconvite", true) == 0)
    {
    new tmp[128];
    tmp = comandos(cmdtext, idx);
    if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Uso do Comando: /gangconvite[ID]");
    SendClientMessage(playerid, 0xFFFFFFFF, "vocк foi convidado a entrar em uma gang");
    gangInvite[strval(tmp)] == PlayerInGang[playerid];//Habilita Convite para o ID da Gang
    return 1;
    }
Primeiramente vamo criar um Loop para definir o ID da Gang
Esse serб o comando de criar a gang, claro que ele nunca salvarб o nome da Gang apenas o ID dela porйm vocк pode fazer um jogo de 'salvamento' e salvar o ID da Gang em um arquivo com Nome dela, Veja Abaixo..
pawn Код:
if(strcmp(cmd, "/gangcriar", true) == 0)
    {
    new tmp[128];
        tmp = comandos(cmdtext, idx);
    if(PlayerInGang[playerid]>0)//Se o player estive em uma gang
    {
    return SendClientMessage(playerid, 0xFF8040FF, " Jб estбs em uma gang");;
    }
        new i;//define id da gang
    i= dini_Int("Gang.ini", "GangsCreates")+1;//define id da gang
    new string[128];
    format(string, sizeof(string),"Vocк criou a 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;
    }
pawn Код:
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
Entгo para Carregar:
pawn Код:
stock ler_nome(gangid)
{
    new arquivo[128];
    format(arquivo,sizeof(arquivo),"%i.ini",gangid);
    format(arquivo,sizeof(arquivo),dini_Get(arquivo,"Nome"));
    return arquivo;
}
entгo basta fazer
pawn Код:
ler_nome(GetPlayerTeam(playerid));//Lк o nome da gang em arquivo
Agora Vamos Criar o Chat da Gang:

pawn Код:
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;
}
Agora a Stock que Envia Mensagem para a Gang Internamente:
pawn Код:
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;
}
Agora Final GM:

pawn Код:
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;
}

Pois bem este й o Fim, espero que tenham gostado,
Crйditos a DraKoN

Se quiserem saber como faz as Gang Zones Dominaives basta acessar aqui:

https://sampforum.blast.hk/showthread.php?tid=143646

Eu Fiz o TUTO Usando gTeams para ser compactнvel com outros assim como do andmeida10

>>>P.S: virei emo
Reply
#2

DraKoN....DraKoN....DraKoN....nгo quero te onfender mais esse seu tutorial й uma verdadeira Maravilha , Parabйns.
Reply
#3

rsrs, Obrigado Garfield vocк tambйm й uma Maravilha
Reply
#4

Ae parabens pelo tut era o que faltava aki no sa-mp parabens!!!
sou novato e isso me ajuda muito!!
Reply
#5

Obrigado Sucatiador...
Reply
#6

Ainda йs vivo rei do copy/past? Lol.
Reply
#7

Quote:
Originally Posted by russo666
Посмотреть сообщение
Ainda йs vivo rei do copy/past? Lol.
Russooo Voltou.LOL.
Reply
#8

ae eu nгo intendi como e q usa os codigos de salvar a gang, onde eu coloco eles ?
Reply
#9

Onde Cria a Gang
Reply
#10

Quote:
Originally Posted by [BR]JD
Посмотреть сообщение
ae eu nгo intendi como e q usa os codigos de salvar a gang, onde eu coloco eles ?
OnPlayerCommandText! e as stocks foras de publics
Reply
#11

eu fiz isso mais nгo salvo a gang
Reply
#12

garfild tem como vc colokar esse codigo em fs para mim eu nao sei onde colokar muitas coisas ainda so meio nub
e queria esse codigo pf
Reply
#13

pf post um pastbin desse sistemaa d gang em FS pf
Reply
#14

Eu coloco os dois primeiros codigos, ate ai tudo bem, mas quando coloco o terceiro codigo o pawno aponta alguns erros

pawn Code:
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(106) : error 017: undefined symbol "comandos"
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(106) : error 033: array must be indexed (variable "cmd")
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : error 017: undefined symbol "PlayerInGang"
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : warning 215: expression has no effect
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


6 Errors.
Esses erros entao nesse trecho
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = comandos(cmdtext, idx);
if(strcmp(cmd, "/gangentrar", true) == 0)
  {
if(PlayerInGang[playerid]==0 && gangInvite[playerid] != 0) //Se o Convite for Diferente de '0' que seria a gang padrao  e  ele estiver fora da gang
{
SetPlayerTeam(playerid,gangInvite[playerid]); // coloca na gang como definido anteriormente
SendClientMessage(playerid, 0xFFFFFFFF, "vocк foi entrou na gang");
PlayerInGang[playerid] = GetPlayerTeam(playerid);
gangInvite[playerid] = 0;//Reseta o Convite
}
    return 1;
}
    return 0;
}
o que eu faзo?
Reply
#15

@Cobertozinho Escreve direito sinгo eu nгo ajudo.

@leandro123456 new PlayerInGang[MAX_PLAYERS];
Reply
#16

Tiro so dois erros
pawn Code:
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : error 017: undefined symbol "gangInvite"
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : warning 215: expression has no effect
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Leandro novo\Desktop\Server novo\filterscripts\gangsistema.pwn(109) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Esse o todo o fs
pawn Code:
#include <a_samp>

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#if defined FILTERSCRIPT
#define MAX_GANGS 32
#define MAX_GANG_PLAYERS 16
#define SEM_GANG 0
new gangInvite[MAX_PLAYERS];
new PlayerInGang[MAX_PLAYERS];
new gangMembers[MAX_GANGS][MAX_GANG_PLAYERS];//Array para Enviar Mensagem posteriormente


public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}



public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
new PlayerInGang[MAX_PLAYERS];
if(strcmp(cmd, "/gangentrar", true) == 0)
  {
if(PlayerInGang[playerid]==0 && gangInvite[playerid] != 0)//Se o Convite for Diferente de '0' que seria a gang padrao  e  ele estiver fora da gang
{
SetPlayerTeam(playerid,gangInvite[playerid]); // coloca na gang como definido anteriormente
SendClientMessage(playerid, 0xFFFFFFFF, "vocк foi entrou na gang");
PlayerInGang[playerid] = GetPlayerTeam(playerid);
gangInvite[playerid] = 0;//Reseta o Convite
}
    return 1;
}
    return 0;
}


public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}
e agora, o que eu faзo?
Reply
#17

Leandro123456

Faz o Todo o Tutorial Primeiro depois copila !!!
Reply
#18

Amanha de manhг vou fazer todo o tuto e postar os resultados aqui.
Reply
#19

Legal o Tutorial estб otimo parabйns.
Reply
#20

vou ver se faзo outro mais complexo usando Dini, o que acham?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)