Major Server Update Released (April 25)

maxorator

  • VC:MP Developer
  • Posts: 159
Major Server Update Released (April 25)
« on April 25th, 2016, 08:47 PM »Last edited by Stormeus
Server Update 04rel004
  • Added client-side GUIs and scripting. The client now has a Squirrel core for running GUI management scripts, and has a few basic client-side events, detailed below.
  • Extensively revised the plugin API to give more informative return values for plugin calls and to reduce repetition.
  • Added functions and callbacks for communicating between the server and client via plugin calls.
  • Removed server-side sprites. Use client-side sprites instead.
  • Removed server-side textdraws. Use client-side GUI labels instead.
  • Checkpoints and spheres were merged, a parameter for CreateCheckPoint can now be used to decide between a sphere and a checkpoint.

If your script relies on server-side features that have been removed, we recommend porting your GUI scripts to use client-side features and upgrading to this server version afterward.

Server downloads:
Windows Server (x86)
Windows Server (x64)
Linux Server (x86)
Linux Server (x64)

You can access the new plugin header at:
https://bitbucket.org/maxorator/vcmp-plugin-header/src

About client side scripts

Client scripts go to store/script with main.nut being the first script file loaded. The documentation is available below.

Updated plugins

Currently all plugins are in one archive:
http://v04.maxorator.com/allplugins_04rel004_patch7.7z

It contains the Windows and Linux, 32 and 64 bit versions of the following plugins:
  • Announce
  • Java
  • Squirrel
  • SQLite for squirrel
  • MySQL for squirrel
  • Hashing for squirrel
  • Sockets for squirrel
  • XML configuration loader

Any plugins that have not been updated for this version WILL NOT WORK.
Re: Major Server Update Released (April 25)
« Reply #1, on April 25th, 2016, 08:47 PM »
Client-side squirrel documentation:
(click to show/hide)
Events

Script::ScriptLoad()
Return type: void.
Called right after scripts have been successfully loaded.

Script::ScriptUnload()
Return type: void.
Called before scripts are unloaded, on disconnect.

Script::ScriptProcess()
Return type: void.
Called once every frame.

Player::PlayerDeath(player)
Parameter types: Player. Return type: void.
Called whenever a player dies.

Player::PlayerShoot(player, weapon, hitEntity, hitPosition)
Parameter types: Player, int, entity, Vector. Return type: void.
Called when a player makes a shot. If something was hit, hitEntity points to that and hitPosition is the position of the collision. Otherwise, hitEntity is null and hitPosition is the end of the bullet trajectory.

Server::ServerData(stream)
Parameter types: Stream. Return type: void.
Called when data from the server was received.

GUI::ElementFocus(element)
Parameter types: GUIElement. Return type: void.
Called when a GUI element receives focus.

GUI::ElementBlur(element)
Parameter types: GUIElement. Return type: void.
Called when a GUI element loses focus.

GUI::ElementHoverOver(element)
Parameter types: GUIElement. Return type: void.
Called when mouse enters the GUIElement (must have GUI_FLAG_MOUSECTRL).

GUI::ElementHoverOut(element)
Parameter types: GUIElement. Return type: void.
Called when mouse leaves the GUIElement (must have GUI_FLAG_MOUSECTRL).

GUI::ElementClick(element, mouseX, mouseY)
Parameter types: GUIElement, int, int. Return type: void.
Called when an element is clicked (must have GUI_FLAG_MOUSECTRL). Coordinates are absolute.

GUI::ElementRelease(element, mouseX, mouseY)
Parameter types: GUIElement, int, int. Return type: void.
Called when mouse is released after click on an element (must have GUI_FLAG_MOUSECTRL). Coordinates are absolute.

GUI::ElementDrag(element, mouseX, mouseY)
Parameter types: GUIElement, int, int. Return type: void.
Called when mouse is moved during dragging the element (must have GUI_FLAG_MOUSECTRL). Coordinates are absolute.

GUI::CheckboxToggle(checkbox, checked)
Parameter types: GUICheckbox, bool. Return type: void.
Called when checkbox is checked.

GUI::WindowClose(window)
Parameter types: GUIWindow. Return type: void.
Called when window is closed.

GUI::InputReturn(editbox)
Parameter types: GUIEditbox. Return type: void.
Called when the user presses enter while keyboard focus is in an editbox.

GUI::ListboxSelect(listbox, text)
Parameter types: GUIListbox, string. Return type: void.
Called when the user selects an item in a list box.

