[Ajuda] Verificar uma variбvel que contem letras
#1

pawn Код:
if(Player[playerid][Emprego] != "Nenhum")
Bem, gostaria de verificar se essa vбriavel tem o valor "Nenhum" e nгo o valor "0"
Й possнvel?
Reply
#2

Sim й!
PHP код:
new string[124]
format(stringsizeof(string), "Nenhum");
if(
strcmp(string,Player[playerid][Emprego],false))
{
    
//Nгo й igual
}
else
{
   
//Й igual

Reply
#3

Quote:
Originally Posted by Cheleber_Pausini
Посмотреть сообщение
Sim й!
PHP код:
new string[124]
format(stringsizeof(string), "Nenhum");
if(
strcmp(string,Player[playerid][Emprego],false))
{
    
//Nгo й igual
}
else
{
   
//Й igual

Pra que format ?

PHP код:
if(strcmp("Nenhum"Player[playerid][Emprego], false))
{
    
//Nгo й igual
}
else
{
   
//Й igual

Reply
#4

'-'
para que tanta gambiarra ?

pawn Код:
#define Nenhum 0
#define Gari 1
#define Jubileu 2
Reply
#5

to estudando uma funзгo:
if(strfind(str, "Nenhum", true)) verificar se hб um caractere dentro da string.
Reply
#6

Quote:
Originally Posted by King..
Посмотреть сообщение
'-'
para que tanta gambiarra ?

pawn Код:
#define Nenhum 0
#define Gari 1
#define Jubileu 2
Vocк entendeu errado, se eu quisesse checar se й = 0 eu nгo precisaria definir nenhum = 0, dб na mesma kk, quero checar se a vбriavel carrega o valor "NENHUM".
Reply
#7

PHP код:
if(strcmp("Nenhum"Player[playerid][Emprego], false)) 

    
//Sгo diferentes

else 

    
//Sгo iguais 

strcmp retorna false se for igual e true se for diferente.

se vocк quiser fazer um sistema de empregos, sugiro que use inteiros, faзa por ids, como creio que terб menos de 255 empregos, use char no array para economizar memoria.
Reply
#8

PHP код:
strcmp(const string1[], const string2[], bool:ignorecase=false);
// const string1 comparar se й igual a const string2[]
// bool:ignorecase=false == vocк quer que entre a comparaзгo ignore letras maiъsculas e minuscula. (false == nгo || true == sim). 
nгo sou bom explicando entгo o link da wiki estб abaixo.

https://sampwiki.blast.hk/wiki/Strcmp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)