SA-MP Forums Archive
[AJUDA] inputtext - 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] inputtext (/showthread.php?tid=348483)



[AJUDA] inputtext - EditPawn - 05.06.2012

Bom, queria saber como que faзo pra arrumar esse sistema que fiz de comprar armas....
pois quando eu vou comprar, e digito Ex: 10 muniзoes, vem sу 2 municoes reais com a arma e cobra o preзo por 10 municoes....

Queria saber se com a inputtext sу poderia ser digitado NUMEROS!
e como eu faria isso ?

Cуdigo:
pawn Код:
if(dialogid == DIALOG_MUNICOES)
    {
        if(!response) return ShowPlayerDialog(playerid, DIALOG_COMPRARARMA, DIALOG_STYLE_LIST, "|_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______[ Loja de Armas ]_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______|", "Kit Vip\nSoco-Inglкs\nFaca\nTaco de Baseball\nGranada de Mгo\nGranada de Gбs\nDesert Eagle\nShotGun\nMp5\nAK-47\nColt M4a1\nSniper\nParaquedas", "Selecionar", "Sair");
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_MUNICOES, DIALOG_STYLE_INPUT, "|_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______[ Muniзхes ]_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______|", "Digite quantas muniзхes vocк deseja comprar!", "Confirmar", "Voltar");
        new guncharge, ammocharge, mod = 100, ammo = inputtext, location = PlayerInfo[playerid][pLocal];
        if(ammo < 1 || ammo > 999) return SendClientMessage(playerid, COLOR_GREY, "Muniзгo tem que ser entre 1 e 999 !");
        if(ArmaID == 1) ArmaID = 1, guncharge = GunPrice[1][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 4) ArmaID = 4, guncharge = GunPrice[3][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 5) ArmaID = 5, guncharge = GunPrice[1][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 16) ArmaID = 16, guncharge = GunPrice[4][0]/100*mod, ammocharge = GunPrice[17][0]/100*ammo;
        else if(ArmaID == 17) ArmaID = 17, guncharge = GunPrice[4][0]/100*mod, ammocharge = GunPrice[15][0]/100*ammo;
        else if(ArmaID == 24) ArmaID = 24, guncharge = GunPrice[15][0]/100*mod, ammocharge = GunPrice[25][0]*ammo;
        else if(ArmaID == 25) ArmaID = 25, guncharge = GunPrice[19][0]/100*mod, ammocharge = GunPrice[26][0]*ammo;
        else if(ArmaID == 29) ArmaID = 29, guncharge = GunPrice[18][0]/100*mod, ammocharge = GunPrice[27][0]*ammo;
        else if(ArmaID == 30) ArmaID = 30, guncharge = GunPrice[22][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 31) ArmaID = 31, guncharge = GunPrice[23][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 34) ArmaID = 34, guncharge = GunPrice[24][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 46) ArmaID = 46, guncharge = GunPrice[0][0]/100*mod, ammocharge = 0;
        if((guncharge+ammocharge) > GetPlayerMoney(playerid))
        {
            format(Str, sizeof(Str), "Vocк nгo tem R$%d para pagar !", guncharge+ammocharge);
            SendClientMessage(playerid, COLOR_GRAD3, Str);
            return 1;
        }
        new payout = guncharge + ammocharge;
        if(location != 102 && !IsACop(playerid)) GivePlayerMoney(playerid, - payout);
        BizzInfo[location-99][bTill] += payout;
        ExtortionBiz(location-99, payout);
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        GivePlayerWeapon(playerid, ArmaID, ammo);
        format(Str, sizeof(Str), "Vocк comprou um(a) %s com %d bala(s) por R$%d", ArmaID, ammo, payout);
        SendClientMessage(playerid, COLOR_GRAD3, Str);
        format(Str, sizeof(Str), "%s comprou armas por R$%d na empresa %d", PlayerName(playerid), payout, location-99);
        printf(Str);
        TAInfo[playerid][PLojaA1] = 0;
        TAInfo[playerid][PLojaA2] = 0;
        TAInfo[playerid][ArmaLoja] = 0;
    }



Respuesta: [AJUDA] inputtext - CidadeNovaRP - 05.06.2012

