How to create a sprite from a command?

Started by Luis_Labarca, Sep 30, 2016, 07:59 PM

Previous topic - Next topic

Luis_Labarca

//-----------------------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); ?

My server RP
IP: 51.222.28.159:8194

Xmair

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;

};

};

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Anik

#2
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.

Xmair


Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD


Xmair

Try executing this.
function myFunc() { local a = 1 return a + rand() }

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

KAKAN

Quote from: Anik on Oct 02, 2016, 04:54 AM
Quote 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.
oh no

Anik

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.

KAKAN

Quote from: Anik on Oct 02, 2016, 11:40 AM
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.
Google why it is needed.
oh no

Luis_Labarca

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
My server RP
IP: 51.222.28.159:8194

Luis_Labarca

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
My server RP
IP: 51.222.28.159:8194