Cuberite Forum

Full Version: 2 arguments in same local or same value
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm trying to store 2 return values in the same local and then store it in a ini file.
Here is the code I made:
Code:
function HandleChunkCommand( Player, Entity )
      ChunksIni = cIniFile( "chunks.ini")
      local ChunkPos = Entity:GetChunkX(),Entity:GetChunkZ()
      ChunksIni:SetValue(ChunkPos,   "Claimed",   1)
      ChunksIni:WriteFile()
      return true
end
It only stores ChunkX, no ChunkZ.
If I do print(Entity:GetChunkX(),Entity:GetChunkZ()) it gives me chunkX and ChunkZ but how can I store it in a local?
Easiest thing to do would be to insert both into a table and then join.
You cannot store two values in a single variable...
Try this:
Code:
ChunksIni:SetValue(Entity:GetChunkX() .. ":" .. Entity:GetChunkZ(),   "Claimed",   1)
This should work:
local ChunkPosX, ChunkPosZ = Entity:GetChunkX(), Entity:GetChunkZ()
you can't store two values in one variable.
Undecided Having more problems
Code:
function HandleClaimChunkCommand( Player, Entity )
      ChunksIni = cIniFile( "chunks.ini")
      ChunksIni:ReadFile()
      if (ChunksIni:FindKey(Entity:GetChunkX() .. ":" .. Entity:GetChunkZ())<0) then
            ChunksIni:AddKeyName(Entity:GetChunkX() .. ":" .. Entity:GetChunkZ())
            ChunksIni:SetValue(Entity:GetChunkX() .. ":" .. Entity:GetChunkZ(),   "Claimed",   1)
            ChunksIni:WriteFile()
      else
            Player:SendMessage("This chunk is already claimed")
            return true
      end
      return true
end
Why does it tell SendMessage is a nil value?

I tested with a simple command that sends you a message and you need to use split in the function, but in my command if I use Split then Entity is a nil value and I cant get chunk pos
Fixed myself Smile
You've mixed up the parameters, they are (Split, Player), not (Player, Entity)

Still, basing any kind of protection scheme on cIniFile is a really really bad idea.
(09-30-2013, 11:20 PM)xoft Wrote: [ -> ]Still, basing any kind of protection scheme on cIniFile is a really really bad idea.
Why?
Its slow
My plugin it's going fine, commands are nearly done, but then I'll need to do hooks. Hope it's finished soon. It will be the first plugin to let players claim areas without the need of an admin.
Pages: 1 2