[Ajuda] Adicionar e subtrair
#1

Ola bom dia.
Vou direto ao assunto Criei um new APolicia cada vez que alguem entra de policia aumenta 2, ai fiz que se ele matar alguem aumentase 5 e se morrese diminuise 3 mas no pego

CODE
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pMorreu] ++;
    PlayerInfo[playerid][pMatou] ++;
    DarGrana(playerid, 100);
    DarScore(playerid, 3);
    TirarScore(killerid, 1);
    TirarGrana(killerid, 50);
   
    if(Gang[playerid]!=Ballas)return ABallas += 5;
    if(Gang[playerid]!=Azteca)return AAzteca += 5;
    if(Gang[playerid]!=Groove)return AGroove += 5;
    if(Gang[playerid]!=Vagos)return AVagos += 5;
    if(Gang[playerid]!=PCC)return APCC += 5;
    if(Gang[playerid]!=CV)return ACV += 5;
    if(Gang[playerid]!=Bikers)return ABikers += 5;
    if(Gang[playerid]!=RussianMafia)return ARussianMafia += 5;
    if(Gang[playerid]!=ItalianMafia)return AItalianMafia += 5;
    if(Gang[playerid]!=Policia)return APolicia += 5;
   
    if(Gang[killerid]!=Ballas)return ABallas -= 3;
    if(Gang[killerid]!=Azteca)return AAzteca -= 3;
    if(Gang[killerid]!=Groove)return AGroove -= 3;
    if(Gang[killerid]!=Vagos)return AVagos -= 3;
    if(Gang[killerid]!=PCC)return APCC -= 3;
    if(Gang[killerid]!=CV)return ACV -= 3;
    if(Gang[killerid]!=Bikers)return ABikers -= 3;
    if(Gang[killerid]!=RussianMafia)return ARussianMafia -= 3;
    if(Gang[killerid]!=ItalianMafia)return AItalianMafia -= 3;
    if(Gang[killerid]!=Policia)return APolicia -= 3;
    return 1;
}
Desde ja Obridago!!!

PS: Ja tentei == e != nenhum deu.
Reply
#2

tipo vc ae esta declarando que ela esta ganhando aonde?

_ 1 o que? + 1

o que
vc fala de score neh
acho que presiзa
de um setscore ae
tem que especificar
Reply
#3

Lembre-se de que a keyword return encerra a execuзгo da funзгo na qual estб .


Este cуdigo deve fazer o que vocк quer :


pawn Код:
if(Gang[killerid] == Policia)   APolicia += 5;
if(Gang[playerid] == Policia)   APolicia -= 3;


Espero ter ajudado .
Reply
#4

Quote:
Originally Posted by rjjj
Посмотреть сообщение
Lembre-se de que a keyword return encerra a execuзгo da funзгo na qual estб .


Este cуdigo deve fazer o que vocк quer :


pawn Код:
if(Gang[killerid] == Policia)   APolicia += 5;
if(Gang[playerid] == Policia)   APolicia -= 3;


Espero ter ajudado .

E msm vlw! vo tenta e ja do edit
Reply
#5

Como o rjjj, Um return diz que nгo й para continuar,Caso tenha algo importante abaixo de todos estes return, no fim da public. Nгo serб executado. pois irб retorna apos chegar em tal ponto.
Reply
#6

[I]Ok consegui agora eu estou tentando criar comandos para fazer coisas em players off mas nao ta pegando pq
pawn Код:
CMD:deletarconta(playerid,params[])
{
   new ID, DName[MAX_PLAYER_NAME];
   if(PlayerInfo[playerid][pAdmin]< 4) return SendClientMessage(playerid,0x8000FFAA,"[ERRO] Voce nao e admin/ ou nivel insuficiente");
   if(sscanf(params, "s",ID))return SendClientMessage(playerid,-1,"[AVISO] /deletarconta [nick]");
   GetPlayerName(ID,DName,sizeof(DName));
   GetPlayerName(playerid,Name,sizeof(Name));
   format(arquivo, sizeof(arquivo), "/Players/%s.ini", ID);
   if(!DOF2_FileExists(arquivo))return SendClientMessage(playerid, -1,"[ERRO] Conta Inexistente");
   DOF2_RemoveFile(arquivo);
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
      if(PlayerInfo[i][pAdmin] > 0)
      {
          format(Don,sizeof(Don),"O Admin %s(ID:%d) deletou a conta %s", Name,playerid,DName);
          SendClientMessageToAll(-1,Don);
      }
   }
   return true;
}[/i]

Reply
#7

Como assim nгo estб pegando?.... acho que vi seu erro....

Sobre a variбvel ID, deveria ser uma string, e no sscanf deve declarar o tamanho da string tambйm, se nгo printarб erros no console.
Reply
#8

