SA-MP Forums Archive
[Ajuda] Anъncio cobra o dinheiro mais nгo vai a mensagem - 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] Anъncio cobra o dinheiro mais nгo vai a mensagem (/showthread.php?tid=569300)



Anъncio cobra o dinheiro mais nгo vai a mensagem - MarlboroBr - 29.03.2015

Pessoal, й o seguinte, o anъncio quando estб muito grande, gasta 300 reais da pessoa mais nгo envia nada. Entгo eu fui e adicionei um cуdigo para limitar a quantidade de caracteres, porem ele nгo estб funcionando. Me ajudem com isso por favor:

PHP код:
if( !strcmp( cmd, "/An", true ))
{
    if( 
pInfo[ playerid ][ Level ] < 5 )
    {
        
SendClientMessage( playerid, COLOR_ERRO, "[ x ] Vocк sу pode enviar um anuncio global com level 5 ou superior !" );
        return 
1;
    }
    if( 
viwerAN[ playerid ] > gettime( ))
    {
        
format( gStr, sizeof( gStr ), "[ x ] Aguarde %d segundos para fazer um novo anъncio !", viwerAN[ playerid ] - gettime( ));
        
SendClientMessage( playerid, COLOR_ERRO, gStr );
        return 
1;
    }
    if( 
GetPlayerCash( playerid ) < 300 )
    {
        
SendClientMessage( playerid, COLOR_ERRO, "[ x ] Vocк nгo tem dinheiro suficiente para fazer um anъncio ! ( Preзo: $300 )" );
        return 
1;
    }
    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;
    if( !
strlen( result ))
    {
        
SendClientMessage( playerid, COLOR_ERRO, "[ x ] Uso correto: /An [ Mensagem ]" );
        return 
1;
    }
    if( 
strlen( result ) > 60 )
    {
        
SendClientMessage( playerid, COLOR_ERRO, "[ x ] Anъncio muito grande, envie um anъncio de no mбximo 60 caracteres !" );
        return 
1;
    }
    new
    
viewer[ 512 ]
    ;
    
format( viewer, sizeof( viewer ), "{FFFAFA}ANЪNCIO: {00FF00}%s{FFFAFA} anuncia: {A9A9A9}%s {FFFAFA}- Contato: {A9A9A9}/SMS %d", PlayerName( playerid ), result, playerid );
    
SendClientMessageToAll( COLOR_BRANCO, viewer );
    
viwerAN[ playerid ] = gettime( ) + 120;
    
sGivePlayerCash( playerid, -300 );
    return 
1;
} 



Re: Anъncio cobra o dinheiro mais nгo vai a mensagem - willttoonn - 29.03.2015

Jб tentou trocar o SendClientMessageToAll por um loop em todos os players?


Re: Anъncio cobra o dinheiro mais nгo vai a mensagem - MarlboroBr - 29.03.2015

Nгo deu certo nгo man...


Re: Anъncio cobra o dinheiro mais nгo vai a mensagem - MarlboroBr - 30.03.2015

up !


Re: Anъncio cobra o dinheiro mais nгo vai a mensagem - Fel486 - 30.03.2015

Realmente assim com Strcmp e Strtok fica complicado. Uma maneira mais fбcil й utilizando ZCMD e SSCANF.

Aqui um exemplo simples que resolveria seu problema

pawn Код:
CMD:teste(playerid, params[])
{
    new texto[50]; // Parametro recebido (string).

    new string[100]; // Texto para format
   
    if(sscanf(params, "s[50]", texto)) return SendClientMessage(playerid, -1, "Comando errado.");

    format(str, sizeof(str), "Texto: %s, Length: %d", texto, strlen(texto)); // Mostrando o texto e seu tamanho.
   
    if(strlen(texto) > LIMITE)
    {
        // ... Aзгo
    }
   
    SendClientMessage(playerid, -1, str); // Enviando mensagem formatada.
   
    return 1;
}




Re: Anъncio cobra o dinheiro mais nгo vai a mensagem - ipsLuan - 31.03.2015

Como falaram, faзa os teus comandos com o uso de ZCMD, fica mais fбcil e mais rбpido.

Abraзos,


Re: Anъncio cobra o dinheiro mais nгo vai a mensagem - MarlboroBr - 01.04.2015

Fiz isso. Resolvido !
Obrigado !

+Rep para quem nгo tinha dado antes !