SA-MP Forums Archive
[Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - 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] Comando Com Espaзo + Sscanf (ZCMD) (/showthread.php?tid=619051)



[Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - WiliHacking - 13.10.2016

E aн galera, й o seguinte, criei um comando cujo tem 3 funзгo: /aluguel desativar /aluguel ativar e /aluguel preco

Ai estб o comando:
PHP код:
CMD:aluguel(playeridparams[])
{
    new 
alug,
    
house GetProxHouse(playerid),
    
FloatXFloatYFloatZ;
    
GetPlayerPos(playeridXYZ);
    if(
IsPlayerInRangeOfPoint(playerid1houseData[house][houseX], houseData[house][houseY], houseData[house][houseZ]))
    {
        if(!
strcmp(params"desativar"true))
        {
              if(
houseData[house][houseRentable] == 0)
             {
                   
SendClientMessage(playeridCOLOR_ERROR"* O aluguel da sua casa jб estб desativado!");
                  
PlayerPlaySound(playerid1085XYZ);
                   return 
1;
               }
            
/*if(strcmp(houseData[house][houseTenant], "Ninguem", false))
               {
                  GetPlayerPos(playerid, X, Y, Z);
                  PlayerPlaySound(playerid, 1085, X, Y, Z);
                 SendClientMessage(playerid, COLOR_ERROR, "* Nгo й possнvel desativar o aluguel com alguйm alugando sua casa.");
                   TogglePlayerControllable(playerid, 1);
                 return 1;
            }*/
            
houseData[house][houseRentable] = 0;
               
Update3DText(house);
              
SendClientMessage(playeridCOLOR_SUCCESS"* Aluguel desativado com sucesso.");
           }
        if(!
strcmp(params"ativar"true))
        {
              if(
houseData[house][houseRentable] == 1)
            {
                   
SendClientMessage(playeridCOLOR_ERROR"* O aluguel da sua casa jб estб ativado!");
                   
PlayerPlaySound(playerid1085XYZ);
                  return 
1;
               }
            
houseData[house][houseRentable] = 1;
            
            
Update3DText(house);
            
SendClientMessage(playeridCOLOR_SUCCESS"* Aluguel ativado com sucesso.");
           }
        if(!
strcmp(params"preco"true))
        {
            if(
sscanf(params"d"alug))
            {
                
SendClientMessage(playerid0xBFC0C2FF"USE: /aluguel preco [valor]");
                return 
true;
            }
            if(
alug || alug 900)
            {
                
SendClientMessage(playerid0xBFC0C2FF"Preзo Mнnimo $1, Mбximo R$900.");
                return 
true;
            }
            new 
string[128];
            
houseData[house][houseRentPrice] = alug;
              
Update3DText(house);
            
format(stringsizeof(string), "Aluguel definido para: $%d"houseData[house][houseRentPrice]);
            
SendClientMessage(playerid0xFFFFFFFFstring);
        }
    }
    return 
1;

Estб funcionando de boas, pelo menos os 2 primeiros, desativar e ativar, porйm o preзo nгo estб dando, tipo, eu digito /aluguel preco [valor] e nгo vai, acho que estou fazendo alguma coisa errada, ajuda ae pfv

OBS: Uso sscanf2


Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - RedMF - 13.10.2016

Tenta
PHP код:
CMD:aluguel(playeridparams[]) 

    new 
alug
    
house GetProxHouse(playerid), 
    
FloatXFloatYFloatZ
    
GetPlayerPos(playeridXYZ); 
    if(
IsPlayerInRangeOfPoint(playerid1houseData[house][houseX], houseData[house][houseY], houseData[house][houseZ])) 
    { 
        if(!
strcmp(params"desativar"true)) 
        { 
              if(
houseData[house][houseRentable] == 0
             { 
                   
SendClientMessage(playeridCOLOR_ERROR"* O aluguel da sua casa jб estб desativado!"); 
                  
PlayerPlaySound(playerid1085XYZ); 
                   return 
1
               } 
            
/*if(strcmp(houseData[house][houseTenant], "Ninguem", false)) 
               { 
                  GetPlayerPos(playerid, X, Y, Z); 
                  PlayerPlaySound(playerid, 1085, X, Y, Z); 
                 SendClientMessage(playerid, COLOR_ERROR, "* Nгo й possнvel desativar o aluguel com alguйm alugando sua casa."); 
                   TogglePlayerControllable(playerid, 1); 
                 return 1; 
            }*/ 
            
houseData[house][houseRentable] = 0
               
Update3DText(house); 
              
SendClientMessage(playeridCOLOR_SUCCESS"* Aluguel desativado com sucesso."); 
           } 
        if(!
strcmp(params"ativar"true)) 
        { 
              if(
houseData[house][houseRentable] == 1
            { 
                   
SendClientMessage(playeridCOLOR_ERROR"* O aluguel da sua casa jб estб ativado!"); 
                   
PlayerPlaySound(playerid1085XYZ); 
                  return 
1
               } 
            
houseData[house][houseRentable] = 1
             
            
Update3DText(house); 
            
SendClientMessage(playeridCOLOR_SUCCESS"* Aluguel ativado com sucesso."); 
           } 
        if(!
strcmp(params"preco"true)) 
        { 
            if(
sscanf(params"u"alug)) 
            { 
                
SendClientMessage(playerid0xBFC0C2FF"USE: /aluguel preco [valor]"); 
                return 
true
            } 
            if(
alug || alug 900
            { 
                
SendClientMessage(playerid0xBFC0C2FF"Preзo Mнnimo $1, Mбximo R$900."); 
                return 
true
            } 
            new 
string[128]; 
              
Update3DText(house); 
            
format(stringsizeof(string), "Aluguel definido para: $%d"alug); 
            
SendClientMessage(playerid0xFFFFFFFFstring); 
            
houseData[house][houseRentPrice] = alug;
        } 
    } 
    return 
1




Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - WiliHacking - 13.10.2016

Quote:

Tenta
PHP Code:
CMD:aluguel(playerid, params[])
{
new alug,
house = GetProxHouse(playerid),
Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);

if(IsPlayerInRangeOfPoint(playerid, 1, houseData[house][houseX], houseData[house][houseY], houseData[house][houseZ]))
{
if(!strcmp(params, "desativar", true))
{
if(houseData[house][houseRentable] == 0)
{
SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб desativado!");
PlayerPlaySound(playerid, 1085, X, Y, Z);
return 1;
}

/*if(strcmp(houseData[house][houseTenant], "Ninguem", false))
{
GetPlayerPos(playerid, X, Y, Z);
PlayerPlaySound(playerid, 1085, X, Y, Z);
SendClientMessage(playerid, COLOR_ERROR, "* Nгo й possнvel desativar o aluguel com alguйm alugando sua casa.");
TogglePlayerControllable(playerid, 1);
return 1;
}*/

houseData[house][houseRentable] = 0;
Update3DText(house);
SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel desativado com sucesso.");
}
if(!strcmp(params, "ativar", true))
{
if(houseData[house][houseRentable] == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб ativado!");
PlayerPlaySound(playerid, 1085, X, Y, Z);
return 1;
}
houseData[house][houseRentable] = 1;

Update3DText(house);
SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel ativado com sucesso.");
}
if(!strcmp(params, "preco", true))
{
if(sscanf(params, "u", alug))
{
SendClientMessage(playerid, 0xBFC0C2FF, "USE: /aluguel preco [valor]");
return true;
}
if(alug < 1 || alug > 900)
{
SendClientMessage(playerid, 0xBFC0C2FF, "Preзo Mнnimo $1, Mбximo R$900.");
return true;
}
new string[128];
Update3DText(house);
format(string, sizeof(string), "Aluguel definido para: $%d", alug);
SendClientMessage(playerid, 0xFFFFFFFF, string);
houseData[house][houseRentPrice] = alug;
}
}
return 1;
}

Nгo deu certo nгo mano, quando eu digito "/aluguel preco" aparece essa mensagem ("Preзo Mнnimo $1, Mбximo R$900.") e quando eu digito "/aluguel preco 100" nгo aparece nada.


Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - WiliHacking - 13.10.2016

Ajuda ae galera


Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - RodrigoMSR - 13.10.2016

Tente:
Код:
CMD:aluguel(playerid, params[])
{
    new alug,
    house = GetProxHouse(playerid),
    Float: X, Float: Y, Float: Z;
    GetPlayerPos(playerid, X, Y, Z);

    if(IsPlayerInRangeOfPoint(playerid, 1, houseData[house][houseX], houseData[house][houseY], houseData[house][houseZ]))
    {
        if(strfind(params, "desativar", true) != -1)
        {
              if(houseData[house][houseRentable] == 0)
             {
                   SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб desativado!");
                  PlayerPlaySound(playerid, 1085, X, Y, Z);
                   return 1;
               }

            /*if(strcmp(houseData[house][houseTenant], "Ninguem", false))
               {
                  GetPlayerPos(playerid, X, Y, Z);
                  PlayerPlaySound(playerid, 1085, X, Y, Z);
                 SendClientMessage(playerid, COLOR_ERROR, "* Nгo й possнvel desativar o aluguel com alguйm alugando sua casa.");
                   TogglePlayerControllable(playerid, 1);
                 return 1;
            }*/

            houseData[house][houseRentable] = 0;
               Update3DText(house);
              SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel desativado com sucesso.");
           }
        else if(strfind(params, "ativar", true) != -1)
        {
              if(houseData[house][houseRentable] == 1)
            {
                   SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб ativado!");
                   PlayerPlaySound(playerid, 1085, X, Y, Z);
                  return 1;
               }
            houseData[house][houseRentable] = 1;

            Update3DText(house);
            SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel ativado com sucesso.");
           }
        else if(strfind(params, "preco", true) != -1)
        {
            if(sscanf(params[6], "d", alug))
            {
                SendClientMessage(playerid, 0xBFC0C2FF, "USE: /aluguel preco [valor]");
                return true;
            }
            if(alug < 1 || alug > 900)
            {
                SendClientMessage(playerid, 0xBFC0C2FF, "Preзo Mнnimo $1, Mбximo R$900.");
                return true;
            }
            new string[128];
            houseData[house][houseRentPrice] = alug;
              Update3DText(house);
            format(string, sizeof(string), "Aluguel definido para: $%d", houseData[house][houseRentPrice]);
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}



Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - WiliHacking - 13.10.2016

Vlws mano, deu certinho, brigadгo


Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - WiliHacking - 13.10.2016

Mano, como eu faзo pra quando o player digita sу /aluguel aparecer uma mensagem igual essa que vocк coloco >> "USE: /aluguel preco [valor]"


Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - RodrigoMSR - 13.10.2016

Quote:
Originally Posted by WiliHacking
Посмотреть сообщение
Mano, como eu faзo pra quando o player digita sу /aluguel aparecer uma mensagem igual essa que vocк coloco >> "USE: /aluguel preco [valor]"
Adicionando mais um else, sу quem sem if:
Код:
CMD:aluguel(playerid, params[])
{
    new alug,
    house = GetProxHouse(playerid),
    Float: X, Float: Y, Float: Z;
    GetPlayerPos(playerid, X, Y, Z);

    if(IsPlayerInRangeOfPoint(playerid, 1, houseData[house][houseX], houseData[house][houseY], houseData[house][houseZ]))
    {
        if(strfind(params, "desativar", true) != -1)
        {
              if(houseData[house][houseRentable] == 0)
             {
                   SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб desativado!");
                  PlayerPlaySound(playerid, 1085, X, Y, Z);
                   return 1;
               }

            /*if(strcmp(houseData[house][houseTenant], "Ninguem", false))
               {
                  GetPlayerPos(playerid, X, Y, Z);
                  PlayerPlaySound(playerid, 1085, X, Y, Z);
                 SendClientMessage(playerid, COLOR_ERROR, "* Nгo й possнvel desativar o aluguel com alguйm alugando sua casa.");
                   TogglePlayerControllable(playerid, 1);
                 return 1;
            }*/

            houseData[house][houseRentable] = 0;
               Update3DText(house);
              SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel desativado com sucesso.");
           }
        else if(strfind(params, "ativar", true) != -1)
        {
              if(houseData[house][houseRentable] == 1)
            {
                   SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб ativado!");
                   PlayerPlaySound(playerid, 1085, X, Y, Z);
                  return 1;
               }
            houseData[house][houseRentable] = 1;

            Update3DText(house);
            SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel ativado com sucesso.");
           }
        else if(strfind(params, "preco", true) != -1)
        {
            if(sscanf(params[6], "d", alug))
            {
                SendClientMessage(playerid, 0xBFC0C2FF, "USE: /aluguel preco [valor]");
                return true;
            }
            if(alug < 1 || alug > 900)
            {
                SendClientMessage(playerid, 0xBFC0C2FF, "Preзo Mнnimo $1, Mбximo R$900.");
                return true;
            }
            new string[128];
            houseData[house][houseRentPrice] = alug;
              Update3DText(house);
            format(string, sizeof(string), "Aluguel definido para: $%d", houseData[house][houseRentPrice]);
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
        else SendClientMessage(playerid, 0xBFC0C2FF, "USE: /aluguel [ativar/desativar/preco]");
    }
    return 1;
}



Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - WiliHacking - 13.10.2016

Mano, nгo deu certo, quando eu digito /aluguel aparece a mensagem de erro quando digita um comando errado, esse sistema estб em FS, serб que й isso?

@edit Sу estб aparecendo a mensagem que vocк coloco no else quando estб perto da casa


Re: [Ajuda] Comando Com Espaзo + Sscanf (ZCMD) - RodrigoMSR - 14.10.2016

Код:
CMD:aluguel(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, 0xBFC0C2FF, "USE: /aluguel [ativar/desativar/preco]");
    new alug,
    house = GetProxHouse(playerid),
    Float: X, Float: Y, Float: Z;
    GetPlayerPos(playerid, X, Y, Z);

    if(IsPlayerInRangeOfPoint(playerid, 1, houseData[house][houseX], houseData[house][houseY], houseData[house][houseZ]))
    {
        if(strfind(params, "desativar", true) != -1)
        {
              if(houseData[house][houseRentable] == 0)
             {
                   SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб desativado!");
                  PlayerPlaySound(playerid, 1085, X, Y, Z);
                   return 1;
               }

            /*if(strcmp(houseData[house][houseTenant], "Ninguem", false))
               {
                  GetPlayerPos(playerid, X, Y, Z);
                  PlayerPlaySound(playerid, 1085, X, Y, Z);
                 SendClientMessage(playerid, COLOR_ERROR, "* Nгo й possнvel desativar o aluguel com alguйm alugando sua casa.");
                   TogglePlayerControllable(playerid, 1);
                 return 1;
            }*/

            houseData[house][houseRentable] = 0;
               Update3DText(house);
              SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel desativado com sucesso.");
           }
        else if(strfind(params, "ativar", true) != -1)
        {
              if(houseData[house][houseRentable] == 1)
            {
                   SendClientMessage(playerid, COLOR_ERROR, "* O aluguel da sua casa jб estб ativado!");
                   PlayerPlaySound(playerid, 1085, X, Y, Z);
                  return 1;
               }
            houseData[house][houseRentable] = 1;

            Update3DText(house);
            SendClientMessage(playerid, COLOR_SUCCESS, "* Aluguel ativado com sucesso.");
           }
        else if(strfind(params, "preco", true) != -1)
        {
            if(sscanf(params[6], "d", alug))
            {
                SendClientMessage(playerid, 0xBFC0C2FF, "USE: /aluguel preco [valor]");
                return true;
            }
            if(alug < 1 || alug > 900)
            {
                SendClientMessage(playerid, 0xBFC0C2FF, "Preзo Mнnimo $1, Mбximo R$900.");
                return true;
            }
            new string[128];
            houseData[house][houseRentPrice] = alug;
              Update3DText(house);
            format(string, sizeof(string), "Aluguel definido para: $%d", houseData[house][houseRentPrice]);
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
        else SendClientMessage(playerid, 0xBFC0C2FF, "USE: /aluguel [ativar/desativar/preco]");
    }
    else SendClientMessage(playerid, 0xBFC0C2FF, "ERRO: Vocк nгo estб perto da casa");
    return 1;
}