ULX

Author Topic: Advice  (Read 4003 times)

0 Members and 1 Guest are viewing this topic.

Offline Tomzen

  • Full Member
  • ***
  • Posts: 115
  • Karma: -1
  • A new lua adventurer
    • Thirdage Gaming
Advice
« on: May 16, 2015, 01:31:36 AM »
On my ForceMic command, I use "timer.Create", and "timer.Destroy" (or Remove), however the problem with this is that the timer is recreated every time you join, change map, or restart server as you type !accept which runs timer.Remove( "fmmsg" ), any way to make this so if you type it once, you will never have to again?

Or perhaps I should use something other than a timer?
Finished:
Impersonate
<==> FakePromote/Demote <==> RandomMap <==> ForceMic <==> Search <==> PlayMenu <==
WIP:
ServerMode <==

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Advice
« Reply #1 on: May 16, 2015, 02:55:00 AM »
You can use PData to read from and to the server's (or clients) SQLite database. PData is kept across map changes and server restarts. Have a look at the Player:SetPData and Player:GetPData functions.

With PData, set some kind of key for each player that can be true of false. Do or don't do stuff depending on the value of that key.

Alternatively, you can use some kind of data file. Write the SteamID of all players that accept in there... Then read... In that case, you will need to make use of the file library.

Reading SQLite is (probably) a lot faster than reading flat files though. So you should go with PData. :)

Edit: added some details
« Last Edit: May 16, 2015, 03:18:59 AM by Timmy »

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Advice
« Reply #2 on: May 16, 2015, 09:10:00 AM »
Just use a client convar...  http://wiki.garrysmod.com/page/Global/CreateClientConVar

Less data and stress on your server (not that it would be much anyway).

Offline Tomzen

  • Full Member
  • ***
  • Posts: 115
  • Karma: -1
  • A new lua adventurer
    • Thirdage Gaming
Re: Advice
« Reply #3 on: May 16, 2015, 11:49:18 PM »
Ahaha, again with the convar, thanks Aaron113.
Finished:
Impersonate
<==> FakePromote/Demote <==> RandomMap <==> ForceMic <==> Search <==> PlayMenu <==
WIP:
ServerMode <==

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Advice
« Reply #4 on: May 17, 2015, 12:12:17 AM »
The only problem with using a convar is that it would remember the decision cross server and then the client might not know a new server is using the addon.
You're better off remembering the decision at the server level.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Advice
« Reply #5 on: May 17, 2015, 07:52:32 PM »
The only problem with using a convar is that it would remember the decision cross server and then the client might not know a new server is using the addon.
You're better off remembering the decision at the server level.
That is true unless it is something custom.

Offline Tomzen

  • Full Member
  • ***
  • Posts: 115
  • Karma: -1
  • A new lua adventurer
    • Thirdage Gaming
Re: Advice
« Reply #6 on: May 18, 2015, 01:24:56 AM »
I've already finished it, so there's no point of replying to this anymore -.-
Finished:
Impersonate
<==> FakePromote/Demote <==> RandomMap <==> ForceMic <==> Search <==> PlayMenu <==
WIP:
ServerMode <==

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Advice
« Reply #7 on: May 18, 2015, 03:08:46 AM »
Except for the fact that you didn't take the advice you asked for.
The way you are doing it could go something like this.


Player joins server A with your addon. They accept the warning. They know that server A might be monitoring their mic.
Player joins server B with your addon. Because of the way you are handling it, they never see the warning. They have no idea that server B might be monitoring their mic.

The warning is pointless at this point because it doesn't warn them at all after they've been to a single server that has the plugin. That isn't the purpose of the warning.

I understand if you want to make the warning have some way of remembering their choice so it doesn't pop up all the time, but you need to make it per server, not per client.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Advice
« Reply #8 on: May 18, 2015, 08:57:32 AM »
Basically, you can't have the warning on client side. You need to have (btw, I haven't look at the code of your addon, so I'm assuming you've decided to use PData) it in your server side. So basically, when a player joins server A, the server side sends a usmg telling them to activate the pop up message. Then when you type !accept (or w/e it is), it reads it in the server side PData.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Advice
« Reply #9 on: May 18, 2015, 10:50:54 AM »
He is currently using a client ConVar.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Advice
« Reply #10 on: May 18, 2015, 04:08:28 PM »
He is currently using a client ConVar.

Yeah, I never have used ConVar's in any of my addons because I don't really understand them correctly, they caused issues and such, so I've always just use PData, usmg, and net messages. That's the only way to go in this life.

Pdata 4 life dog
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Advice
« Reply #11 on: May 18, 2015, 04:38:59 PM »
I guess I didn't read that is was for his forcemic command.  I would definitely use something serverside then.  Otherwise players will not get notified over different servers.