Raised This Month: $32 Target: $400
 8% 

ProChat


Post New Thread Reply   
 
Thread Tools Display Modes
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-30-2009 , 11:16   Re: ProChat
Reply With Quote #11

Quote:
Originally Posted by arkshine View Post
- new iOldName[27], iNewName[27]; Should be 32.

- Instead of check_flags() function, If you want to test something like : get_user_flags(id) & ADMIN_KICK && get_user_flags(id) & ADMIN_BAN, should not be enough to do just : if ( !( get_user_flags( id ) & ~( ADMIN_KICK | ADMIN_BAN ) ) ) ? It would be better.

- Why did you use client_command() when you can directly register via register_clmd() ? It would be better and it will avoid unnecessary calls.

- What's the purpose of get_chat_viewer_access() when the level is hardcoded ? Just do a #define so user will have to change just one line.

- Message_SayText() ; It would be more appropriate to try to do an effort to use severals switch instead of if() elseif()[..] , checking each time the string. Also, while+contain+replace = replace_all(), what's wrong with replace_all() ?
Len: max name lengh is 26 chars.

Flags: didn't knew that function. But what about support for 'y' ADMIN_ADMIN flag?

Cmd registering: supports not only "/chatviewer" but also ".chatviewer" and also supports a<->A (big ladders to small).

Else if vs. if: we need to check all chars so I'm using if (not else if).

replace_all vs. while( contain ) replace(): replace_all uses more cpu cuz scans number of replaces + has backup checkup + uses not static variables (function is fast repeating). In other words replace_all uses more CPU and more RAM.

// edit:

Quote:
Originally Posted by ConnorMcLeod View Post
Quote:
Originally Posted by arkshine
what's wrong with replace_all() ?
It's too much readable for NumB.
Rofl. Love you.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 01-30-2009 at 11:20.
MPNumB is offline
Send a message via Skype™ to MPNumB
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-30-2009 , 12:22   Re: ProChat
Reply With Quote #12

Quote:
Len: max name lengh is 26 chars.
Max name length is limited to 32 characters. I tried just now to be sure.

Quote:
Flags: didn't knew that function. But what about support for 'y' ADMIN_ADMIN flag?
I think I have misunderstood what you wanted to do. What I gave is to check if there are only theses flags. But if you want to check if theses flags are presents (not only one flags, all provided flags), you should do just : if ( i_Flags & ( ADMIN_KICK | ADMIN_BAN ) == ( ADMIN_KICK | ADMIN_BAN ) )

Quote:
Cmd registering: supports not only "/chatviewer" but also ".chatviewer" and also supports a<->A (big ladders to small).
It would be more efficient to use severals register_clcmd() (/ .). client_command is called often. The support of 'a<->A' is for me not really necessary here ( I mean not enough useful to be prioritized on efficiency ). Well do what you want. Edit: if you still want to use equali(), register at least say and say_team instead of using client_command which will be called often others than chat messages.

Quote:
Else if vs. if: we need to check all chars so I'm using if (not else if).
No, just few letters should be enough ; It will be more faster and efficient. ( It's always better to check only one character than using equal() and checking the whole string + switch() against if~elseif' )

Quote:
replace_all vs. while( contain ) replace(): replace_all uses more cpu cuz scans number of replaces + has backup checkup + uses not static variables (function is fast repeating). In other words replace_all uses more CPU and more RAM.
More Cpu/ram ? Not really, prove it. :p. it's just cells.. For that, it would more appropriate to use a safe method. Just my opinion.

Last edited by Arkshine; 01-30-2009 at 13:42.
Arkshine is offline
Miko000000
Senior Member
Join Date: Jul 2008
Location: Slovakia
Old 01-30-2009 , 15:38   Re: ProChat
Reply With Quote #13

GJ and nice work
Miko000000 is offline
Send a message via ICQ to Miko000000 Send a message via Skype™ to Miko000000
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-30-2009 , 15:39   Re: ProChat
Reply With Quote #14

Quote:
Originally Posted by Miko000000 View Post
GJ and nice work
GW and nice job
SnoW is offline
Send a message via MSN to SnoW
Speed!
BANNED
Join Date: Jan 2009
Old 01-30-2009 , 22:52   Re: ProChat
Reply With Quote #15

Quote:
Originally Posted by arkshine View Post
Max name length is limited to 32 characters. I tried just now to be sure.



I think I have misunderstood what you wanted to do. What I gave is to check if there are only theses flags. But if you want to check if theses flags are presents (not only one flags, all provided flags), you should do just : if ( i_Flags & ( ADMIN_KICK | ADMIN_BAN ) == ( ADMIN_KICK | ADMIN_BAN ) )



It would be more efficient to use severals register_clcmd() (/ .). client_command is called often. The support of 'a<->A' is for me not really necessary here ( I mean not enough useful to be prioritized on efficiency ). Well do what you want. Edit: if you still want to use equali(), register at least say and say_team instead of using client_command which will be called often others than chat messages.



No, just few letters should be enough ; It will be more faster and efficient. ( It's always better to check only one character than using equal() and checking the whole string + switch() against if~elseif' )



More Cpu/ram ? Not really, prove it. :p. it's just cells.. For that, it would more appropriate to use a safe method. Just my opinion.
in one hand you are telling him to fix minor things that actually may not fix bugs, just may improve in a way that wont be even noticeble.
in the other hand you are telling him that a method is better, but not thaaat better.
i think plugins may be done in more than 1 way, and in many ways will be working and with equal perfonmance
and everyone has his owns methods scripting, he may use his methods (that actually works) for his plugins, and you for your plugins (that are actually pretty the same)
take it good, i think its just a bit excesive to correct things that do not have difference, its just "to be used to that method"
just an opinion
Speed! is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-31-2009 , 00:41   Re: ProChat
Reply With Quote #16

