Display Sprite with cmd!

Started by MEGAMIND, Sep 02, 2017, 08:27 AM

Previous topic - Next topic

MEGAMIND

Display Sprite with cmd!

================Add this on server side====================
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==========================
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
[spoiler]

[/spoiler]