GUI::ScrollbarScroll(scrollbar, position, change)
Parameter types: GUIScrollbar, float, float. Return type: void.
Called when the user selects an item in a list box.

GUI::WindowResize(window, width, height)
Parameter types: GUIWindow, int, int. Return type: void.
Called when a window is resized.

GUI::GameResize(width, height)
Parameter types: int, int. Return type: void.
Called when the game screen is resized.

GUI::KeyPressed()
Parameter types: int. Return type: void.
Called when a key is pressed, with the virtual key code as the parameter.

KeyBind::OnDown()
Parameter types: KeyBind. Return type: void.
Called when a keybind is activated.

KeyBind::OnUp()
Parameter types: KeyBind. Return type: void.
Called when a keybind is released.

Types

Types int, float, bool and string are built-in types. entity is not an actual type, but can be any of either Player, Vehicle or Building. The actual type can be detected from the return value of entity.Type which is respectively OBJ_PLAYER, OBJ_VEHICLE or OBJ_BUILDING for them.

The values of properties marked as read-only cannot be changed. If a property is marked as bound, then it means the instance of for example a Vector that you get from it is bound to the object. Therefore if you do var = player.Position;, var.X will always contain the player's X position, not the X position when var was assigned. To get an unbound vector, use var = Vector(player.Position);.

Vector

Constructor Vector(x, y, z)
Parameter types: float, float, float

Constructor Vector(vector)
Parameter types: Vector
Creates a copy of the specified vector.

Property X
Type: float

Property Y
Type: float

Property Z
Type: float

Operator +
Return type: Vector
Adds the values of two vectors together and returns a new instance.

VectorScreen

Constructor VectorScreen(x, y)
Parameter types: int, int

Constructor VectorScreen(screenVector)
Parameter types: VectorScreen
Creates a copy of the specified screen vector.

Property X
Type: int

Property Y
Type: int

Colour

Constructor Colour(r, g, b, a)
Parameter types: int, int, int, int

Constructor Colour(r, g, b)
Parameter types: int, int, int
Alpha is set to 255.

Constructor Colour(colour)
Parameter types: Colour
Creates a copy of the specified colour.

Property R
Type: int

Property G
Type: int

Property B
Type: int

Property A
Type: int

Property Hex
Type: int

KeyBind

Key values are virtual key codes. When a keybind is created, events about it will start coming, no need to register the keybind anywhere. To make a keybind not send events anymore, all references to it must be removed.

Constructor KeyBind(keyOne)
Parameter types: int

Constructor KeyBind(keyOne, keyTwo)
Parameter types: int, int

Constructor KeyBind(keyOne, keyTwo, keyThree)
Parameter types: int, int, int

RayTrace

When ray trace is created, the properties from it will contain the results.

Constructor RayTrace(start, end, flags)
Parameter types: Vector, Vector, flags
Flag values can be or-ed together with the | operator to select which types of entities it should check: RAY_BUILDING, RAY_PED, RAY_VEHICLE, RAY_OBJECT.

Property Collided (read-only)
Type: bool
True when the ray hit something.

Property Entity (read-only)
Type: entity
The entity that was hit, or null if nothing was hit. May also be null if the entity has been destroyed.

Property Position
Type: Vector
The position of the collision, or zero vector if nothing was hit.

Stream

Used to construct the packet to send to the server or to read the data sent by the server. Read functions cannot be used on streams that were created by the script. The format of the stream is little-endian, with the exception that strings are written as a big-endian 2-byte length followed by the characters. Check Server::SendData for sending the stream or event Server::ServerData for receiving it.

Constructor Stream()
Creates a new stream for writing, which can be sent to the server.

Function ReadByte()
Return type: int
Reads a single byte from the stream.

Function ReadInt()
Return type: int
Reads an integer (4 bytes) from the stream.

Function ReadFloat()
Return type: float
Reads a float (4 bytes) from the stream.

Function ReadString()
Return type: float
Reads a string from the stream.

Function WriteByte(value)
Parameter types: int. Return type: void
Writes a single byte to the stream.

Function WriteInt(value)
Parameter types: int. Return type: void
Writes an integer (4 bytes) to the stream.

Function WriteInt(value)
Parameter types: float. Return type: void
Writes a float (4 bytes) to the stream.

Function WriteInt(value)
Parameter types: string. Return type: void
Writes a string to the stream.

