Raised This Month: $51 Target: $400
 12% 

admin exec command only happens after entire script runs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ichthys
Veteran Member
Join Date: Dec 2004
Location: []*[]
Old 05-16-2005 , 03:12   admin exec command only happens after entire script runs
Reply With Quote #1

Well heres something kinda wierd.
I was trying to get an admin check to work. It was basically supposed to run a rcon command on the admin to see if they had admin access. The problem was, the exec'd command on the admin/player only happened after the script could check whether the rcon command was executed.

player_say.cfg
Code:
setinfo isadmin 0
es ma_exec event_var(es_username) nm_rcon isadmin 1
if (event_var(text) equalto admin) then if (server_var(isadmin) equalto 1) then es_tell event_var(userid) You are an admin
So this didn't work. I then put a whole bunch of es_msg server_Var(isadmin) between the es ma_exec event_var(es_username)..... and the check of isadmin by the script. It printed lines of 0's and then exec'ed the ma_exec, only after the event!
Tried exec'ing other .cfgs, didn't work.
__________________
ichthys is offline
Mattie
Veteran Member
Join Date: Jan 2005
Old 05-16-2005 , 08:10   Re: admin exec command only happens after entire script runs
Reply With Quote #2

Quote:
Originally Posted by ichthys
Well heres something kinda wierd.
I was trying to get an admin check to work. It was basically supposed to run a rcon command on the admin to see if they had admin access. The problem was, the exec'd command on the admin/player only happened after the script could check whether the rcon command was executed.

player_say.cfg
Code:
setinfo isadmin 0
es ma_exec event_var(es_username) nm_rcon isadmin 1
if (event_var(text) equalto admin) then if (server_var(isadmin) equalto 1) then es_tell event_var(userid) You are an admin
So this didn't work. I then put a whole bunch of es_msg server_Var(isadmin) between the es ma_exec event_var(es_username)..... and the check of isadmin by the script. It printed lines of 0's and then exec'ed the ma_exec, only after the event!
Tried exec'ing other .cfgs, didn't work.
ma_cexec will always be slow. (Regardless if ES is involved or not.) You can't count on it for something like this. All that command does is "send a message to client telling him he's forced to do this command". It doesn't wait for any response, and a response may never appear (if the client was locked-up or dropped the packet or something else). It's always going to be later because the server will execute this script in a few milliseconds, tops. The remote command will take at least the client's latency *2 to get back to you (e.g. about 140+ milliseconds for my connection to my server). This is just inherent in Mani's (and all plugins') client execute commands.

In order to try to get around this, sometimes I'll have the player say something and setup an alias/test in player_say such that it will do what I want.

You might be able to use an es_delayed for the verification, but keep in mind that excessive delays might prevent the message from being received when you want. I've seen really long delays sometimes when doing an "ma_cexec_all say Hello" from some players in certain circumstances.

In this specific test, I'd just write something like this:
Code:
es ma_exec event_var(userid) nm_rcon es_tell event_var(userid) You are an admin  (you lucky SOB)
(Btw, just for safety, I always use userids when possible, so I changed the first username to userid.)

Best of luck with your script,
-Mattie
Mattie is offline
ichthys
Veteran Member
Join Date: Dec 2004
Location: []*[]
Old 05-16-2005 , 11:38  
Reply With Quote #3

Yes i use userid's aswell. I was just typing this really quick. My scripts are all compatible with NemoD aswell as Mani so there need to be a few extra lines. (NemoD needs userid's prefixed with #)

Whatever: So I'll try alias's with a delay again.

BTW: the application of this im plannining on is more that just letting the admin know, they are an admin.
__________________
ichthys is offline
Mattie
Veteran Member
Join Date: Jan 2005
Old 05-16-2005 , 12:04  
Reply With Quote #4

Quote:
Originally Posted by ichthys
BTW: the application of this im plannining on is more that just letting the admin know, they are an admin.
I figured-- I was thinking about this recently as it would be quite handy sometimes. Let me know if you find anything good for this problem, as I'd be quite interested.

Thanks,
-Mattie
Mattie is offline
ichthys
Veteran Member
Join Date: Dec 2004
Location: []*[]
Old 05-16-2005 , 12:14  
Reply With Quote #5

I'll definately post the working script
__________________
ichthys is offline
ichthys
Veteran Member
Join Date: Dec 2004
Location: []*[]
Old 05-16-2005 , 14:18  
Reply With Quote #6

Okay got it to work. With a delay of just 1sec. But thats on a lan connection. 2 should do it for most net connections i guess.

player_say.cfg
Code:
es_xsetinfo isadmin 0
if (event_var(text) equalto admin) then ma_cexec event_var(userid) ma_rcon isadmin 1
alias admincheck "if (server_var(isadmin equalto 1) then exec any.cfg
if (event_var(text) equalto admin) then es_delayed 2 es admincheck
I think i might make a script pack for this. So any other script can easily check for admins. It will only check when the player connects, not every player_say
__________________
ichthys is offline
Mattie
Veteran Member
Join Date: Jan 2005
Old 05-16-2005 , 14:26  
Reply With Quote #7

Quote:
Originally Posted by ichthys
Okay got it to work. With a delay of just 1sec. But thats on a lan connection. 2 should do it for most net connections i guess.

player_say.cfg
Code:
es_xsetinfo isadmin 0
if (event_var(text) equalto admin) then ma_cexec event_var(userid) ma_rcon isadmin 1
alias admincheck "if (server_var(isadmin equalto 1) then exec any.cfg
if (event_var(text) equalto admin) then es_delayed 2 es admincheck
I think i might make a script pack for this. So any other script can easily check for admins. It will only check when the player connects, not every player_say
Hmm-- there may be some typos in there (e.g. "server_var(isadmin equalto 1"). If this is player_say, how does that relate to "only check when the player connects"? Is there some code not shown above?

What happens if someone else says admin (connects?) during that 1-2 second window? You might want to make the admincheck alias be an alias specific to the userid to prevent collisions. Probably wouldn't be an issue much, but it could get out-of-synch if I'm reading your code correctly.

-Mattie
Mattie is offline
ichthys
Veteran Member
Join Date: Dec 2004
Location: []*[]
Old 05-16-2005 , 14:44  
Reply With Quote #8

Just to show the alias / delay command working. Not a direct cut-copy from the working version, hence the typos
__________________
ichthys is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode