Countdown
#51
@STR_Warrior
Thanks.
For my permissions plugin i used this for table.insert:
rank[Player:GetName()] = result;
What is better?
And how can i check if he is in the table?
Reply
Thanks given by:
#52
When you use table.insert you basicly create an array.
local Table = {}
Table.insert(Table, "Test")
print(Table[1]) -- Result is "Test"
Table.insert(Table, "Test2")
print(Table[2]) -- Result is "Test2"
When you use your way:
local Table = {}
Table["Test"] = "Test"
print(Table["Test"]) -- Result is "Test"
You add a key. This is propably better then using table.insert because you already know the name of the key.
If you want to check if he's in the table you can use:
if (rank[Player:GetName()] == nil) then
 -- He\'s not in the table
end
Reply
Thanks given by:
#53
Some new questions:
1. How can i get the number of online players?
So i can check if 5 players are online.
2. How can i copy a folder with lua?
3. How can i delete a folder with lua?
Reply
Thanks given by:
#54
1:
local Amount = cRoot:Get():GetServer():GetNumPlayers()

2 and 3: the cFile class might be able to do something.
Reply
Thanks given by:
#55
(01-16-2014, 12:11 AM)STR_Warrior Wrote: 2 and 3: the cFile class might be able to do something.

Thanks, but cFile can only copy files or not?
Quote: Copies a single file to a new destination

I will copy on startup from the server the backup from the minigame map to the mcserver folder.
And on server stop i will delete the world folder.
Reply
Thanks given by:
#56
(01-16-2014, 12:22 AM)daniel0916 Wrote: I will copy on startup from the server the backup from the minigame map to the mcserver folder.
And on server stop i will delete the world folder.

You might want to consider the Forgetful storage schema, settable in world.ini. It will cause the server to load chunks from the MCA files, but not save them anywhere, so as soon as the chunks are unloaded (all players log out or move too far away) the chunks seemingly regenerate back to their previous state.
http://wiki.mc-server.org/doku.php?id=co...ge_section
Reply
Thanks given by:
#57
(01-16-2014, 12:49 AM)xoft Wrote: You might want to consider the Forgetful storage schema, settable in world.ini. It will cause the server to load chunks from the MCA files, but not save them anywhere, so as soon as the chunks are unloaded (all players log out or move too far away) the chunks seemingly regenerate back to their previous state.
http://wiki.mc-server.org/doku.php?id=co...ge_section

Thanks i will try it Smile.

The Schedule with onTick or onWorldTick don't work.

function AddSchedule(Function, Parameters, Ticks)
  table.insert(ScheduleTable, {Function, Parameters, Ticks})
end
 
function OnScheduleTick(Time)
    for I=1, #ScheduleTable do
        if ScheduleTable[I][4] < 0 then
            ScheduleTable[I][2](ScheduleTable[I][3])
            table.remove(ScheduleTable, I)
        else
            ScheduleTable[I][4] = ScheduleTable[I][4] - 1
        end
    end
end

cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnScheduleTick);

AddSchedule(MyFunction, {}, 200);

function MyFunction(Params)
	cRoot:Get():BroadcastChat("Schedule!");
end

Code:
[16:12:40] Stack trace:
[16:12:40]   [C](-1): (no name)
[16:12:40]   Plugins/SurvivalGames/main.lua(75): (no name)
[16:12:40] Stack trace end
[16:12:40] Error in plugin SurvivalGames calling function <callback>()
[16:12:40] LUA: Plugins/SurvivalGames/main.lua:75: attempt to compare nil with number

In the line is:
if ScheduleTable[I][4] < 0 then
Reply
Thanks given by:
#58
Without the error you get I can't do allot Wink Assuming you didn't forget to put it in the post: did you create the ScheduleTable table?

worktycho implented a cWorld:ScheduleTask function. You could try to use that instead. I have no idea how to use it yet though ;(
EDIT:
Ah you now posted the error now Wink
I think you should change if ScheduleTable[I][4] to ScheduleTable[I][3].
Because when you create a table using braces well.. Let me try to show it:
local Table = {12, 43, 13}
Index:         1    2   3
Reply
Thanks given by:
#59
@STR_Warrior
maybe so?

function OnScheduleTick(Time)
    for I=1, #ScheduleTable do
        if ScheduleTable[I][3] < 0 then
            ScheduleTable[I][2](ScheduleTable[I][3])
            table.remove(ScheduleTable, I)
        else
            ScheduleTable[I][3] = ScheduleTable[I][3] - 1
        end
    end
end
Reply
Thanks given by:
#60
No I think this should work:
function OnScheduleTick(Time)
    for I=1, #ScheduleTable do
        if ScheduleTable[I][3] < 0 then
            ScheduleTable[I][1](ScheduleTable[I][2])
            table.remove(ScheduleTable, I)
        else
            ScheduleTable[I][3] = ScheduleTable[I][3] - 1
        end
    end
end
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)