Property Error (read-only)
Type: bool
Whether writing exceeded the maximum stream size, or a read call tried to read past the end of the stream.

Player

Property Type (read-only)
Type: int
The type of this entity, always OBJ_PLAYER.

Property ID (read-only)
Type: int

Property Local (read-only)
Type: bool
Whether this is the local player.

Property Name (read-only)
Type: string

Property Health (read-only)
Type: float

Property Armour (read-only)
Type: float

Property Position (bound)
Type: Vector

Vehicle

Vehicle position and speed can only be changed if the vehicle is currently controlled by the current player (either a driver, passenger or the closest player).

Property Type (read-only)
Type: int
The type of this entity, always OBJ_VEHICLE.

Property ID (read-only)
Type: int

Property ModelIndex (read-only)
Type: int

Property Health (read-only)
Type: float

Property Position (bound)
Type: Vector

Property Speed (bound)
Type: Vector

Function GetOccupant(slot)
Parameter types: int. Return type: Player
The value passed to it is the slot number. 0 for driver, 1-8 for passengers.

Building

Property Type (read-only)
Type: int
The type of this entity, always OBJ_BUILDING.

Property ModelIndex (read-only)
Type: int

Property Position (read-only)
Type: Vector

Global functions

dofile(filename)
Parameter types: string. Return type: void.
Loads the specified script file. The script/ directory is automatically prepended.

print(text)
Parameter types: string. Return type: void.
Writes to the debug log file.

Script::GetTicks()
Return type: int.
Returns a number of milliseconds since the computer started. Can be used to measure time intervals.

Script::LoadScript(filename)
Parameter types: string. Return type: void.
Same as dofile.

World::FindPlayer(id)
Parameter types: int. Return type: Player.
Returns the player instance for the ID, or null if the player does not exist.

World::FindLocalPlayer()
Return type: Player.
Returns the local player instance.

World::FindVehicle(id)
Parameter types: int. Return type: Vehicle.
Returns the vehicle instance for the ID, or null if the vehicle does not exist or is not streamed in.

Server::SendData()
Parameter types: Stream. Return type: bool.
Sends the data written to the stream to the server. Returns false if null or read-only stream was given.

Console::Print(text)
Parameter types: string. Return type: void.
Writes to the game console.

GUI::GetMouseEnabled()
Return type: void.
Checks if mouse is enabled for GUI.

GUI::SetMouseEnabled(enabled)
Parameter types: bool. Return type: void.
Sets whether mouse is enabled for GUI.

GUI::GetMousePos()
Return type: VectorScreen.

GUI::GetScreenSize()
Return type: VectorScreen.

GUI::ScreenPosToWorld(screenPosition)
Parameter types: Vector. Return type: Vector.
Returns the world coordinates for the screen position.

GUI::WorldPosToScreen(position)
Parameter types: Vector. Return type: Vector.
Returns the screen coordinates for the position.

GUI::GetFocusedElement()
Return type: GUIElement.
Returns the focused element, or null if none.

GUI::SetFocusedElement(element)
Parameter types: GUIElement. Return type: void.
Sets the focus on the specified element.
Re: Major Server Update Released (April 25)
« Reply #2, on April 25th, 2016, 08:47 PM »Last edited on May 3rd, 2016, 05:26 PM
Client-side squirrel documentation continued (GUI types):
(click to show/hide)
GUIElement

There aren't actually any instances of GUIElement, but it is the base class for all other GUI element classes. This means that all properties and functions it has also work on other GUI elements. GUI element flags are used in several places, the available flag constants are:
  • GUI_FLAG_NONE
  • GUI_FLAG_VISIBLE
  • GUI_FLAG_DISABLED
  • GUI_FLAG_BACKGROUND
  • GUI_FLAG_BORDER
  • GUI_FLAG_SHADOW
  • GUI_FLAG_DRAGGABLE
  • GUI_FLAG_CLIP
  • GUI_FLAG_WRAP
  • GUI_FLAG_AUTO_RESIZE
  • GUI_FLAG_INHERIT_ALPHA
  • GUI_FLAG_ANIMATION
  • GUI_FLAG_TABSTOP
  • GUI_FLAG_MOUSECTRL
  • GUI_FLAG_KBCTRL
  • GUI_FLAG_SCROLLABLE
  • GUI_FLAG_TEXT_SHADOW
  • GUI_FLAG_TEXT_TAGS
  • GUI_FLAG_DEPTH_TEST
  • GUI_FLAG_3D_ENTITY
  • GUI_FLAG_CACHE_TEXTURE
  • GUI_FLAG_CHECKBOX_CHECKED
  • GUI_FLAG_EDITBOX_MASKINPUT
  • GUI_FLAG_LISTBOX_MULTISELECT
  • GUI_FLAG_LISTBOX_SORTING
  • GUI_FLAG_MEMOBOX_TOPBOTTOM
  • GUI_FLAG_SCROLLBAR_HORIZ
  • GUI_FLAG_WINDOW_TITLEBAR
  • GUI_FLAG_WINDOW_CLOSEBTN
  • GUI_FLAG_WINDOW_RESIZABLE

