Scripting/Squirrel/Client Events/Server::ServerData

From Vice City Multiplayer
Revision as of 03:25, 16 June 2017 by Kennedyarz (talk | contribs) (Created page with "== Example == <source lang=squirrel> Testing<- { Test = null } function Script::ScriptLoad() { Testing.Test = GUIButton(VectorScreen(sX * 0.23, sY * 0.05), Vecto...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

Example

Testing<-
{
    Test = null
}

function Script::ScriptLoad()
{
        Testing.Test = GUIButton(VectorScreen(sX * 0.23, sY * 0.05), VectorScreen(sX * 0.11, sY * 0.03), Colour(22, 22, 22, 200) "Data", GUI_FLAG_BORDER | GUI_FLAG_DRAGGABLE | GUI_FLAG_VISIBLE);
}

function GUI::ElementRelease(element, mouseX, mouseY) 
{
	if(element == Testing.Test)
	{
	local Data = Stream();
    	Data.WriteString("Testing.Test");
    	Server.SendData(Data);
	}
}

//----------------------- S E R V E R  S I D E --------------------------//
function onClientScriptData(player)
{
	local string = Stream.ReadString(), int = Stream.ReadInt();
        if (string == "Test.Testing")
        {
        Message("Hello");
        }
}

Notes

Is responsible for sending a implemented function from the client side side to the server side