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

amx freeze


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-01-2010 , 07:49   Re: amx freeze
Reply With Quote #21

Some code is redundant, instead of do many loops depending on @*** argument, use get_players with appropriated flags and do only 1 loop.

You could make a function so freeze/unfreeze a player in which you would set flags, bit, and store angles.
If you do so, at the end of the function, you could check if PreThink forward needs to be registered or not, this is just a suggestion, but FM allows to enable/disable forwards ;)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-01-2010 , 08:50   Re: amx freeze
Reply With Quote #22

Quote:
Originally Posted by ConnorMcLeod View Post
Some code is redundant, instead of do many loops depending on @*** argument, use get_players with appropriated flags and do only 1 loop.

You could make a function so freeze/unfreeze a player in which you would set flags, bit, and store angles.
If you do so, at the end of the function, you could check if PreThink forward needs to be registered or not, this is just a suggestion, but FM allows to enable/disable forwards ;)
So i can register_forward outside plugin_init() too ?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-01-2010 , 08:52   Re: amx freeze
Reply With Quote #23

Sure.
__________________
Arkshine is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-01-2010 , 09:01   Re: amx freeze
Reply With Quote #24

Cool, I'll start working on it right now. Thanks


EDIT: Done, new version uploaded.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 11-01-2010 at 09:42.
drekes is offline
Send a message via MSN to drekes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2010 , 20:02   Re: amx freeze
Reply With Quote #25

Do following changes :
  • tempid in loop is not needed as your comment said.
  • wpn var is not needed in CurWeapon event callback, also you don't need to check weapon at all since you add filter in register_event line.
  • Also, put IsFrozen check before alive check as it doesn't use any native (curweapon and prethink)
  • Func_Freeze doesn't need to be public
  • formatex is not appropriated since you don't format anything, just use copy or directly assign string value.
  • would be better to use client_disconnect than cilent_connect, also, check again for registered forward there.

Suggestion :
case 'A':
->
case 'A', 'a':
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-02-2010 , 20:17   Re: amx freeze
Reply With Quote #26

Quote:
Originally Posted by ConnorMcLeod View Post
tempid in loop is not needed as your comment said.
Thanks for the confirmation.

Quote:
Originally Posted by ConnorMcLeod View Post
formatex is not appropriated since you don't format anything, just use copy or directly assign string value.
I recently learned a new method.
Is copy better then something like this ?

Code:
enum teams
{
    ALL,
    T,
    CT
}

new const teamnames[teams][] =
{
    "All",
    "Terrorist",
    "Counter-Terrorist"
}

// in cmd_freeze
new teams: team;

{
    case 'A', 'a':    
       team = ALL;
}

client_print(id, print_chat, "..frozen %s", TeamNames[team]);
Quote:
Originally Posted by ConnorMcLeod View Post
would be better to use client_disconnect than cilent_connect, also, check again for registered forward there
I don't understand what you mean by this.


I will update it tomorrow.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2010 , 21:45   Re: amx freeze
Reply With Quote #27

Quote:
Originally Posted by drekes View Post
Is copy better then something like this ?
I don't think so.


Last thing, after unregistering forward you should set g_PreThinkId to 0, and check if it's different from 0 before unregistering, and 0 when you register it.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-02-2010 at 22:55.
ConnorMcLeod is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-03-2010 , 05:43   Re: amx freeze
Reply With Quote #28

All done
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 11-03-2010 , 05:50   Re: amx freeze
Reply With Quote #29

Instead of the current syntax, which makes it impossible to freeze the player for one second, make the command accept only one parameter, so amx_freeze player will toggle between frozen and not frozen.
Seta00 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-03-2010 , 06:00   Re: amx freeze
Reply With Quote #30

Quote:
Originally Posted by Seta00 View Post
Instead of the current syntax, which makes it impossible to freeze the player for one second, make the command accept only one parameter, so amx_freeze player will toggle between frozen and not frozen.
Done
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
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 01:56.


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