Function AddChild(element)
Parameter types: GUIElement. Return type: void.
Makes the specified element a child of this element.

Function IsChildOf(element)
Parameter types: GUIElement. Return type: bool.
Returns true if this element is the child of the specified element.

Function Detach()
Return type: void.
Detaches this element from its parent.

Function MoveForward()
Return type: void.
Moves the siblign element right in front of this one behind it.

Function MoveBackward()
Return type: void.
Moves the sibling element right behind this element to the front of it.

Function SendToTop()
Return type: void.
Moves this element on top of all other sibling elements.

Function SendToBottom()
Return type: void.
Moves this element to the bottom of all other sibling elements.

Property Position (bound)
Type: VectorScreen

Property Size (bound)
Type: VectorScreen

Property Position3D / Pos3D (bound)
Type: Vector

Property Rotation3D (bound)
Type: Vector

Property Size3D (bound)
Type: Vector

Function Set3DTransform(position, rotation, size)
Parameter types: Vector, Vector, Vector. Return type: void.
Sets the 3D transformation of this element.

Property Colour / Color (bound)
Type: Colour

Property TextColour / TextColor (bound)
Type: Colour

Property Alpha
Type: int

Property Text
Type: string

Property TextSize (read-only)
Type: VectorScreen
Size on the screen of the text in this element.

Property TextAlignment
Type: int
Sets the alignment of text. Available constants are:
  • GUI_ALIGN_LEFT
  • GUI_ALIGN_RIGHT
  • GUI_ALIGN_TOP
  • GUI_ALIGN_BOTTOM
  • GUI_ALIGN_CENTERV
  • GUI_ALIGN_CENTERH
  • GUI_ALIGN_CENTER

Property FontName
Type: string

Property FontSize
Type: int

Property FontFlags
Type: int
Available flag constants are:
  • GUI_FFLAG_NONE
  • GUI_FFLAG_BOLD
  • GUI_FFLAG_ITALIC
  • GUI_FFLAG_ULINE
  • GUI_FFLAG_STRIKE
  • GUI_FFLAG_NOAA
  • GUI_FFLAG_OUTLINE

Property TextPaddingTop
Type: int

Property TextPaddingBottom
Type: int

Property TextPaddingLeft
Type: int

Property TextPaddingRight
Type: int

Property Flags
Type: int

Function AddFlags(flags)
Parameter types: int. Return type: void.

Function RemoveFlags(flags)
Parameter types: int. Return type: void.

GUIButton

Constructor GUIButton()

Constructor GUIButton(position, size, colour)
Parameter types: VectorScreen, VectorScreen, Colour

Constructor GUIButton(position, size, colour, text)
Parameter types: VectorScreen, VectorScreen, Colour, string

Constructor GUIButton(position, size, colour, text, flags)
Parameter types: VectorScreen, VectorScreen, Colour, string, int

GUICanvas

Constructor GUICanvas()

GUICheckbox

Constructor GUICheckbox()

Constructor GUICheckbox(position, colour)
Parameter types: VectorScreen, Colour

Constructor GUICheckbox(position, colour, flags)
Parameter types: VectorScreen, Colour, int

GUIEditbox

Constructor GUIEditbox(position, size, colour)
Parameter types: VectorScreen, VectorScreen, Colour

Constructor GUIEditbox(position, size, colour, text)
Parameter types: VectorScreen, VectorScreen, Colour, string

Constructor GUIEditbox(position, size, colour, text, flags)
Parameter types: VectorScreen, VectorScreen, Colour, string, int

Property HasTextSelected (read-only)
Type: bool

Property TextSelection (read-only)
Type: string

