This topic was marked solved by its starter, on December 31st, 2018, 04:33 PM

Maximiliano

  • Newbie
  • Posts: 20
a Doubt about auto-update in GuiLabel
«  »Last edited
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?

(click to show/hide)
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;






umar4911

  • Sr. Member
  • Creating own server!
  • Posts: 475
I am gamer, programmer and hacker. Try to find me!
xD

Maximiliano

  • Newbie
  • Posts: 20

umar4911

  • Sr. Member
  • Creating own server!
  • Posts: 475
Re: a Doubt about auto-update in GuiLabel
« Reply #3,  »
When a player is killed, you update cash of player in server side (player.Cash) and send it to client.
Code: [Select]
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.
Code: [Select]
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

  • Newbie
  • Posts: 20
Re: a Doubt about auto-update in GuiLabel
« Reply #4,  »
Quote from umar4911 on December 31st, 2018, 05:48 AM
When a player is killed, you update cash of player in server side (player.Cash) and send it to client.
Code: [Select]
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.
Code: [Select]
function Server::ServerData(stream) {

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

}
}
Thx :D