[AYUDA]Con %s
#1

Hola, bueno mi problema es que yo tengo esto asi
pawn Код:
if(strcmp(cmd, "/prueba", true) == 0)
    {
            new string[256];
            new idx;
            new tmp[256];
            tmp = strtok(cmdtext, idx);
           
            if(!strlen(tmp))
            {
            new precio = strval(tmp);
            format(string,sizeof(string),"%s, %d",cmdtext,precio);
            SendClientMessage(playerid,COLOR_BLANCO,string);
            SaveIn("property",string);
            return 1;
            }
    return 1;
    }
Yo quiero que salga un texto,nъmero ejemplo Forum Samp,4051 pero en ves de salir con la , sale Forum Samp 4051,0 toma todo en el %s y en el de los nъmeros %d lo deja en 0 como puedo solucionar este problema??


Gracias de ante mano
Reply
#2

Aquн te dejo un comando de ejemplo:

pawn Код:
if(!strcmp(cmd, "/prueba", true))
    {
            new Texto[128], Numero[128];
            Texto = strtok(cmdtext,idx);
            Numero = strtok(cmdtext,idx);
            new precio = strval(Numero);
            if(!strlen(Texto) || !IsNumeric2(Numero)) return SendClientMessage(playerid, Rojo, "Usу: /prueba [texto] [nъmero]"); // aqui hace una restriccion si no se escribio nada, y el de IsNumeric2 chequea si es un numero, si no es un numero le manda el mismo texto
            format(Texto, sizeof(Texto), "%s, %d",Texto, precio);
            SendClientMessage(playerid,Blanco, Texto);
            return 1;
    }
para definir IsNumeric2

pawn Код:
IsNumeric2(const string[])
{
    // Is Numeric Check 2
    // ------------------
    // By DracoBlue... handles negative numbers

    new length=strlen(string);
    if (length==0) return false;
    for (new i = 0; i < length; i++)
    {
      if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.') // Not a number,'+' or '-' or '.'
             || (string[i]=='-' && i!=0)                                             // A '-' but not first char.
             || (string[i]=='+' && i!=0)                                             // A '+' but not first char.
         ) return false;
    }
    if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
    return true;
}
Reply
#3

Gracias +1 por ayudarme me funciono

EDIT: Dame el enlace donde te tengo que dar reputaciуn
Reply
#4

http://forum.sa-mp.com/reputation.php?p=1569769
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)