Function SelectText(startIndex, endIndex)
Parameter types: int, int. Return type: void.

Property CursorPos
Type: int

GUILabel

Constructor GUILabel()

Constructor GUILabel(position, colour)
Parameter types: VectorScreen, Colour

Constructor GUILabel(position, colour, text)
Parameter types: VectorScreen, Colour, string

Constructor GUILabel(position, colour, text, flags)
Parameter types: VectorScreen, Colour, string, int

GUIListbox

Constructor GUIListbox()

Constructor GUIListbox(position, size)
Parameter types: VectorScreen, VectorScreen

Constructor GUIListbox(position, size, colour, selectedColour)
Parameter types: VectorScreen, VectorScreen, Colour, Colour

Constructor GUIListbox(position, size, colour, selectedColour, flags)
Parameter types: VectorScreen, VectorScreen, Colour, Colour, int

Property Items (read-only)
Type: array

Function AddItem(item)
Parameter types: string. Return type: void.

Function RemoveItem(item)
Parameter types: string. Return type: void.

Function Clean()
Return type: void.
Removes all items.

Property ItemCount (read-only)
Type: int

Property SelectedCount (read-only)
Type: int

Property SelectedColour (bound)
Type: Colour
Background colour of selected items.

GUIMemobox

Constructor GUIMemobox()

Constructor GUIMemobox(position, size, colour)
Parameter types: VectorScreen, VectorScreen, Colour

Constructor GUIMemobox(position, size, colour, flags)
Parameter types: VectorScreen, VectorScreen, Colour, int

Function AddLine(line)
Parameter types: string. Return type: void.

Function AddLine(line, colour)
Parameter types: string, Colour. Return type: void.

Function Clear()
Return type: void.

Property DisplayPos
Type: float

Property LineHeight
Type: int

Property LineCount (read-only)
Type: int

Property HistorySize
Type: int

GUIProgressBar

Constructor GUIProgressBar()

Constructor GUIProgressBar(position, size, colour)
Parameter types: VectorScreen, VectorScreen, Colour

Constructor GUIProgressBar(position, size, colour, selectedColour)
Parameter types: VectorScreen, VectorScreen, Colour, Colour

Constructor GUIProgressBar(position, size, colour, selectedColour, flags)
Parameter types: VectorScreen, VectorScreen, Colour, Colour, int

Constructor GUIProgressBar(position, size, colour, selectedColour, flags, endValue)
Parameter types: VectorScreen, VectorScreen, Colour, Colour, int, float

Property Value
Type: float

Property MaxValue
Type: float

Property BackgroundShade
Type: float

Property Thickness
Type: int

Property StartColour (bound)
Type: Colour

Property EndColour (bound)
Type: Colour

GUIScrollbar

Constructor GUIScrollbar()

Constructor GUIScrollbar(position, size)
Parameter types: VectorScreen, VectorScreen

Constructor GUIScrollbar(position, size, colour)
Parameter types: VectorScreen, VectorScreen, Colour

Constructor GUIScrollbar(position, size, colour, flags)
Parameter types: VectorScreen, VectorScreen, Colour, int

Function SetParams(contentSize, stepSize, barPosition, barSize)
Parameter types: float, float, float, float. Return type: void.

Property ContentSize
Type: float

Property StepSize
Type: float

Property BarSize
Type: float

Property BarPosition
Type: float

Property BackgroundShade / BGShade
Type: float

GUISprite

Constructor GUISprite()

Constructor GUISprite(fileName, position)
Parameter types: string, VectorScreen

Constructor GUISprite(fileName, position, colour)
Parameter types: string, VectorScreen, Colour

Constructor GUISprite(fileName, position, colour, flags)
Parameter types: string, VectorScreen, Colour, int

Property TextureSize
Type: VectorScreen

Property TopLeftUV
Type: Vector

Property BottomRightUV
Type: Vector

Function SetTexture(fileName)
Parameter types: string. Return type: void.

Function Resize()
Return type: void.

GUIWindow

Constructor GUIWindow()

Constructor GUIWindow(position, size, colour)
Parameter types: VectorScreen, VectorScreen, Colour

Constructor GUIWindow(position, size, colour, text)
Parameter types: VectorScreen, VectorScreen, Colour, string

Constructor GUIWindow(position, size, colour, text, flags)
Parameter types: VectorScreen, VectorScreen, Colour, string, int

Property DragOffset (read-only)
Type: VectorScreen

