2 arguments in same local or same value
#1
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?
Reply
Thanks given by:
#2
Easiest thing to do would be to insert both into a table and then join.
Reply
Thanks given by:
#3
You cannot store two values in a single variable...
Try this:
Code:
ChunksIni:SetValue(Entity:GetChunkX() .. ":" .. Entity:GetChunkZ(),   "Claimed",   1)
Reply
Thanks given by: tonibm19
#4
This should work:
local ChunkPosX, ChunkPosZ = Entity:GetChunkX(), Entity:GetChunkZ()
you can't store two values in one variable.
Reply
Thanks given by:
#5
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
Reply
Thanks given by:
#6
Fixed myself Smile
Reply
Thanks given by:
#7
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.
Reply
Thanks given by:
#8
(09-30-2013, 11:20 PM)xoft Wrote: Still, basing any kind of protection scheme on cIniFile is a really really bad idea.
Why?
Reply
Thanks given by:
#9
Its slow
Reply
Thanks given by:
#10
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.
Reply
Thanks given by:




Users browsing this thread: 8 Guest(s)