Vice City: Multiplayer

Server Development => Scripting and Server Management => Client Scripting => Topic started by: MEGAMIND on September 2nd, 2017, 09:27 AM

Title: Display Sprite with cmd!
Post by: MEGAMIND on September 2nd, 2017, 09:27 AM
Display Sprite with cmd!

================Add this on server side====================
Code: [Select]
function onPlayerCommand( player, cmd, text )
{
if(cmd=="overlay"){
Stream.StartWrite()
Stream.WriteInt(1)
Stream.SendStream(player)
}
else if(cmd=="off"){
Stream.StartWrite()
Stream.WriteInt(3)
Stream.SendStream(player)
}
else if(cmd=="web"){
Stream.StartWrite()
Stream.WriteInt(2)
Stream.SendStream(player)
}
}

function onClientScriptData(player)
{
if (type == 1)
{
Stream.StartWrite();
Stream.WriteInt(1);
Stream.SendStream(player);
}
if (type == 2)
{
Stream.StartWrite();
Stream.WriteInt(2);
Stream.SendStream(player);
}

if (type == 3)
{
Stream.StartWrite();
Stream.WriteInt(3);
Stream.SendStream(player);
}
}

==================Add this to your client side==========================
Code: [Select]
function Server::ServerData(stream)
{
local type = stream.ReadInt();

if (type == 1) {//CreateSprit
::sprite <- GUISprite("overlay.png", VectorScreen(40, 290));
::sprite.Size = VectorScreen(180, 300);
::sprite.Alpha = 210;
::sprite.AddFlags(GUI_FLAG_MOUSECTRL);
}

if (type == 2) {//CreateSprit
::sprite <- GUISprite("web.png", VectorScreen(40, 290));
::sprite.Size = VectorScreen(180, 300);
::sprite.Alpha = 210;
::sprite.AddFlags(GUI_FLAG_MOUSECTRL);
}
if (type == 3) {//Delete Sprit
::sprite <- null;
}
}

Use cmd
/overlay -> to open a sprite, /web -> to open second sprite, /off to off any of the sprite

This is my first snippet for clientside. I thought this will help players(newbies) on how to make a simple cmd to activate any of the function they are trying to perform..

Pics
(click to show/hide)
(https://preview.ibb.co/jY6ata/2017_09_02_01_19_01_0995.png)(https://ibb.co/mUq1Ya)
(https://preview.ibb.co/c6UpKF/2017_09_02_01_19_17_0613.png)(https://ibb.co/d0UZmv)
(https://preview.ibb.co/mWmEmv/2017_09_02_01_19_28_0800.png)(https://ibb.co/kyBfRv)