Property TitleColour (bound)
Type: Colour

Re: Major Server Update Released (April 25)
« Reply #3, on April 25th, 2016, 08:48 PM »
New and modified functions of squirrel plugin:
(click to show/hide)
CreateCheckpoint(player, world, isSphere, position, color, radius)
Parameter types: Player, int, bool, Vector, ARGB, float. Return type: Checkpoint.
Additional parameter isSphere, since Sphere functions were removed.

SetBackfaceCullingDisabled(toggle)
Parameter types: bool. Return type: void.
Sets whether the backface culling is disabled, which makes all game triangles be drawn from both sides. This is useful to make GTA 3 map objects look natural.

GetBackfaceCullingDisabled(toggle)
Parameter types: bool. Return type: void.

SetHeliBladeDamageDisabled(toggle)
Parameter types: bool. Return type: void.
Sets whether helicopter blades do damage.

GetHeliBladeDamageDisabled(toggle)
Parameter types: bool. Return type: void.

Event onClientScriptData(player)
Parameter types: Player. Return type: void.
Notifies that scripts from the specified player sent a packet of data, which can be read with the Stream.Read* functions.

Stream.StartWrite()
Return type: void.
Resets stream writing, use this before writing a new packet.

Stream.SetWritePosition(position)
Parameter types: int. Return type: void.
Set the stream buffer position when writing, can be used to rewind the buffer to overwrite some part.

Stream.GetWritePosition()
Return type: int.
Returns the current position in the output stream buffer.

Stream.GetWriteSize()
Return type: int.
Returns the current size of the output stream buffer.

Stream.HasWriteError()
Return type: bool.
Returns whether writing encountered an error (buffer size limit) since the last StartWrite() call.

Stream.WriteByte(value)
Parameter types: int. Return type: void.
Writes one byte to the stream.

Stream.WriteInt(value)
Parameter types: int. Return type: void.
Writes an integer (4 bytes) to the stream.

Stream.WriteFloat(value)
Parameter types: float. Return type: void.
Writes a float (4 bytes) to the stream.

Stream.WriteString(value)
Parameter types: string. Return type: void.
Writes a string to the stream.

Stream.SendStream(player)
Parameter types: Player. Return type: void.
Sends the currently written stream to the specified player, or every player if the parameter is null.

Stream.SetReadPosition(position)
Parameter types: int. Return type: void.
Set the stream buffer position when reading, can be used to rewind the buffer to reread a previously read part.

Stream.GetReadPosition()
Return type: int.
Returns the current position in the input stream buffer.

Stream.GetReadSize()
Return type: int.
Returns the size of the input stream buffer.

Stream.HasReadError()
Return type: bool.
Returns whether reading encountered an error (reading beyond the end of buffer).

Stream.ReadByte(value)
Parameter types: int. Return type: void.
Reads one byte from the stream.

Stream.ReadInt(value)
Parameter types: int. Return type: void.
Reads an integer (4 bytes) from the stream.

Stream.ReadFloat(value)
Parameter types: float. Return type: void.
Reads a float (4 bytes) from the stream.

Stream.ReadString(value)
Parameter types: string. Return type: void.
Reads a string from the stream.
Re: Major Server Update Released (April 25)
« Reply #4, on April 25th, 2016, 08:48 PM »
A sample script using streams to pass data between client and server scripts:

Server script

Code: [Select]
function onClientScriptData(player) {
    local type = Stream.ReadInt();
   
    if (type == 55) {
        Stream.StartWrite();
        Stream.WriteInt(56);
        Stream.WriteByte(Stream.ReadByte() + 1);
        Stream.WriteFloat(Stream.ReadFloat() + 2.2);
        Stream.WriteString("o" + Stream.ReadString() + "!");
        Stream.SendStream(player);
    }
    else {
        print("Received something else");
    }
}

Client script

Code: [Select]
keyJBind <- KeyBind(0x4A);

function KeyBind::OnDown(keyBind) {
    if (keyBind == keyJBind) {
        local message = Stream();
        message.WriteInt(55);
        message.WriteByte(3);
        message.WriteFloat(5.9);
        message.WriteString("lalaya");
        Server.SendData(message);
       
        Console.Print("Sent stuff");
    }
}

function Server::ServerData(stream) {
    local type = stream.ReadInt();

    if (type == 56) {
        Console.Print(stream.ReadByte());
        Console.Print(stream.ReadFloat());
        Console.Print(stream.ReadString());
    }
    else {
        Console.Print("Received something else");
    }
}

