Hello.
I want to create an addon that when you go to an npc a menu opens and you choose an alert (1, 2, 3 ...), then there is a text in the hud that says "Alert Level: " and then the number of the alert.
I have done the derma, the buttons and everything but I do not know how to change the number by pressing a button of the derma.
The only thing I have achieved on my own is to change but only to the person who presses it, not for everyone.
What I want to know how to do is change the alert number of the hud by pressing a button on the derma of the npc.
When someone presses the button of alert 1, I want it to put on the hud (already created) alert 1.
Sorry for my english.
If you need to create alarm for all players you .net
In .net you transfer alarm number, then server broadcasts it
Net Library Usage
It's not .net, just call it the network library
The .network library
Sorry, if I confused you with .NET Framework
More Information:
I have a NPC. There you choose the alert.
Then I want a text on the hud that says "Alert Level: (and here the number of the alert pressed in the npc)"
I know how to make the text appears in the hud, but i dont know how to make appear the number that was selected on the npc.
Can someone give me a working example?
-- CLIENT
dermaButton = ButtonWithAlertNumber
dermaButton.number = 3
dermaButton.DoClick = function()
net.Start("NPCAlertBroadcast")
net.WriteFloat(dermaButton.number)
net.SendToServer()
end
-- SERVER
net.Receive("NPCAlertBroadcast",function(len,ply)
net.Start("NPCAlertBroadcast")
net.WriteFloat(net.ReadFloat())
net.Broadcast()
end)
-- CLIENT
net.Receive("NPCAlertBroadcast",function()
local number = net.ReadFloat()
end
-- Then redirect number to HUD
You might want to do some checks on server-side. After this line:
net.Receive("NPCAlertBroadcast",function(len,ply)
For example, make sure the player is looking at the NPC and add a cooldown, to make sure the players' huds aren't getting spammed.
Sorry, you need to Log In to post a reply to this thread.