How is efficiency an opinion or scripting style?
arkshine has been scripting for a long time now, and he knows what he is talking about.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-31-2009 , 05:15   Re: ProChat
Reply With Quote #17

Quote:
just an opinion
I think we have to create efficient code when we can. The purpose is to do quality plugin. Safe code sometimes against efficiency depending the need. Maybe the plugin alone it will not be that noticeable, but if you have severals plugins not coded in an efficient way, it will be. What I have said is not my 'method' it's just an efficient method that people should be used as 'standart'.
Why do you use static ? Because you know it's more appropriate to use it on (large) array (or cells) in a function called often. It's the same with switch() or checking one letter instead of using if() elsif() with equal a lot of times. It's more efficient to use it when we can. ( common practice ). Like your check_flags function a lot of code when you may can it in on line.

Anyway it was just suggestions, I don't care if you ignore or not. I was just some help so you plugin can be more efficient. ( I will do my version as it should be and it will compare with profiler. It may be interesting. I will post my version here later, too )

Last edited by Arkshine; 01-31-2009 at 09:10.
Arkshine is offline
anxiro
Member
Join Date: Jan 2005
Old 01-31-2009 , 05:25   Re: ProChat
Reply With Quote #18

I disabled my own admin access on the server but I am still allowed to do /chatviewer -command? Why?

Anyway - Good plugin!

Last edited by anxiro; 01-31-2009 at 05:25. Reason: (command change)
anxiro is offline
Send a message via ICQ to anxiro
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-31-2009 , 09:43   Re: ProChat
Reply With Quote #19

Quote:
Originally Posted by arkshine View Post
Max name length is limited to 32 characters. I tried just now to be sure.
Damn, before protocol update it was 26 - 100% sure in it...


Quote:
Originally Posted by arkshine View Post
I think I have misunderstood what you wanted to do. What I gave is to check if there are only theses flags. But if you want to check if theses flags are presents (not only one flags, all provided flags), you should do just : if ( i_Flags & ( ADMIN_KICK | ADMIN_BAN ) == ( ADMIN_KICK | ADMIN_BAN ) )
Anyway, changed it to this way (as I said before - didn't knew about this way).


Quote:
Originally Posted by arkshine View Post
It would be more efficient to use severals register_clcmd() (/ .). client_command is called often. The support of 'a<->A' is for me not really necessary here ( I mean not enough useful to be prioritized on efficiency ). Well do what you want. Edit: if you still want to use equali(), register at least say and say_team instead of using client_command which will be called often others than chat messages.
I created this plugin long time ago. Just submitted it this week rewriting it to be more readable. Good idea to use register_clcmd(). Done.


Quote:
Originally Posted by arkshine View Post
No, just few letters should be enough ; It will be more faster and efficient. ( It's always better to check only one character than using equal() and checking the whole string + switch() against if~elseif' )
Right now understood that I don't understand of what lines of source you are talking about. =P


Quote:
Originally Posted by arkshine View Post
More Cpu/ram ? Not really, prove it. :p. it's just cells.. For that, it would more appropriate to use a safe method. Just my opinion.
Ok.

PHP Code:
while( contain(textstring) )
   
replace(texttext_lenstringstring2); // I think it's simple 
Now lets take a look at:
PHP Code:
stock replace_all(string[], len, const what[], const with[])
{
 new 
pos 0;
 
 if ((
pos contain(stringwhat)) == -1)
 {
  return 
0;
 }
 
 new 
total 0;
 new 
with_len strlen(with);
 new 
diff strlen(what) - with_len;
 new 
total_len strlen(string);
 new 
temp_pos 0;
 
 while (
replace(string[pos], len poswhatwith) != 0)
 {
  
/* jump to position after replacement */
  
pos += with_len;
 
  
/* update cached length of string */
  
total_len -= diff;
 
  
/* will the next call be operating on the last character? */
  
if (pos >= total_len)
  {
   break;
  }
 
  
/* find the next position from our offset */
  
temp_pos contain(string[pos], what);
 
  
/* if it's invalid, we're done */
  
if (temp_pos == -1)
  {
   break;
  }
 
  
/* otherwise, reposition and update counters */
  
pos += temp_pos;
  
total++;
 }
 
 return 
total;

If not visible by eye that replace_all takes more power I can also say it this way:

SayText event can be repeated really fast and often. Using variable what is not "static" or "global" (like "new" what this stock does), we can just end up in a server crash.

// edit:


Updated to 1.1 :
Fixed: max name length changed from 26 to 31.
Changed: some things in the code to make plugin work better.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 01-31-2009 at 10:04.
MPNumB is offline
Send a message via Skype™ to MPNumB
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-31-2009 , 10:33   Re: ProChat
Reply With Quote #20

About replace_all, he takes more power ( slighty ) but is more safe too. Though it may not a bad idea to include this stock in your plugin, changing new by static if the function is called often.

Anyway, I've just thought about your code, since you replace by a space ( not removing ), there is a much better method to do that, something that ( may need adjustments but you get the idea ):

Code:
    for ( new i = iLen; i <= iLen + iLen2; i++ )     {         if ( iMessage[i] == 'SOH' || iMessage[i] == 'STX' || iMessage[i] == 'ETX' || iMessage[i] == 'EOT' || iMessage[i] == '%' )             iMessage[i] = ' ';     }

No native, no extra cpu/memory used. :p

EDIT : Arg, codes doesn't show ; I've written manually but you will understand.

Last edited by Arkshine; 01-31-2009 at 10:37.
Arkshine is offline
Reply


Thread Tools
Display Modes

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 00:49.


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