generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: I am having a meltdown please help

Previous Thread :: Next Thread 
TheMrRadioActiveMan is not online. TheMrRadioActiveMan
Joined: 11 Dec 2010
Total Posts: 974
18 Jan 2017 01:21 PM
Hi I am playing around with remote functions and having trouble passing arguments

what i need to happen is this

Server fires event

Server sends data to client

client receives data

clients then sends back ITS OWN response

The WIKI is very unclear on passing arguments


Report Abuse
iYoshiFox is not online. iYoshiFox
Joined: 14 Apr 2012
Total Posts: 1058
18 Jan 2017 01:27 PM
-- Client Side

remoteFunction:InvokeServer(arguments)




-- ServerSide

function remoteFunction.OnServerInvoke(client, arguments)
end


OnServerInvoke always has a 'client' argument, and all other arguments passed are after the 'client' argument.




Hope I helped ^-^
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
18 Jan 2017 01:29 PM
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=200061209


Report Abuse
TheMrRadioActiveMan is not online. TheMrRadioActiveMan
Joined: 11 Dec 2010
Total Posts: 974
18 Jan 2017 01:50 PM
Not quite what I need


I need the SERVER To fire a event ALONG with data+

example
(I am very aware not real code, I am just visualizing)

Server:FIREALLCLIENTS(DATA)

client:OnEvent(SERVERS_DATA)

client: does code using that data

client: Return diff data

Server: gets the data response, waiting for ALL clients (or time)

then moves on using that data
Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
18 Jan 2017 01:52 PM
never allow the client what data the server needs to save..
Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
18 Jan 2017 01:53 PM
never allow the client to tell the ser Er what data it needs to save..*
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
18 Jan 2017 01:54 PM
He justs wants info from the client lol, you sometimes want the server to know which button the client clicked right?
Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
18 Jan 2017 01:54 PM
rip spelling
Report Abuse
TheMrRadioActiveMan is not online. TheMrRadioActiveMan
Joined: 11 Dec 2010
Total Posts: 974
18 Jan 2017 01:57 PM
@pketny


Exactly.
Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
18 Jan 2017 01:58 PM
@pketny
"client: does code using that data

client: Return diff data

Server: gets the data response, waiting for ALL clients (or time)

then moves on using that data"

right there he says the client will return new data to the server to be used
in the case that the data is points, levels, or anything of that nature, that is a bad way to do it
Report Abuse
TheMrRadioActiveMan is not online. TheMrRadioActiveMan
Joined: 11 Dec 2010
Total Posts: 974
18 Jan 2017 01:59 PM
I need the server to do this


Send an alert to the client usinging these vars:

Message
MessageType
color
font
special

using these vars the client is going to create a GUI with some choices

then depending on what choice the client picks it will send that response to the server

so i guess "yes"

then with that data the server can decide what to do with that client
Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
18 Jan 2017 02:02 PM
first create aatable of players in the server, then fireallclients
have an event that fires when a player responds, remove that player from the table
have a loop that waits until the table is empty
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
18 Jan 2017 02:04 PM
You want a RemoteFunction instead
Make one in the ReplicatedStorage named DataFunction

-- client
DataFuncton = game.ReplicatedStorage:WaitForChild("DataFunction")

function DataFunction.OnClientInvoke(data)
for _,v in next, data do
print(v)
end -- just print all the data in the array received
return true -- return whatever you'd like, different data, etc
end
end


-- server
local DataFunction = game.ReplicatedStorage:WaitForChild("DataFunction")
local oldData = {1,2,3,4,5} -- blah blah, alter at will, put inside the function if you want, too
local newData -- the most recent client data

function CollectData()
newData = {}
for _,player in next,game.Players:GetPlayers() do
local response = DataFunction:InvokeClient(player,oldData)
table.insert(newData,response)
end
end


Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
18 Jan 2017 02:05 PM
So jsut do this:


Server:FIREALLCLIENTS(DATA):

local playersSendTo = game.Players:GetPlayers()
local handled

askQuestion:FireAllClients("What do u like more?", "apple", "pear")

wait(time)

if not handled then
---not all players gave their opinion
end

client:OnEvent(SERVERS_DATA) + client: does code using that data + client: Return diff data:

askQuestion.OnClientEvent:connect(function(question, option, option2)
answer1 = option
answer2 = option2


--Set the right text for the right buttons
askingFrame.Visible = true
end)

ButtonOption1.MouseButton1Click:connect(function()
optionChosen:FireServer(answer1)
end

-- same for buttonoption2



Server: gets the data response, waiting for ALL clients (or time)

optionChosen.OnServerEvent:Connect(function(player, option)
---save option
--remove player from playersSendTo

if #playersSendTo == 0 then
-- all players gave opinions
handled = true
end

end)
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
18 Jan 2017 02:07 PM
Sorry, a bit messy, typed it in a hurry, hope you understand
Report Abuse
TheMrRadioActiveMan is not online. TheMrRadioActiveMan
Joined: 11 Dec 2010
Total Posts: 974
18 Jan 2017 02:10 PM
no it wont use andthing that needs to secure


it is alerting the clients a new round is about to start and asking if they want to join
Report Abuse
TheMrRadioActiveMan is not online. TheMrRadioActiveMan
Joined: 11 Dec 2010
Total Posts: 974
18 Jan 2017 02:10 PM
Wow why i typed that a bunch of replies
Report Abuse
TheMrRadioActiveMan is not online. TheMrRadioActiveMan
Joined: 11 Dec 2010
Total Posts: 974
18 Jan 2017 02:15 PM
that makes more sense thanks pt
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
18 Jan 2017 02:52 PM
Use mine.
It is secure if you know what you're doing.
Don't need events


Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
19 Jan 2017 04:20 AM
@Soybeen my code is a bit messy and is meant to be pseudo like. So it has a lot of flaws, but why would using RemoteFunctions instead of RemoteEvents be more 'Secure'?

Also RemoteFunction:InvokeClient is a YieldFunction, so the players will be invoked 1 by 1 instead of all at them same time
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
19 Jan 2017 04:29 AM
wrap it in a coroutine then

data = {}
responded = 0
for i, v in pairs(game.Players:GetChildren()) do
coroutine.wrap(function()
data[p.Name] = remotefunc:InvokeClient(v,data)
responded = responded + 1
end)()
end
repeat wait() until responded == game.Players.NumPlayers
--do stuff with dictionary of data


#code self = nil
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
19 Jan 2017 04:32 AM
NONONONONONONNONOOOOOO
Never hide the fact that something is a tuple.

askQuestion.OnClientEvent:connect(function(question, option, option2)
answer1 = option
answer2 = option2

>>>>

askQuestion.OnClientEvent:connect(function(question, ...)
local answers = {...}
answer1 = answers[1]
answer2 = answers[2]
Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
19 Jan 2017 05:16 AM
https://www.youtube.com/playlist?list=PLatbVFCcsDB9JZE_1WQvmG0i4NrpNIybs


Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow my twitch: twitch.tv/austinrblx
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
19 Jan 2017 05:31 AM
cody why would you do
"local answers = {...}
[local] answer1 = answers[1]
[local] answer2 = answers[2]"

It makes no sense having to create a table for no reason when you could have easily just loaded the tuples into the locals directly.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image