This binds the J key to send some data to the server, then server modifies the data a bit and sends back, then client script prints to the game console.

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,807
.

Cool

  • Hero Member
  • Posts: 760
Re: Major Server Update Released (April 25)
« Reply #6, on April 25th, 2016, 09:28 PM »
when i update my server and plugins start error conect sql does not exists
dont be angry on me but i cant understand why i have loaded sqlite plugin

maxorator

  • VC:MP Developer
  • Posts: 159
Re: Major Server Update Released (April 25)
« Reply #7, on April 25th, 2016, 09:29 PM »
Quote from Hercules on April 25th, 2016, 09:28 PM
when i update my server and plugins start error conect sql does not exists
dont be angry on me but i cant understand why i have loaded sqlite plugin
Did you replace the plugins with the new ones? If yes, can you copy-paste any errors you are getting in the console?

Cool

  • Hero Member
  • Posts: 760
Re: Major Server Update Released (April 25)
« Reply #8, on April 25th, 2016, 09:40 PM »Last edited on April 25th, 2016, 09:42 PM
i updated all things and i check plugin name server.cfg but all fine but this error

maxorator

  • VC:MP Developer
  • Posts: 159
Re: Major Server Update Released (April 25)
« Reply #9, on April 25th, 2016, 10:23 PM »
Quote from Hercules on April 25th, 2016, 09:40 PM
i updated all things and i check plugin name server.cfg but all fine but this error
The issue with SQLite was due to server, redownload and try again.

I haven't yet created the new version of INI plugin (wasn't aware people were still using it).

Cool

  • Hero Member
  • Posts: 760
Re: Major Server Update Released (April 25)
« Reply #11, on April 26th, 2016, 12:01 AM »Last edited on April 26th, 2016, 11:03 AM
Thanks
[EDIT] @maxorator  i am on mobile tonight so i didnt test it now i test it but same error

Stormeus

  • VC:MP Developer
  • oh god how did i get here im not good w computer
  • Posts: 1,046

Doom_Kill3R

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,066
Re: Major Server Update Released (April 25)
« Reply #13, on April 26th, 2016, 02:13 AM »Last edited on April 26th, 2016, 03:44 AM
FIIINALLLYYY!!!!

:edit: I updated all the plugins, the server execution file. I created a simple script file. The problem is I can't use any of the global functions or events which are listed up there. I get errors, I tried the client side script @maxorator posted and even that's throwing errors. Do we have to define somewhere that specific files are meant to be client-sided?

This script:
Code: [Select]
function KeyBind::OnDown(keyBind) {
    if (keyBind == keyJBind) {
        local message = Stream();
        message.WriteInt(55);
        message.WriteByte(3);
        message.WriteFloat(5.9);
        message.WriteString("lalaya");
        Server.SendData(message);
       
        Console.Print("Sent stuff");
    }
}

Error: The index 'KeyBind' does not exist.
Server and Plugins type: x64

:edit: Same with 32bit server and plugins. I believe there is a way to mark scripts as client-sided in-order to use these features, perhaps I can't seem to find something like that up there or you forgot to mention?

KAKAN

  • Wiki Contributor
  • Posts: 3,425
Re: Major Server Update Released (April 25)
« Reply #14, on April 26th, 2016, 04:23 AM »
Quote from Doom_Kill3R on April 26th, 2016, 02:13 AM
FIIINALLLYYY!!!!

:edit: I updated all the plugins, the server execution file. I created a simple script file. The problem is I can't use any of the global functions or events which are listed up there. I get errors, I tried the client side script @maxorator posted and even that's throwing errors. Do we have to define somewhere that specific files are meant to be client-sided?

This script:
Code: [Select]
function KeyBind::OnDown(keyBind) {
    if (keyBind == keyJBind) {
        local message = Stream();
        message.WriteInt(55);
        message.WriteByte(3);
        message.WriteFloat(5.9);
        message.WriteString("lalaya");
        Server.SendData(message);
       
        Console.Print("Sent stuff");
    }
}

Error: The index 'KeyBind' does not exist.
Server and Plugins type: x64

:edit: Same with 32bit server and plugins. I believe there is a way to mark scripts as client-sided in-order to use these features, perhaps I can't seem to find something like that up there or you forgot to mention?
Same here.
Either way, great work!
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN