//-----------------------Script Server
Hi I was wondering how I can send data to create a sprit from a command I have tested with the following command but help does not work
function onPlayerCommand( player, cmd, text )
{
if(cmd=="test"){
Stream.StartWrite()
Stream.WriteInt(6)
Stream.SendStream(player)
}
}
function onClientScriptData(player)
{
if (type == 6)
{
Stream.StartWrite();
Stream.WriteInt(5);
Stream.SendStream(player);
}
}
//--------------------------------Client-Side
function Server::ServerData(stream)
{
local type = stream.ReadInt();
if (type == 5) {//CreateSprit
::GUI.SetMouseEnabled(true);
::sprite <- GUISprite("s.png", VectorScreen(0, 0));
::sprite.Size = VectorScreen(40, 40);
::sprite.AddFlags(GUI_FLAG_MOUSECTRL);
}
}
thanks from already ;) :D
and another thing as doing that to the closing a window I of GUI.SetMouseEnabled (false); ?
The function onClientScriptData is called when you send data from client to server.
function onPlayerCommand( iPlayer, szCmd, szText ) {
switch( szCmd.tolower( ) ) {
case "test":
Stream.StartWrite( );
Stream.WriteInt( 5 );
Stream.SendStream( iPlayer );
break;
};
};
You are doing right. Just change this line
Stream.WriteInt(6)
To
Stream.WriteInt(5)
Because on Server::ServerData function you are checking if the type is 5 or not.
@Xmair Why "
;" after bracket?? I think its not necessary.
Try executing this.
function myFunc() { local a = 1 return a + rand() }
Quote from: Anik on Oct 02, 2016, 04:54 AMQuote from: Xmair on Oct 01, 2016, 04:49 PM@Anik why not?
@Xmair cuz its not necessary.
It might not be necessary in squirrel, but, it actually tells the compiler to stop interpreting the command from that line and go to the next line( in noob lang ). Just as Xmair said, try executing that code and see.
Quote from: Xmair on Oct 02, 2016, 05:16 AMTry executing this.
function myFunc() { local a = 1 return a + rand() }
This won't work. But first one will work without colons.
Quote from: Anik on Oct 02, 2016, 11:40 AMQuote from: Xmair on Oct 02, 2016, 05:16 AMTry executing this.
function myFunc() { local a = 1 return a + rand() }
This won't work. But first one will work without colons.
Google why it is needed.
Quote from: Xmair on Oct 01, 2016, 10:06 AMThe function onClientScriptData is called when you send data from client to server.
Ah ok thanks bro
Quote from: Anik on Oct 01, 2016, 11:32 AMYou are doing right. Just change this line
Stream.WriteInt(6)
To
Stream.WriteInt(5)
Because on Server::ServerData function you are checking if the type is 5 or not.
@Xmair Why ";" after bracket?? I think its not necessary.
thanks bro