In my game I have a local script for gun that fires a remote event to change a players health. The problem is that hackers could just fire the remote event and change a players health. How do I stop this from happening? Here's the remote event:
script.CHealth.OnServerEvent:connect(function(player,humanoid,amnt)
humanoid.Health = humanoid.Health - amnt
end)
And here's where it's called:
game.Workspace.RemoteEvents.CHealth:FireServer(humanoid,60)
The best way to do it is to not have any vulnerabilities with your code. The player can easily exploit that to give them self health, so you should first check if the number is negative (math.sign).
Next, create a randomized key. The best way to do this is to have a key variable set to 0 on the client and a key variable set also to 0 on the server. Create a function on the client that the entire client will use which fires the remote event with that key, but also does something like adds 1 and multiplies it by 100 (or something more complex). Do the same on the server every time a remote is fired. In every event on the server, check if the key provided is the same one as on the server, and if it isn't then kick them. This way, exploiters won't be able to fire remotes without the key which they won't be able to get.
A simple answer would just be to make the remote event within the script, and when you're done with it, remove it. Also, never put remote events/functions in workspace, the safest place to put them is replicated storage.
local remoteevent = Instance.new("RemoteEvent")
remoteevent.Parent = game.ReplicatedStorage.RemoteEvents
remoteevent.Name = "CHealth"
game.ReplicatedStorage.RemoteEvents.CHealth:FireServer(humanoid,60)
For the other script:
script.CHealth.OnServerEvent:connect(function(player,humanoid,amnt)
humanoid.Health = humanoid.Health - amnt
game.ReplicatedStorage.RemoteEvents.CHealth:Remove()
end)
This was just the first way I thought of. I didn't test the script, there may be some spelling errors I didn't catch or something like that, so if there is an error you can always think of that.
If someone hacks with filtering enabled, then fires that event, it will only look like they took damage for them. Also, I think hackers inject server scripts, and server scripts don't work on the client. Here are some good articles: http://wiki.roblox.com/index.php?title=Experimental_Mode | http://wiki.roblox.com/index.php?title=Building_Games_with_Experimental_Mode_Off
Related
I'm in a pickle. (not literally, of course)
I had a ship game, which used Proximity Prompts to enter the docks. This worked well enough. However, that was for a click to move system, and now I'm attempting to make a direct control system (e.g. you press WASD to move your ship instead of clicking a point on the ocean), and as such, there is no character in the game, and have done everything else without a character.
In short: They don't work now and I have no clue why.
The script is near enough the exact same on both games (The original game's script has a lot more other functions in it, but nothing that would affect this), and so is the configuration of the Proximity Prompt. But I don't see how it could be to do with the lack of a player Character, and if it is, how do I edit the default code for it, to work without one? (I had a look, but couldn't find anything useful) As it doesn't seem like it will have direct dependence on the character, as any animations or custom behaviour would have to be done connecting to the ProximityPromptService/Prompt itself to add those via the events.
This is literally the whole server-side script I have for it.
local proximitypromptservice = game:GetService("ProximityPromptService")
local function get_player_data (player)
... --Unrelated, it's just a function to get player data, no issues here.
end
proximitypromptservice.PromptTriggered:Connect(function(promptobject,player)
print("Prompt TRIGGERED") --Not seen in the log when the Prompt is pressed.
if promptobject.Name == "DockControl" then
print("DOCKCONTROL")
if player.IsLoading.Value == false then
game.ReplicatedStorage.Dock.AccessDock:Fire(player,...)
end
end
end)
It's probably worth noting that when you press the key, e.g. E, it does the hold Duration animation and then disappears, and reappears as you'd normally expect. Creating a custom docking system is not out of the question, but I would really really prefer not to create an overcomplicated, clunky system for something that should work out of the box.
Any help would be appreciated,
The Frog.
PS: Also tried this on both local and server scripts as a child of the prompt to no avail.
script.Parent.Triggered:Connect(function()
print("TRIGGERED")
end)
sir,
I am trying to create stateful proxy in opensips 2.4.
I just wanted a variable to hold received message information and process it.
So i checked "core variable" in opensips manual.it says, script variable are process wise. So i should not use to hold header value in script value like $var(Ruri)=$ru?? it will be overwritten by other call??
$var(userName)=$rU;
$var(removePlus) = '+';
# Search the string starting at 0 index
if($(var(userName){s.index, $var(removePlus)})==0){
$rU=$(var(userName){s.substr,1,0});
}
$var variables are process-local, meaning that you can't share them with other SIP workers even if you wanted to! In fact, they are so optimized that their starting value will often be what the same process left-behind during a previous SIP message processing (tip: you can prove this by running opensips with children = 1 and making two calls).
On the other hand, variables such as $avp are shared between processes, but not in a "dangerous" way that you have to worry about two INVITE retransmissions processing in parallel, each overwriting the other one's $avp, etc. No! That is taken care of under the hood. The "sharing" only means that, for example, during a 200 OK reply processed by a different process than the one which relayed the initial INVITE, you will still be able to read and write to the same $avp which you set during request processing.
Finally, your code seems correct, but it can be greatly simplified:
if ($rU =~ "^+")
strip(1);
Whenever I try to do this set of code in robloxian lua, I can't access the textbox. This code is suppost to do this, but I think that its accessing the property of the text inside the textbox instead. Here is a somewhat representative of the code that I am using. So, lets say that Bob wants to talk to John. I would write it like this.
game.StarterGui.ScreenGui.Frame.JohnsSpeech.Text = game.StarterGui.ScreenGui.Frame.JohnsUserSetText.Text
Now, JohnsUserSetText is the textbox, and JohnsSpeech is the speech. But when I try to do this, it doesn't work. It just says whatever the text is in the properties. Any help would be appreciated. Thanks! And have a great rest of your day!
Supposed to do what?
.Text is a property of a textbox or anything similar
NOTE: You are changing a starter gui, which means anyone using that current gui won't get the updated one until they die and respawn. If you want to update the one in their GUI access it through Game.Players.playernamehere.PlayerGui
StarterGui is what the game imports into a player when it reloads everything AKA: respawning or joining
if you need tips on updating each players Gui tell me and I can give some examples
Much as M. Ziegenhorn is saying, your issue is that you're referring to the StarterGui, not the PlayerGui.
The StarterGui is the container containing the default GUIs to be given out to the player upon spawn, while PlayerGui (game.Players.Ravenshield.PlayerGui, for instance) is where the GUIs are stored for each player.
The PlayerGui can only be accessed through a LocalScript.
The easiest way to access your PlayerGui is obviously to just place the LocalScript inside the ScreenGui you're using.
Otherwise, you can also access it easily by doing game.Players.LocalPlayer.PlayerGui
If I were to put my LocalScript directly in the ScreenGui we're using, it could look like this:
local TextBox = script.Parent.TextBox
local SpeechLabel = script.Parent.SpeechLabel
SpeechLabel.Text = TextBox.Text
However, you probably want to add text whenever they write it into the TextBox. Then we need to take a look at the documentation for ROBLOX, and specifically the TextBox Object.
If you scroll down to the Events, you can take a look at the TextBox.Changed event. This will fire everytime a property of the TextBox changes.
We could also use TextBox.FocusLost, which fires when the client has unfocused the TextBox. The event supplies a boolean 'enterPressed' which tells us whether or not the client pressed enter to lose focus.
local TextBox = script.Parent.TextBox
local SpeechLabel = script.Parent.SpeechLabel
TextBox.FocusLost:Connect(function(enterPressed)
if enterPressed then -- Checking if the enterPressed is true and not nil
-- The user must have pressed enter to exit the TextBox.
-- Could mean that they're done writing something.
SpeechLabel.Text = TextBox.Text
end
end)
All events have to be bound by using the :Connect method. This is what tells ROBLOX to start 'listening' to the event, to make sure the function fires every time this occurs.
I've been poring over this subject for the past 12 hours, and I simply cannot seem to get anywhere. I do not even know if this is possible, but I'm hoping it is because it would go a long way to continuing my project.
What I am attempting to do is create coroutines so the particular program I use does not freeze up due to its inability to perform asynchronous http requests. I've figured out how to do that part, even though my understanding of coroutines is still in the "Huh? How does that work?" phase. My issue now is being able to respond to multiple requests with the correct information. For instance, the following should produce three separate responses:
foo(a)
foo(b)
foo(c)
where foo initiates a coroutine with the parameters inside. If all requested separately, then it returns the proper results. However, if requested as a block, it will only return foo(c)'s result. Now, I understand the reasoning behind this, but I cannot find a way to make it return all three results when requested as a block. To help understand this problem a bit, here's the actual code:
function background_weather()
local loc = url.escape(querystring)
weatherpage = http.request("http://api.wunderground.com/api/004678614f27ceae/conditions/q/" .. loc .. ".json")
wresults = json.decode(weatherpage)
--process some stuff here, mainly datamining
end
--send datamined information as a response
coroutine.yield()
end
And the creation of the coroutine:
function getweather ()
-- see if backgrounder running
if background_task == nil or
coroutine.status (background_task) == "dead" then
-- not running, create it
background_task = coroutine.create (background_weather)
-- make timer to keep it going
AddTimer ("tickler", 0, 0, 1, "",
timer_flag.Enabled + timer_flag.Replace,
"tickle_it")
end -- if
end -- function
The querystring variable is set with the initial request. I didn't include it here, but for the sake of testing, use 12345 as the querystring variable. The timer is something that the original author of the script initialized to check if the coroutine was still running or not, poking the background every second until done. To be honest, I'm not even sure if I've done this correctly, though it seems to run asynchronously in the program.
So, is it possible to receive multiple requests in one block and return multiple responses, correctly? Or is this far too much a task for Lua to handle?
Coroutines don't work like that. They are, in fact, blocking.
The problem coroutines resolve is "I want to have a function I can execute for a while, then go back to do other thing, and then come back and have the same state I had when I left it".
Notice that I didn't say "I want it to keep running while I do other things"; the flow of code "stops" on the coroutine, and only continues on it when you go back to it.
Using coroutines you can modify (and in some cases facilitate) how the code behaves, to make it more evident or legible. But it is still strictly single-threaded.
Remember that what Lua implements must be specified by C99. Since this standard doesn't come with a thread implementation, Lua is strictly single-threaded by default. If you want multi-threading, you need to hook it to an external lib. For example, luvit hooks Luajit with the libuv lib to achieve this.
A couple good references:
http://lua-users.org/wiki/CoroutinesTutorial
http://lua-users.org/wiki/ThreadsTutorial
http://lua-users.org/wiki/MultiTasking
http://kotisivu.dnainternet.net/askok/bin/lanes/comparison.html
Chapter 9.4 of Programming in Lua contains a fairly good example of how to deal with this exact problem, using coroutines and LuaSocket's socket.select() function to prevent busylooping.
Unfortunately I don't believe there's any way to use the socket.http functions with socket.select; the code in the PiL example is often all you'll need, but it doesn't handle some fairly common cases such as the requested URL sending a redirect.
How do you make a combo of two emotes in lua in World of Warcraft work?
function Button2_OnClick()
PlaySoundFile("Interface\\Addons\\Fart\\common_fart[1].wav");
DoEmote("moon");
DoEmote("sit");
DoEmote("dance");
DoEmote("beckon");
end
I am using Wow Addon Studio to make a fart application on Wow.
I used this function, and only the sit motion showed, and beckon and moon only showed on the chat window. The dance emote didn't show up anywhere.
Blizzard has explicitly prohibited anything that can be used to make lua wait or pause because it is an essential ingredient to making a gold mining or grinding bot.
There isn't a native (i.e. lua only) way to have lua wait without using all the CPU. Outside of the WOW client, you'd use win.sleep or some other 3rd party API call that calls into the host application or operating systems threading functions.
It may be possible to simulate a wait by having code execute on a frequent event (such as text arriving at the chat window) and then in the event handler checking to see if enough time has passed to permit executing the next command in the sequence. This probably wouldn't be a very accurate timer and it would be rather complex as you'd have to create a data structure to hold the sequence of commands, the timings between each, the current command, etc. and so on.
This may be an intentional limitation of the API to prevent in game automation (botting).
What has worked for me is to have a global variable that is incremented through the loop. Such as
Integer count = 0;
function Button2_OnClick()
i++
switch
case(1)
PlaySoundFile("Interface\\Addons\\Fart\\common_fart[1].wav");
case(2)
DoEmote("moon");
case(3)
DoEmote("sit");
case(4)
DoEmote("dance");
case(5)
DoEmote("beckon");
default
i=0;
end
end
What you would have to do then is to click the button multiple times, but you would get the effect you're going for.
I would suggest you wait some time before doing the next emote. As far as I know, the server disconnects you if you spam too much. This might just trigger it sometimes.
Besides that, I guess maybe the client has a way of preventing it? In either case, I would suggest you add some sort of fraction-of-a-second delay between the emotes.
Cheers,
Amit Ron
Could it be that the last two can't be done while sitting?
infact, integer i = 0, because defining integer 'count' and then using i is incorrect. :)