• Ulx slay next round TTT
    6 replies, posted
Ok so i'm building my own ulx command to slay a player the next time that they spawn. Now in doing so i need to save some variables specific to the player for example the number of rounds for them to be slain, their id and weather they should be banned if they leave during that time. now would it be better to save the information as PData on the player like ply:SetPData("slay_rounds", "5") and then do that for different variables for each player. Or to save these in a table for example slaynt_plys={ {} , {} } and then set the player to slaynt_plys[1], their slays to slaynt_plys[1][1] and foce kick to slaynt_plys[1][2] in the form of true and false. Abit confusing yes, and the only reason i don't want to post code is because i'm quite new and this is something that's actually going quite well and that i would like to for my own server. So this is probably a question for advanced lua programmers, which would you choose and which will be easier to utilize and keep clean?
Use a table, PData is a bad idea. [editline]25th April 2013[/editline] If you need any help I can. Just pm me
Thanks, i thought that tables were a better idea as well, will the table reset if the map changes though, that would be rather annoying.
[QUOTE=Pandaman09;40424599]Use a table, PData is a bad idea. [editline]25th April 2013[/editline] If you need any help I can. Just pm me[/QUOTE] PData is a good idea if you want it to save between map changes. It is what I used for my autoslay
[QUOTE=The Android1;40429849]PData is a good idea if you want it to save between map changes. It is what I used for my autoslay[/QUOTE] I never knew that pdata saved between map changes.
Well if tables will keep it cleaner and pdata saves between maps, i could temporarily convert to pdata with a function that's called before map change, if there's a hook that does that. Would it be better to go with just pdata or with a combination of tables and pdata?
How else can i store the information from the table, pdata seems a bit unclean, any other ways i could do this? [editline]26th April 2013[/editline] I've also been looking at hooks i could use to transfer the table to pdata, and vice versa, [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexfa7e.html[/url] and [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9068.html[/url] seem like the two hooks to use, can anyone verify this? [editline]26th April 2013[/editline] Alright just letting you guys know that hook "ShutDown" is called just before switching maps, and the hook "InitPostEntity" is called after, still not sure if i should go with tables and pdata though, which one is the best?? solution, pdata or pdata with tables, any other solutions?
Sorry, you need to Log In to post a reply to this thread.