pawn Код:
CMD:deletarconta(playerid,params[])
{
    new DName[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin]< 4) return SendClientMessage(playerid,0x8000FFAA,"[ERRO] Voce nao e admin/ ou nivel insuficiente");
    if(sscanf(params, "s[24]",DName))return SendClientMessage(playerid,-1,"[AVISO] /deletarconta [nick]");
    GetPlayerName(playerid,Name,sizeof(Name));
    format(arquivo, sizeof(arquivo), "/Players/%s.ini", DName);
    if(!DOF2_FileExists(arquivo))return SendClientMessage(playerid, -1,"[ERRO] Conta Inexistente");
    DOF2_RemoveFile(arquivo);
    for(new i; i != MAX_PLAYERS; ++i) {
        if(IsPlayerConnected(i)) {
            if(PlayerInfo[i][pAdmin] > 0) {
                format(Don,sizeof(Don),"O Admin %s(ID:%d) deletou a conta %s", Name,playerid,DName);
                SendClientMessage(i,-1,Don);
            }
        }
    }
   return true;
}
Reply
#9

Quote:
Originally Posted by paulor
Посмотреть сообщение
pawn Код:
CMD:deletarconta(playerid,params[])
{
    new DName[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin]< 4) return SendClientMessage(playerid,0x8000FFAA,"[ERRO] Voce nao e admin/ ou nivel insuficiente");
    if(sscanf(params, "s[24]",DName))return SendClientMessage(playerid,-1,"[AVISO] /deletarconta [nick]");
    GetPlayerName(playerid,Name,sizeof(Name));
    format(arquivo, sizeof(arquivo), "/Players/%s.ini", DName);
    if(!DOF2_FileExists(arquivo))return SendClientMessage(playerid, -1,"[ERRO] Conta Inexistente");
    DOF2_RemoveFile(arquivo);
    for(new i; i != MAX_PLAYERS; ++i) {
        if(IsPlayerConnected(i)) {
            if(PlayerInfo[i][pAdmin] > 0) {
                format(Don,sizeof(Don),"O Admin %s(ID:%d) deletou a conta %s", Name,playerid,DName);
                SendClientMessage(i,-1,Don);
            }
        }
    }
   return true;
}

Nao deu tempo de testar tive alguns contra tempo antes de vim para o curso assim que der eu testo.
Reply
#10

Desculpa o double post mas no caso como ficaria este comando eu tentei e ele da aviso


AVISO
pawn Код:
C:\Documents and Settings\Administrador\Desktop\SAMPSERVER\gamemodes\Guerra.pwn(1031) : error 033: array must be indexed (variable "DName")
C:\Documents and Settings\Administrador\Desktop\SAMPSERVER\gamemodes\Guerra.pwn(1033) : error 033: array must be indexed (variable "DName")
C:\Documents and Settings\Administrador\Desktop\SAMPSERVER\gamemodes\Guerra.pwn(1035) : error 033: array must be indexed (variable "DName")
C:\Documents and Settings\Administrador\Desktop\SAMPSERVER\gamemodes\Guerra.pwn(1037) : error 033: array must be indexed (variable "DName")
C:\Documents and Settings\Administrador\Desktop\SAMPSERVER\gamemodes\Guerra.pwn(1039) : error 033: array must be indexed (variable "DName")
C:\Documents and Settings\Administrador\Desktop\SAMPSERVER\gamemodes\Guerra.pwn(1041) : error 033: array must be indexed (variable "DName")

CODE
pawn Код:
CMD:infocontaoff(playerid,params[])
{
   new DName[MAX_PLAYER_NAME], Speed[300];
   if(PlayerInfo[playerid][pAdmin]< 4) return SendClientMessage(playerid,0x8000FFAA,"[ERRO] Voce nao e admin/ ou nivel insuficiente");
   if(sscanf(params, "s[50]",DName))return SendClientMessage(playerid,-1,"[AVISO] /infocontaoff [nick]");
   GetPlayerName(playerid, Name, sizeof(Name));
   format(arquivo, sizeof(arquivo), "/Players/%s.ini", DName);
   if(!DOF2_FileExists(arquivo))return SendClientMessage(playerid, -1,"[ERRO] Conta Inexistente");
   format(Don,sizeof(Don),"|================[ %s ]================|", DName);
   strcat(Don, Speed);
   format(Don,sizeof(Don),"Nivel de Admin : %d",PlayerInfo[DName][pAdmin]);
   strcat(Don, Speed);
   format(Don,sizeof(Don),"Score : %d",PlayerInfo[DName][pScore]);
   strcat(Don, Speed);
   format(Don,sizeof(Don),"Grana : %i",PlayerInfo[DName][pGrana]);
   strcat(Don, Speed);
   format(Don,sizeof(Don),"Matou : %d",PlayerInfo[DName][pMatou]);
   strcat(Don, Speed);
   format(Don,sizeof(Don),"Morreu : %d",PlayerInfo[DName][pMorreu]);
   strcat(Don, Speed);
   format(Don,sizeof(Don),"Logou : %d",PlayerInfo[DName][pLogou]);
   strcat(Don, Speed);
   format(Don,sizeof(Don),"|================[ FIM ]================|");
   strcat(Don, Speed);
   ShowPlayerDialog(playerid, InfoPlayer, DIALOG_STYLE_MSGBOX, "Info Player", Speed, "fechar", "");
   return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)