Tente:
pawn Код:
if(dialogid == DIALOG_MUNICOES)
    {
        if(!response) return ShowPlayerDialog(playerid, DIALOG_COMPRARARMA, DIALOG_STYLE_LIST, "|_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______[ Loja de Armas ]_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______|", "Kit Vip\nSoco-Inglкs\nFaca\nTaco de Baseball\nGranada de Mгo\nGranada de Gбs\nDesert Eagle\nShotGun\nMp5\nAK-47\nColt M4a1\nSniper\nParaquedas", "Selecionar", "Sair");
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_MUNICOES, DIALOG_STYLE_INPUT, "|_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______[ Muniзхes ]_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______|", "Digite quantas muniзхes vocк deseja comprar!", "Confirmar", "Voltar");
        new guncharge, ammocharge, mod = 100, ammo = strval(inputtext), location = PlayerInfo[playerid][pLocal];
        if(ammo < 1 || ammo > 999) return SendClientMessage(playerid, COLOR_GREY, "Muniзгo tem que ser entre 1 e 999 !");
        if(ArmaID == 1) ArmaID = 1, guncharge = GunPrice[1][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 4) ArmaID = 4, guncharge = GunPrice[3][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 5) ArmaID = 5, guncharge = GunPrice[1][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 16) ArmaID = 16, guncharge = GunPrice[4][0]/100*mod, ammocharge = GunPrice[17][0]/100*ammo;
        else if(ArmaID == 17) ArmaID = 17, guncharge = GunPrice[4][0]/100*mod, ammocharge = GunPrice[15][0]/100*ammo;
        else if(ArmaID == 24) ArmaID = 24, guncharge = GunPrice[15][0]/100*mod, ammocharge = GunPrice[25][0]*ammo;
        else if(ArmaID == 25) ArmaID = 25, guncharge = GunPrice[19][0]/100*mod, ammocharge = GunPrice[26][0]*ammo;
        else if(ArmaID == 29) ArmaID = 29, guncharge = GunPrice[18][0]/100*mod, ammocharge = GunPrice[27][0]*ammo;
        else if(ArmaID == 30) ArmaID = 30, guncharge = GunPrice[22][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 31) ArmaID = 31, guncharge = GunPrice[23][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 34) ArmaID = 34, guncharge = GunPrice[24][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 46) ArmaID = 46, guncharge = GunPrice[0][0]/100*mod, ammocharge = 0;
        if((guncharge+ammocharge) > GetPlayerMoney(playerid))
        {
            format(Str, sizeof(Str), "Vocк nгo tem R$%d para pagar !", guncharge+ammocharge);
            SendClientMessage(playerid, COLOR_GRAD3, Str);
            return 1;
        }
        new payout = guncharge + ammocharge;
        if(location != 102 && !IsACop(playerid)) GivePlayerMoney(playerid, - payout);
        BizzInfo[location-99][bTill] += payout;
        ExtortionBiz(location-99, payout);
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        GivePlayerWeapon(playerid, ArmaID, ammo);
        format(Str, sizeof(Str), "Vocк comprou um(a) %s com %d bala(s) por R$%d", ArmaID, ammo, payout);
        SendClientMessage(playerid, COLOR_GRAD3, Str);
        format(Str, sizeof(Str), "%s comprou armas por R$%d na empresa %d", PlayerName(playerid), payout, location-99);
        printf(Str);
        TAInfo[playerid][PLojaA1] = 0;
        TAInfo[playerid][PLojaA2] = 0;
        TAInfo[playerid][ArmaLoja] = 0;
    }



Re: [AJUDA] inputtext - paulor - 05.06.2012

Код:
new guncharge, ammocharge, mod = 100, ammo = strval(inputtext), location = PlayerInfo[playerid][pLocal];



Re: Respuesta: [AJUDA] inputtext - EditPawn - 05.06.2012

