SA-MP Forums Archive
[Ajuda] Funзгo - 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] Funзгo (/showthread.php?tid=527717)



Funзгo - BrunoPasqualini - 24.07.2014

Fiz essa funзгo pra verificar se a string passada estб vazia, porйm sу retorna se tiver mais que dois espaзos, se tiver um espaзo diz que nгo estб em branco. Tambйm queria saber se tem como usar o foreach em strings pois nгo consegui. Alйm disso quando eu uso SendClientMessageToAll(-1, txt[i]) imprimi o que veio no txt e nгo a posiзгo da iteraзгo no for.

pawn Код:
stock emBranco(txt[]){
    if(strlen(txt) == 0) return true;
    for(new i = 0; i < strlen(txt); i++){
        if(strcmp(txt[i]," ")){
            return true;
        }
    }
    return false;
}



Re: Funзгo - zSuYaNw - 24.07.2014

pawn Код:
stock emBranco(txt[]){
    if(!strlen(txt) || txt[0] == '\0'){
        return 1;
    }
   
    for(new i = 0, e = strlen(txt); i < e; i++){
        if(txt[i] != ' '{
            return false;
        }
    }
    return true;
}



Re: Funзгo - PT - 24.07.2014

isso tbm daria

pawn Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif



Re: Funзгo - BrunoPasqualini - 24.07.2014

Arrumei:
pawn Код:
stock emBranco(txt[]){
    if(strlen(txt) == 0) return true;
    for(new i = 0; i < strlen(txt); i++){
        if(strcmp(txt[i]," ",false,1) == 0){
            return true;
        }
    }
    return false;
}