SA-MP Forums Archive
[Ajuda] Problema com sscanf - 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] Problema com sscanf (/showthread.php?tid=509789)



Problema com sscanf - TheIII - 28.04.2014

Boa noite, fiz esse comando de kick e nгo sei o que estб errado, ao meu ver nada.. mesmo eu digitando /kick id motivo ele retorna a mensagem "Use: /kick [id] [motivo]", comecei a usar zcmd e sscanf agora.. :/
Код:
CMD:kick(playerid, params[])
{
	new id, motivo[64];
	GetPlayerName(playerid,pname,sizeof(pname));
	GetPlayerName(id,pname2,sizeof(pname2));
	if(sscanf(params, "us[64]", id,motivo))
	{
	    SendClientMessage(playerid,COR_ERRO,"Use: /kick [id] [motivo]");
	}
	else
	{
	    if(Account[playerid][AdminLVL] < 1)
	    {
            SendClientMessage(playerid,COR_ERRO,"Vocк nгo possui level suficiente de administrador.");
	    }
	    else
	    {
	        if(!IsPlayerConnected(id))
	        {
	            SendClientMessage(playerid,COR_ERRO,"Player nгo conectado.");
	        }
	        else
	        {
				format(pString, sizeof(pString),"** O %s %s(id:%d) kickou o player %s(id:%d)(motivo: %s)!",aLVL[GetAdmin(playerid)],pname,playerid,pname2,id,motivo);
				SendClientMessageToAll(COR_CINZA,pString);
				//Kick(id);
	        }
	    }
	}
	return 1;
}



Re: Problema com sscanf - Fel486 - 28.04.2014

PHP код:
CMD:kick(playeridparams[])
{
    new 
idmotivo[64];
    
GetPlayerName(playerid,pname,sizeof(pname));
    
GetPlayerName(id,pname2,sizeof(pname2));
    if(
sscanf(params"ds[64]"id,motivo))
    {
        
SendClientMessage(playerid,COR_ERRO,"Use: /kick [id] [motivo]");
    }
    else
    {
        if(
Account[playerid][AdminLVL] < 1)
        {
            
SendClientMessage(playerid,COR_ERRO,"Vocк nгo possui level suficiente de administrador.");
        }
        else
        {
            if(!
IsPlayerConnected(id))
            {
                
SendClientMessage(playerid,COR_ERRO,"Player nгo conectado.");
            }
            else
            {
                
format(pStringsizeof(pString),"** O %s %s(id:%d) kickou o player %s(id:%d)(motivo: %s)!",aLVL[GetAdmin(playerid)],pname,playerid,pname2,id,motivo);
                
SendClientMessageToAll(COR_CINZA,pString);
                
//Kick(id);
            
}
        }
    }
    return 
1;




Re: Problema com sscanf - Input - 28.04.2014

pawn Код:
CMD:kick(playerid, params[])
{
    new id, motivo[64];
    if(sscanf(params, "us[64]", id,motivo))
        return SendClientMessage(playerid,COR_ERRO,"Use: /kick [id] [motivo]");
       
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(id,pname2,sizeof(pname2));
   
    if(Account[playerid][AdminLVL] < 1)
        return SendClientMessage(playerid,COR_ERRO,"Vocк nгo possui level suficiente de administrador.");
       
    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid,COR_ERRO,"Player nгo conectado.");
       
    format(pString, sizeof(pString),"** O %s %s(id:%d) kickou o player %s(id:%d)(motivo: %s)!",aLVL[GetAdmin(playerid)],pname,playerid,pname2,id,motivo);
    SendClientMessageToAll(COR_CINZA,pString);
    Kick(id);
    return 1;
}



Re: Problema com sscanf - TheIII - 28.04.2014

Olб, os 2 compilaram.. mas ainda estб a retornar "Use: /kick [id] [motivo]" :/


Re: Problema com sscanf - Input - 28.04.2014

Quote:
Originally Posted by TheIII
Посмотреть сообщение
Olб, os 2 compilaram.. mas ainda estб a retornar "Use: /kick [id] [motivo]" :/
Da uma atualizada no seu sscanf.. Qual versгo vocк utiliza?


Re: Problema com sscanf - DiiMeNoR - 28.04.2014

Tenta ai fera..
pawn Код:
CMD:kick(playerid, params[])
    {
        new id, motivo[64];
        GetPlayerName(playerid,pname,sizeof(pname));
        GetPlayerName(id,pname2,sizeof(pname2));
        if(sscanf(params,"us", id, motivo)) return SendClientMessage(playerid,COR_ERRO,"Use: /kick [id] [motivo]");
        if(Account[playerid][AdminLVL] < 1)
        {
            SendClientMessage(playerid,COR_ERRO,"Vocк nгo possui level suficiente de administrador.");
        }
        else
        {
            if(!IsPlayerConnected(id))
            {
                SendClientMessage(playerid,COR_ERRO,"Player nгo conectado.");
            }
            else
            {
                format(pString, sizeof(pString),"** O %s %s(id:%d) kickou o player %s(id:%d)(motivo: %s)!",aLVL[GetAdmin(playerid)],pname,playerid,pname2,id,motivo);
                SendClientMessageToAll(COR_CINZA,pString);
                //Kick(id);
            }
        }
        return 1;
    }



Re: Problema com sscanf - TheIII - 28.04.2014

Essa: https://sampforum.blast.hk/showthread.php?tid=120356 (2.8.1)
Acabei de atualizar o sscanf e mesmo assim retorna essa mensagem..
Fiz outros comandos hoje com o sscanf e tudo normal.. se eu usar
Quote:

if(sscanf(params, "us", id,motivo))

funciona, sу que sу aparece um caractere no motivo.. :/


Re: Problema com sscanf - TheIII - 28.04.2014

@DiiMeNoR deu certo, +rep .. obg a todos =D
sу mudei de
Quote:

new id, motivo[64];
if(sscanf(params, "us[64]", id,motivo))

para
Quote:

new id, motivo[64];
if(sscanf(params, "us", id,motivo))




Re: Problema com sscanf - Fel486 - 28.04.2014

^^ Nгo faz menor sentido, mas beleza....


Re: Problema com sscanf - TheIII - 28.04.2014

Quote:
Originally Posted by Fel486
Посмотреть сообщение
^^ Nгo faz menor sentido, mas beleza....
Pois й.. nгo entendi tambйm.. kkkk o importante й que tб funcionando.. =D