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 » Scripting Helpers
Home Search
 

Re: data persistence problem...

Previous Thread :: Next Thread 
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 09:49 PM
how come this:

game.Players.PlayerAdded:connect(function(p)
a = Instance.new("StringValue", p)
a.Name = "Map"
a.Value = ""
end)

game.Players.PlayerAdded:connect(function(p)
p:WaitForDataReady()
C = p:LoadString("Map")
p.Map.Value = C
print("had, value = '"..p.Map.Value.."'")
end)

game.Players.PlayerRemoving:connect(function(p)
p:WaitForDataReady()
c = p:FindFirstChild("Map")
if c then
p:SaveString("Map", c.Value)
end
end)

does not make this recognize that I have a map value already?

wait(10)
if game.Players.LocalPlayer.Map.Value=="" then

I even put in a wait but it is always saying that this if is true
Report Abuse
misgav11 is not online. misgav11
Joined: 21 Apr 2011
Total Posts: 3418
13 Sep 2012 09:52 PM
make different functions, that the problem.
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 09:59 PM
what do you mean by that?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 Sep 2012 10:00 PM
function Entered(Player)
end

function Removing(Player)
end

game.Players.PlayerAdded:connect(Entered)

game.Players.PlayerRemoving:connect(Removing)
Report Abuse
misgav11 is not online. misgav11
Joined: 21 Apr 2011
Total Posts: 3418
13 Sep 2012 10:03 PM
function string(p)
a = Instance.new("StringValue", p)
a.Name = "Map"
a.Value = ""
end

function load(p)
p:WaitForDataReady()
C = p:LoadString("Map")
p.Map.Value = C
print("had, value = '"..p.Map.Value.."'")
end

game.Players.PlayerAdded:connect(function (new)
if new:findFirstChild("Map"} == nil then
string(new)
else
load(new)
end
end)

game.Players.PlayerRemoving:connect(function(p)
p:WaitForDataReady()
c = p:FindFirstChild("Map")
if c then
p:SaveString("Map", c.Value)
end
end)
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
13 Sep 2012 10:08 PM
Make your variables local variables, too.
You may be cross-interpreting other players' maps.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
13 Sep 2012 10:09 PM
@misgav

His original script is just fine. He did use functions. He used anonymous functions.
They're all valid.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
13 Sep 2012 10:09 PM
Also, LocalScripts do NOT have access to Data Persistence. You'll have to save DP form the server.
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:13 PM
the saving script is in the workspace, the script with the if is using a value that the save/load script is supposed to make, im trying to do what you suggested on this thread:

http://www.roblox.com/Forum/ShowPost.aspx?PostID=78028898
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 Sep 2012 10:14 PM
Are two onplayerentered:connect(...) like, allowd like that?
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:17 PM
there is no output saying it isn't...
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
13 Sep 2012 10:20 PM
You're testing Online? As in, actually playing the game?
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:21 PM
testing play solo for output, in game for data persistence
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
13 Sep 2012 10:22 PM
That condition will always be true in Solo, and I'm not sure what you're doing to check the value.
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:24 PM
im generating terrain made of bricks with a table and the table is saved like you helped me with yesterday, but when I play once I get 1 map, when i play a second time the thing looks completely different because it did not save
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 Sep 2012 10:25 PM
did you use

WaitForDataReady
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:28 PM
I just did this:
wait(10)
if game.Players.LocalPlayer.Map.Value=="" then
--code to randomly make a new table
else
--use saved map value...
--code to generate a table with saved map value or map just created if there is no save thing.
end

because doesn't waitfordata ready just wait until the data is ready which means that it will never go on with the script if the person has not played before?

(I did use it in the load script though but that is posted above)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 Sep 2012 10:31 PM
Is it a normal script, not local
did you have enough ends
did you see and typos
what is el'io outputo
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:39 PM
no output, no typos, the only reason i am making the array a string value is because the save load script is a normal script and i need the script that uses the array to be local
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
13 Sep 2012 10:43 PM
What if we combine both PlayerAdded event callbacks?


game.Players.PlayerAdded:connect(function(p)
a = Instance.new("StringValue", p)
a.Name = "Map"
a.Value = ""

p:WaitForDataReady()
local C = p:LoadString("Map")
a.Value = C
print("had, value = '"..p.Map.Value.."'")
end)


game.Players.PlayerRemoving:connect(function(p)
p:WaitForDataReady()
local c = p:FindFirstChild("Map")
if c then
p:SaveString("Map", c.Value)
end
end)
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:51 PM
@agent, im testing your idea right now...
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 10:56 PM
doesnt work.... I just had an idea though... let me test ittttttt
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 11:17 PM
uhh.... glitch? now it only generates the edges of the terrain so it is like this: (0=empty...)


map = {
{1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
{1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
{1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
{1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1}};
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 11:17 PM
but it does save... so could the data just be over the limit for a string value so it saves only parts of it?
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
13 Sep 2012 11:41 PM
never mind, it does not save but it generates the same thing every time i play it in multi-player, but if i play it in solo it works...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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