How to use two case

Started by Mohamed Boubekri, Mar 22, 2021, 07:32 PM

Previous topic - Next topic

Mohamed Boubekri

I'm trying to sent two case see it below:-
function GUI::ElementRelease(element, mouseX, mouseY)
{
switch (element)
{
case regiscom.regbut: //register boutton///
GUI.InputReturn(regiscom.user); //when player click register boutton he need to fill editbox first//
GUI.InputReturn(regiscom.pas); //but as you see here three edit box: user, pasword, repassword//
GUI.InputReturn(regiscom.repas); // actually i don't know if i have a problem here or no
}
}
Ok now see the function inputreturn below:-
function GUI::InputReturn(editbox)
{
switch(editbox)
{
case regiscom.user: case regiscom.pas: case regiscom.repas: //well as you see here, please if i have a problem tell me

if (regiscom.user.Text.len() > 0)
{
if (regiscom.pas.Text.len() > 0)
{
if (regiscom.repas.Text.len() > 0)
{
if (regiscom.pas.Text == regiscom.repas.Text)
{
SendDataToServertwo( regiscom.user.Text, regiscom.pas.Text, 70 ); //ok when the conditions met its send data to serv
}                                                               //but still i have a problem i'll tell you
else hihihihi(6);
}
else hihihihi(5);
}
else hihihihi(4);
}
else hihihihi(3);
}
}
Well, know see server side func below:-
function onClientScriptData( player )
{
local int = Stream.ReadInt( ),
string = Stream.ReadString ( );
switch( int.tointeger() )
{
case 70:
local str2 = Stream.ReadString ( ); ///pasword///
local q = QuerySQL(Database, "SELECT * FROM Accounts WHERE Username = '" + string + "'");
if (!q)
{
MessagePlayer("Ok your user: "+string+" and you pass: "+str,player);  //the message its show and work great, but its send two time

// ok know i'll tell you my problem
// when the two message show its show two time

QuerySQL(Database, "INSERT INTO Accounts ( Username, Password , Admin, Cash, Bank, LastPosX, LastPosY, LastPosZ, LastPos, IP, UID, UID2 ) VALUES ( '" + string + "', '" + SHA256(str2) + "', '" + 0 + "', '" + 0 + "', '" + 0 + "', '" + 0 + "', '" + 0 + "', '" + 0 + "', '" + 0 + "', '" + player.IP + "', '" + player.UniqueID + "', '" + player.UniqueID2 + "' )");
MessagePlayer("[#ffff00]Successfully Registered.", player);
MessagePlayer("[#ffff00]Don't forget your password [#CC6666]" + str2, player);
stats[player.ID].Password = SHA256(str2);
stats[player.ID].Admin = 0;
stats[player.ID].UID = player.UniqueID;
stats[player.ID].UID2 = player.UniqueID2;
stats[player.ID].IP = player.IP;
stats[player.ID].Reg = true;
stats[player.ID].Log = true;
}
else Stream.StartWrite( ); Stream.WriteInt( 11 ); Stream.SendStream( player );
break;
}
}
Like i tell you, its send two time, See the picture to understand me:-

Actually the message is only not repeated twice, but three ???
I want the message to repeated Once.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

AroliS^

function GUI::ElementRelease(element, mouseX, mouseY)
{
switch (element)
{
case regiscom.regbut: //register boutton///
1// GUI.InputReturn(regiscom.user); //when player click register boutton he need to fill editbox first//
2// GUI.InputReturn(regiscom.pas); //but as you see here three edit box: user, pasword, repassword//
3// GUI.InputReturn(regiscom.repas); // actually i don't know if i have a problem here or no
}
}

i bet you, you can solve it by your self after this
Lemme love ya

Mohamed Boubekri

@AroliS^ Yes, I solved it thanks to you, I will share the solution with others:-
function GUI::ElementRelease(element, mouseX, mouseY)
{
switch (element)
{
case regiscom.regbut:
GUI.InputReturn(regiscom.user,regiscom.pas,regiscom.repas); //yep change that
break;
}
}
function GUI::InputReturn(editbox, editbox1, editbox2) // yep here also change
{
switch ( editbox && editbox1 && editbox2 ) // yep here also
{
case regiscom.user: case regiscom.pas: case regiscom.repas: /////register//

if (regiscom.user.Text.len() > 0)
{
if (regiscom.pas.Text.len() > 0)
{
if (regiscom.repas.Text.len() > 0)
{
if (regiscom.pas.Text == regiscom.repas.Text)
{
SendDataToServertwo( regiscom.user.Text, regiscom.pas.Text, 70 );
}
else hihihihi(6);
}
else hihihihi(5);
}
else hihihihi(4);
}
else hihihihi(3);
break;
}
}
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

AroliS^

#3
You dont need to send all Editboxes, as far as you detecting if they aren.t empty tho.

function GUI::ElementRelease(element, mouseX, mouseY)
{
switch (element)
{
case regiscom.regbut:
GUI.InputReturn(regiscom.users); //yep change that
break;
}
}

function GUI::InputReturn(editbox) // yep here also change
{
switch ( editbox) // yep here also
{
case regiscom.user: case regiscom.pas: case regiscom.repas: /////register//

if (regiscom.user.Text.len() > 0)
{
if (regiscom.pas.Text.len() > 0)
{
if (regiscom.repas.Text.len() > 0)
{
if (regiscom.pas.Text == regiscom.repas.Text)
{
SendDataToServertwo( regiscom.user.Text, regiscom.pas.Text, 70 );
}
else hihihihi(6);
}
else hihihihi(5);
}
else hihihihi(4);
}
else hihihihi(3);
break;
}
}


this shall be enough, and also try organizing your scripts.
Lemme love ya