Quote:
Originally Posted by CidadeNovaRP
Посмотреть сообщение
Tente:
pawn Код:
if(dialogid == DIALOG_MUNICOES)
    {
        if(!response) return ShowPlayerDialog(playerid, DIALOG_COMPRARARMA, DIALOG_STYLE_LIST, "|_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______[ Loja de Armas ]_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______|", "Kit Vip\nSoco-Inglкs\nFaca\nTaco de Baseball\nGranada de Mгo\nGranada de Gбs\nDesert Eagle\nShotGun\nMp5\nAK-47\nColt M4a1\nSniper\nParaquedas", "Selecionar", "Sair");
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_MUNICOES, DIALOG_STYLE_INPUT, "|_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______[ Muniзхes ]_______{00FF00}B{FFFF00}L{0000FF}G{FFFFFF}_______|", "Digite quantas muniзхes vocк deseja comprar!", "Confirmar", "Voltar");
        new guncharge, ammocharge, mod = 100, ammo = strval(inputtext), location = PlayerInfo[playerid][pLocal];
        if(ammo < 1 || ammo > 999) return SendClientMessage(playerid, COLOR_GREY, "Muniзгo tem que ser entre 1 e 999 !");
        if(ArmaID == 1) ArmaID = 1, guncharge = GunPrice[1][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 4) ArmaID = 4, guncharge = GunPrice[3][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 5) ArmaID = 5, guncharge = GunPrice[1][0]/100*mod, ammocharge = 0;
        else if(ArmaID == 16) ArmaID = 16, guncharge = GunPrice[4][0]/100*mod, ammocharge = GunPrice[17][0]/100*ammo;
        else if(ArmaID == 17) ArmaID = 17, guncharge = GunPrice[4][0]/100*mod, ammocharge = GunPrice[15][0]/100*ammo;
        else if(ArmaID == 24) ArmaID = 24, guncharge = GunPrice[15][0]/100*mod, ammocharge = GunPrice[25][0]*ammo;
        else if(ArmaID == 25) ArmaID = 25, guncharge = GunPrice[19][0]/100*mod, ammocharge = GunPrice[26][0]*ammo;
        else if(ArmaID == 29) ArmaID = 29, guncharge = GunPrice[18][0]/100*mod, ammocharge = GunPrice[27][0]*ammo;
        else if(ArmaID == 30) ArmaID = 30, guncharge = GunPrice[22][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 31) ArmaID = 31, guncharge = GunPrice[23][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 34) ArmaID = 34, guncharge = GunPrice[24][0]/100*mod, ammocharge = GunPrice[28][0]*ammo;
        else if(ArmaID == 46) ArmaID = 46, guncharge = GunPrice[0][0]/100*mod, ammocharge = 0;
        if((guncharge+ammocharge) > GetPlayerMoney(playerid))
        {
            format(Str, sizeof(Str), "Vocк nгo tem R$%d para pagar !", guncharge+ammocharge);
            SendClientMessage(playerid, COLOR_GRAD3, Str);
            return 1;
        }
        new payout = guncharge + ammocharge;
        if(location != 102 && !IsACop(playerid)) GivePlayerMoney(playerid, - payout);
        BizzInfo[location-99][bTill] += payout;
        ExtortionBiz(location-99, payout);
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        GivePlayerWeapon(playerid, ArmaID, ammo);
        format(Str, sizeof(Str), "Vocк comprou um(a) %s com %d bala(s) por R$%d", ArmaID, ammo, payout);
        SendClientMessage(playerid, COLOR_GRAD3, Str);
        format(Str, sizeof(Str), "%s comprou armas por R$%d na empresa %d", PlayerName(playerid), payout, location-99);
        printf(Str);
        TAInfo[playerid][PLojaA1] = 0;
        TAInfo[playerid][PLojaA2] = 0;
        TAInfo[playerid][ArmaLoja] = 0;
    }
Deu certo, o que era que eu nao achei ainda ?
@EDIT, ja vi

Vlw ae +rep


Re: [AJUDA] inputtext - EditPawn - 05.06.2012

Desculpe o double....


Entao, strval usasse para Numeros
strlen usasse para strings....

Certo ?
Tem mais alguma que fora essas sao importantes ?
Obg


Re: [AJUDA] inputtext - Abravanel - 05.06.2012

Strval - converte uma string para inteiger(nъmero)
Strlen - geta o tamanho de uma determinada string

Sim tem muitos outros, segue uma lista abaixo:

Strcmp
Strfind
Strtok
Strdel
Strins
Strmid
Strpack
Strcat


Re: [AJUDA] inputtext - EditPawn - 05.06.2012

Quote:
Originally Posted by AFerreira
Посмотреть сообщение
Strval - converte uma string para inteiger(nъmero)
Strlen - geta o tamanho de uma determinada string

Sim tem muitos outros, segue uma lista abaixo:

Strcmp
Strfind
Strtok
Strdel
Strins
Strmid
Strpack
Strcat
eu sу nao sabia mecher com strfind, strmid, strpack, strdel...

Obg ^^