SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 22/09/2019, 07:04 PM   #1
CoelhaO
Little Clucker
 
CoelhaO's Avatar
 
Join Date: Sep 2019
Location: Brasil
Posts: 15
Reputation: 0
Default inputtext e switch

Alguém com pode me disponibilizar um exemplo de switch utilizando o inputtext e comparando com a variável que armazena carácter .
CoelhaO is offline   Reply With Quote
Old 22/09/2019, 07:11 PM   #2
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 882
Reputation: 62
Default Re: inputtext e switch

Quais seriam as variáveis possíveis para combinação para que esse switch fosse necessário? O inputtext seria apenas numérico ou número com texto também.
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility
willttoonn is offline   Reply With Quote
Old 22/09/2019, 07:19 PM   #3
CoelhaO
Little Clucker
 
CoelhaO's Avatar
 
Join Date: Sep 2019
Location: Brasil
Posts: 15
Reputation: 0
Default Re: inputtext e switch

Ele vai armazenar números e texto
Seria como transformar esse if em switch
PHP Code:
PlayerInfo[playerid][pSenha] = DOF2_GetInt(arquivo"Senha"); 
if(
strval(inputtext) == PlayerInfo[playerid][pSenha]) 
  {
  
SendClientMessage(playerid, -1"teste1.");
  } 
CoelhaO is offline   Reply With Quote
Old 22/09/2019, 07:22 PM   #4
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 882
Reputation: 62
Default Re: inputtext e switch

Com switch
pawn Code:
PlayerInfo[playerid][pSenha] = DOF2_GetInt(arquivo, "Senha");

switch(strval(inputtext))
{
    case PlayerInfo[playerid][pSenha]: SendClientMessage(playerid, -1, "teste1.");
}

Sem switch e da maneira que eu prefiro fazer (raramente uso switch):
pawn Code:
PlayerInfo[playerid][pSenha] = DOF2_GetInt(arquivo, "Senha");

if(strval(inputtext) == PlayerInfo[playerid][pSenha])
    SendClientMessage(playerid, -1, "teste1.");
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility
willttoonn is offline   Reply With Quote
Old 22/09/2019, 07:48 PM   #5
CoelhaO
Little Clucker
 
CoelhaO's Avatar
 
Join Date: Sep 2019
Location: Brasil
Posts: 15
Reputation: 0
Default Re: inputtext e switch

Já tentei destas formas e da ERRO
error 008: must be a constant expression; assumed zero
PHP Code:
//formula1
switch(strval(inputtext))
{
    {
    case 
PlayerInfo[playerid][pSenha]: SendClientMessage(playerid, -1"teste1.");
    }
}
//formula1
switch(strval(inputtext))
{
    case 
PlayerInfo[playerid][pSenha]:
    {
    
SendClientMessage(playerid, -1"teste1.");
    }

CoelhaO is offline   Reply With Quote
Old 22/09/2019, 08:18 PM   #6
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 882
Reputation: 62
Default Re: inputtext e switch

Quote:
Originally Posted by CoelhaO View Post
Já tentei destas formas e da ERRO
error 008: must be a constant expression; assumed zero
PHP Code:
//formula1
switch(strval(inputtext))
{
    {
    case 
PlayerInfo[playerid][pSenha]: SendClientMessage(playerid, -1"teste1.");
    }
}
//formula1
switch(strval(inputtext))
{
    case 
PlayerInfo[playerid][pSenha]:
    {
    
SendClientMessage(playerid, -1"teste1.");
    }

Você colocou um {} duas vezes antes do case na primeira. Se a segunda não funcionou, use o if que terá o mesmo efeito, use o exemplo de if que eu enviei acima.
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility
willttoonn is offline   Reply With Quote
Old 22/09/2019, 08:25 PM   #7
CoelhaO
Little Clucker
 
CoelhaO's Avatar
 
Join Date: Sep 2019
Location: Brasil
Posts: 15
Reputation: 0
Default Re: inputtext e switch


Também não vai vou desistir ou criar uma include
PHP Code:
switch(strval(inputtext))
{
case 
PlayerInfo[playerid][pSenha]: SendClientMessage(playerid, -1"teste1.");

CoelhaO is offline   Reply With Quote
Old 22/09/2019, 09:09 PM   #8
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 882
Reputation: 62
Default Re: inputtext e switch

Porque não usa if?
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility
willttoonn is offline   Reply With Quote
Old 22/09/2019, 09:14 PM   #9
CoelhaO
Little Clucker
 
CoelhaO's Avatar
 
Join Date: Sep 2019
Location: Brasil
Posts: 15
Reputation: 0
Default Re: inputtext e switch

Não gosto muito, mais terei que utilizar if ate achar uma solução melhor.
Obrigado.
__________________
CoelhaO_LokaO#4743
BRASIL INTEIRO GAMES EM BREVE
CoelhaO is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch inside switch? Lajko1 Scripting Help 2 03/05/2016 05:37 PM
Switch() bug?! TheSy Scripting Help 5 02/06/2014 04:49 PM
Switch the inputtext. BetaLaxx Scripting Help 5 30/03/2012 04:23 PM
Which one is better (switch and else if) DayaKisteme Scripting Help 5 16/11/2011 09:17 PM
Switch Help Mini` Help Archive 0 02/03/2010 11:06 PM


All times are GMT. The time now is 11:57 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.