Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Nihongo^ on Dec 19, 2017, 06:22 AM

Title: GUI Not showing the value
Post by: Nihongo^ on Dec 19, 2017, 06:22 AM
Hello one of my friend put a function name GUI. Most of you guys aware about it . So the problem is its not showing the value in server
Like if i have 1 Gems on my db. It won't show 1 the value remain 0 nor it update.

/*
Scripted by: Doom_Kill3R
P.S: Hello Wireshark users!
*/

// Screen
sW <- GUI.GetScreenSize().X;
sH <- GUI.GetScreenSize().Y;

// Constants
const C_SERVER_NAME = "Grand Theft Auto San Fierro";

// Globals
sClientLevel <- "Rank: Member";
sClientGems <- null;
LabelGems_ClientLabel <- null;
Label_ClientLabel <- null;
Label_ServerName <- null;

function Script::ScriptLoad()
{


::LabelGems_ClientLabel <- GUILabel( VectorScreen( 0, sH * 0.95 ), Colour( 221, 17, 0 ), "Gems: 0");
local TextWidth = ::LabelGems_ClientLabel.Size.X * 6;
::LabelGems_ClientLabel.Position.X = sW - TextWidth;
::LabelGems_ClientLabel.FontFlags = GUI_FFLAG_BOLD;
::LabelGems_ClientLabel.TextAlignment = GUI_ALIGN_LEFT;
::LabelGems_ClientLabel.FontSize = 15;


::Label_ClientLabel <- GUILabel( VectorScreen( 0, sH * 0.95 ), Colour( 0, 255, 22 ), "Rank: Member" );
local TextWidth = ::Label_ClientLabel.Size.X * 2;
::Label_ClientLabel.Position.X = sW - TextWidth;
::Label_ClientLabel.FontFlags = GUI_FFLAG_BOLD;
::Label_ClientLabel.TextAlignment = GUI_ALIGN_LEFT;
::Label_ClientLabel.FontSize = 15;

        Label_ServerName <- GUILabel( VectorScreen( 0, sH * 0.95 ), Colour( 255, 255, 0 ), C_SERVER_NAME );
Label_ServerName.FontFlags = GUI_FFLAG_BOLD;
Label_ServerName.TextAlignment = GUI_ALIGN_LEFT;
Label_ServerName.FontSize = 16;


}


function Server::ServerData( stream ) {
switch( stream.ReadInt() ) {
case 0:
{
::sClientLevel = stream.ReadString();
::Label_ClientLabel.Text = "Rank: " + ::sClientLevel;

local TextWidth = ::Label_ClientLabel.Size.X * 2;
::Label_ClientLabel.Position.X = sW - TextWidth;
break;
}
case 1:
{
::sClientGems = stream.ReadInt();
::LabelGems_ClientLabel.Text = "Gems: " + ::sClientGems ;

local TextWidth = ::LabelGems_ClientLabel.Size.X * 6;
::LabelGems_ClientLabel.Position.X = sW - TextWidth;
      break;
}
}
}
Title: Re: GUI Not showing the value
Post by: DizzasTeR on Dec 19, 2017, 07:30 AM
It seems this is a script I had made for my friend if I recall correctly maybe @Decent_946 but I'm not sure. Other than that, if you want it to update, you have to send a stream from server with the new value and update it on client. Check some client scripts to get an idea how to send streams from server to client with data
Title: Re: GUI Not showing the value
Post by: Nihongo^ on Dec 19, 2017, 12:30 PM
Well its seems hard for me to learn about GUI. Become more better if someone made a video and guide newbies
Like i don't really understand about these some lines
When i change ""Gems: 0"; " to "Gems: 1"; It shows the value 1  which mean GUI is not reading value from DB.

(https://s13.postimg.org/od436chd3/image.png)
Look at the bottom what's the use of

Gems: " + ::sClientGems ;
Title: Re: GUI Not showing the value
Post by: Darran on Dec 20, 2017, 06:22 AM
Quote from: Doom_Kill3R on Dec 19, 2017, 07:30 AMIt seems this is a script I had made for my friend if I recall correctly maybe @Decent_946 but I'm not sure. Other than that, if you want it to update, you have to send a stream from server with the new value and update it on client. Check some client scripts to get an idea how to send streams from server to client with data

btw  decent made script for me