[PEDIDO] Funзгo SendClientMessage com suporte para parametros
#1

Olб Comunidade SA:MP,


Nгo se existe, entгo queria fazer um pedido, uma funзгo onde eu possa usar assim:
pawn Код:
SendClientMessageEx(playerid, COR, "* %s ... %d...%.4f...",Nome, Integer, Float);
Tentei fazer mas nгo sei fazer o sistema de por os parametros, do jeito que eu ia fazer nгo ia ficar muito bom...



Humildemente agradecido.
Reply
#2

Nгo entendi bem, poderia explicar melhor?
Reply
#3

pawn Код:
stock SendClientMessageEx(playerid,color,type[],{Float,_}:...)
{
        new string[128];
        for(new i = 0;i<numargs() -2;i++)
        {
            switch(type[i])
            {
                case 's':
                {
                                new result[128];
                                for(new a= 0;getarg(i +3,a) != 0;a++)
                                {
                                    result[a] = getarg(i +3,a);
                                }
                                if(!strlen(string))
                                {
                                    format(string,sizeof string,"%s",result);
                                } else format(string,sizeof string,"%s%s",string,result);
                }
 
                case 'i':
                {
                    new result = getarg(i +3);
                                if(!strlen(string))
                                {
                                    format(string,sizeof string,"%i",result);
                                } else format(string,sizeof string,"%s%i",string,result);
                }
 
                case 'f':
                {
                                new Float:result = Float:getarg(i +3);
                                if(!strlen(string))
                                {
                                    format(string,sizeof string,"%f",result);
                                } else format(string,sizeof string,"%s%f",string,result);
                }
            }
        }
    SendClientMessage(playerid,color,string);
    return 1;
}
Fonte: https://sampforum.blast.hk/showthread.php?tid=144744&page=48
Reply
#4

enviar a mensagem sem precisar usar format...


exemplo:
pawn Код:
SendClientMessage(playerid, COR, "%d bem vindo ao servidor",nome(playerid));
entendeu?
Reply
#5

Acho que seria algo do tipo

pawn Код:
SendClientMessageEx(playerid, cor, string[], int, Float:float)
{
}
Reply
#6

Quote:
Originally Posted by [O.z]Caroline
Посмотреть сообщение
pawn Код:
stock SendClientMessageEx(playerid,color,type[],{Float,_}:...)
{
        new string[128];
        for(new i = 0;i<numargs() -2;i++)
        {
            switch(type[i])
            {
                case 's':
                {
                                new result[128];
                                for(new a= 0;getarg(i +3,a) != 0;a++)
                                {
                                    result[a] = getarg(i +3,a);
                                }
                                if(!strlen(string))
                                {
                                    format(string,sizeof string,"%s",result);
                                } else format(string,sizeof string,"%s%s",string,result);
                }
 
                case 'i':
                {
                    new result = getarg(i +3);
                                if(!strlen(string))
                                {
                                    format(string,sizeof string,"%i",result);
                                } else format(string,sizeof string,"%s%i",string,result);
                }
 
                case 'f':
                {
                                new Float:result = Float:getarg(i +3);
                                if(!strlen(string))
                                {
                                    format(string,sizeof string,"%f",result);
                                } else format(string,sizeof string,"%s%f",string,result);
                }
            }
        }
    SendClientMessage(playerid,color,string);
    return 1;
}
Fonte: https://sampforum.blast.hk/showthread.php?tid=144744&page=48
Valeu Carol, vou testar aqui...
Reply
#7

Olha meu post ali ...
Reply
#8

cara usa o format
Reply
#9

Quote:
Originally Posted by [O.z]Caroline
Посмотреть сообщение
Olha meu post ali ...
Nгo deu muito certo, ele envia uma messagem em branco...como se o nao tivesse formatado a string...
Reply
#10

Use um macro:

pawn Код:
#define SendClientMessageEx(%0,%1,%2,%3) format(%2, sizeof(%2), %3); \
SendClientMessage(%0, %1, %2)
Feito por Shelby
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)