Display Sprite with cmd!

MEGAMIND

  • Hero Member
  • Developer of "Web-Net" search engine
  • Posts: 698
Display Sprite with cmd!
« 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)