SendDataToServertext(com.we32.Text, 15) // its send only one string
// but me i want two string one for username & one for password
// here is my function below
function SendDataToServertext(str, int)
{
local message = Stream();
message.WriteInt(int.tointeger());
message.WriteString(str);
Server.SendData(message);
}
As you saw above, How i can send two string like:- SendDataToServertext(one.Text,two.Text, 15).
Quote from: We3da on Mar 21, 2021, 06:02 PMHow i can send two string like:- SendDataToServertext(one.Text,two.Text, 15).
You call the
Stream.WriteString() method twice, i.e.:
function SendDataToServertext( str1, str2, int )
{
local stream = Stream();
stream.WriteInt( int );
stream.WriteString( str1 );
stream.WriteString( str2 );
Server.SendData( stream );
}
Usage example:
function Script::ScriptLoad()
{
::SendDataToServertext( "hello", "hi", 15 );
}
Server side usage example:
function onClientScriptData( player )
{
// We call the Stream.ReadInt() method first because it was the first one to be sent from the client,
// therefore we must call it first. Same applies with the strings.
local int = Stream.ReadInt(); // Integer received from the client.
local str1 = Stream.ReadString(); // First string received from the client.
local str2 = Stream.ReadString(); // Second string received from the client.
Message( "int: " + int );
Message( "str1: " + str1 );
Message( "str2: " + str2 );
}
Output:
(https://i.imgur.com/Oe3j8bm.png)
Thanks, i will try it.