Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Luis_Labarca on Sep 30, 2016, 07:59 PM

Title: How to create a sprite from a command?
Post by: Luis_Labarca on Sep 30, 2016, 07:59 PM
//-----------------------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); ?

Title: Re: How to create a sprite from a command?
Post by: Xmair on Oct 01, 2016, 10:06 AM
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;

};

};
Title: Re: How to create a sprite from a command?
Post by: Anik on Oct 01, 2016, 11:32 AM
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.
Title: Re: How to create a sprite from a command?
Post by: Xmair on Oct 01, 2016, 04:49 PM
@Anik why not?
Title: Re: How to create a sprite from a command?
Post by: 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.
Title: Re: How to create a sprite from a command?
Post by: Xmair on Oct 02, 2016, 05:16 AM
Try executing this.
function myFunc() { local a = 1 return a + rand() }
Title: Re: How to create a sprite from a command?
Post by: KAKAN on Oct 02, 2016, 06:11 AM
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.
Title: Re: How to create a sprite from a command?
Post by: 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.
Title: Re: How to create a sprite from a command?
Post by: KAKAN on Oct 02, 2016, 12:26 PM
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.
Title: Re: How to create a sprite from a command?
Post by: Luis_Labarca on Oct 03, 2016, 07:54 PM
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
Title: Re: How to create a sprite from a command?
Post by: Luis_Labarca on Oct 03, 2016, 07:54 PM
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