SA-MP Forums Archive
[Ajuda] /anuncio - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] /anuncio (/showthread.php?tid=287988)



[Ajuda] /anuncio - Don_Speed - 05.10.2011

alguem tem o codigo do /anuncio para me passar nao acho aki no forum!!!


Re: [Ajuda] /anuncio - Jason` - 05.10.2011

pawn Код:
if(strcmp(cmdtext,"/anuncio",true) == 0 || strcmp(cmdtext,"/an",true) == 0)
{
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[256];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
       result[idx - offset] = cmdtext[idx];
          idx++;
    }
    if(!strlen(result))
    {
        SendClientMessage(playerid,BRANCO,"Use /(AN)uncio [Texto]");
    return 1;
    }
    new string[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string,sizeof(string),"[Anъncio]: %s: %s",name,result);
    SendClientMessageToAll(0xFFFFFFAA,string);
    return 1;
}
Ajudei? Reputation


Re: [Ajuda] /anuncio - Don_Speed - 05.10.2011

nao funcionou


Re: [Ajuda] /anuncio - Jason` - 05.10.2011

Qual o erro? Poste aqui que fica mais facil resolver ¬¬


Re: [Ajuda] /anuncio - WLSF - 05.10.2011

pawn Код:
if(!strcmp(cmd,"/anuncio",true))
{
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "(erro): /anuncio [text]");
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
       idx++;
    }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = cmdtext[idx];
        idx++;
    }
    result[idx - offset] = EOS;
    new sStr[120],nome[MAX_PLAYER_NAME];GetPlayerName(playerid,nome,sizeof(nome));
    format(sStr,sizeof(sStr),"Anъncio %s: %s",nome,(result));
    SendClientMessageToAll(-1,sStr);
    return 1;
}



Re: [Ajuda] /anuncio - Jason` - 05.10.2011

Pensei que quando usasse o result como unico parametro n precisasse do tmp.

Que noob eu =/


Re: [Ajuda] /anuncio - WLSF - 05.10.2011

tmp = strtok(cmdtext,idx); й o espaзo que tu usa exemplo:

[ /anuncio ESPAЗO ]

se nгo me engano..