a Doubt about auto-update in GuiLabel

Started by Maximiliano, Dec 30, 2018, 01:28 AM

Previous topic - Next topic

Maximiliano

Hello, good morning.
 I have a doubt that I hope someone solves it ...
How can I update my GUILabel every time the amount of money of a player is modified?

[spoiler]
 cash <- GUILabel(VectorScreen( scr.X * 0.82, scr.Y * 0.24 ),Colour(51, 160, 254), "$" + cashh +" ");
 cash.FontSize = 27.1;
 cash.FontFlags = GUI_FFLAG_BOLD;
[/spoiler]






umar4911

I am gamer, programmer and hacker. Try to find me!
xD


umar4911

When a player is killed, you update cash of player in server side (player.Cash) and send it to client.
function OnPlayerKill(killer, player, body, reason)
{
 killer.Cash += 200;
 SendDataToClient(killer, 1, killer.Cash);
}

function SendDataToClient(player, integer, string)
{
 Stream.StartWrite();
 Stream.WriteInt(integer);
 if (string != null) Stream.WriteString(string);
 Stream.SendStream(player);
}

When you receive data from server, update the GUI text.
function Server::ServerData(stream) {

 local StreamReadInt = stream.ReadInt(),
  StreamReadString = stream.ReadString();
 switch (StreamReadInt.tointeger())
 {
  case 1:
   cash.Text <- StreamReadString;
   break;

}
}
I am gamer, programmer and hacker. Try to find me!
xD

Maximiliano

Quote from: umar4911 on Dec 31, 2018, 05:48 AMWhen a player is killed, you update cash of player in server side (player.Cash) and send it to client.
function OnPlayerKill(killer, player, body, reason)
{
 killer.Cash += 200;
 SendDataToClient(killer, 1, killer.Cash);
}

function SendDataToClient(player, integer, string)
{
 Stream.StartWrite();
 Stream.WriteInt(integer);
 if (string != null) Stream.WriteString(string);
 Stream.SendStream(player);
}

When you receive data from server, update the GUI text.
function Server::ServerData(stream) {

 local StreamReadInt = stream.ReadInt(),
  StreamReadString = stream.ReadString();
 switch (StreamReadInt.tointeger())
 {
  case 1:
   cash.Text <- StreamReadString;
   break;

}
}

Thx :D