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

HomeFree v0.7


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-30-2011 , 12:08   Re: HomeFree
Reply With Quote #21

- I was talking about the events : SayText, TeamInfo. Such message index are static and won't change in-game, therefore that's something you could cache one time.
- You still keep mPlayers[i] == 0 check. It doesn't make sense and can't happen.
- The blocking of "buy" is wrong. You can buy with others ways. So... again, see info_map_paramters entity. Easy and efficient way.
- Why you don't hook SendAudio or TextMsg to know what team has won ?
- AFAIK changing the return of a FM forward, you need to supercede. I did not say you to remove this return, but to move it in the check, which should be logic.

I have others things to say, but for now, fix again your plugin.
I'm starting to wonder if you can really support this plugin.
__________________
Arkshine is offline
Nur56
Member
Join Date: Apr 2007
Old 09-30-2011 , 13:33   Re: HomeFree
Reply With Quote #22

Quote:
Originally Posted by Arkshine View Post
- I was talking about the events : SayText, TeamInfo. Such message index are static and won't change in-game, therefore that's something you could cache one time.
- You still keep mPlayers[i] == 0 check. It doesn't make sense and can't happen.
- The blocking of "buy" is wrong. You can buy with others ways. So... again, see info_map_paramters entity. Easy and efficient way.
- Why you don't hook SendAudio or TextMsg to know what team has won ?
- AFAIK changing the return of a FM forward, you need to supercede. I did not say you to remove this return, but to move it in the check, which should be logic.

I have others things to say, but for now, fix again your plugin.
I'm starting to wonder if you can really support this plugin.
-Done( I think? )
-Removed and doing i = 0 actually worked this time
-Done that, had to include engine but oh well
-Hooked using TextMsg
-Didn't understand you in the beginning, fixed now with an IGNORE outside the check

I've worked hard for this plugin, I would hate for it to go to waste

(updated src, removed +/-sprint and +/-slowfall and replaced them with +/-homefree)
Nur56 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-30-2011 , 14:05   Re: HomeFree
Reply With Quote #23

- You don't understand the caching thing.
That : get_user_msgid("SayText"), it returns an unique number which won't change in-game. Since static, and since it will be called more than one time, it would be appropriate to cache its value into a global variable one time, in plugin_init for example.
- Same for get_maxplayers(). You save the value before, it's better, but it will still be called each time the function will be run, and the returns value won't change in-game.
- Why are you using register_message for TxtMsg ? There is not reason to hook the message as pre, you don't want to modify its params, right ? You can simply use 2 register_event. It will be more efficient.
- What are you trying to delete the entity in the player's spawn ? How you can expect you find such entity when Ham_Spawn is registered with "player" ? Really doesn't make sense what you do. Search you will find snippet for that.

It does not really matter you have worked hard. Look, each time there are many things to say, it proves simply you need to learn more. Nothing wrong with that, you should just aware of your own limit. That's not the scripting section. You are supposed to know what you're doing. That's why I've said I was wondering if you can support really your plugin. You have some potential for sure, but you will understand it starts to be boring to correct you each time because our job is not to teach you how to code.

Anyway for now, it seems you can follow, fix your plugin, and really please, test your plugin before releasing.
__________________

Last edited by Arkshine; 09-30-2011 at 14:12.
Arkshine is offline
Nur56
Member
Join Date: Apr 2007
Old 09-30-2011 , 16:31   Re: HomeFree
Reply With Quote #24

Quote:
Originally Posted by Arkshine View Post
- You don't understand the caching thing.
That : get_user_msgid("SayText"), it returns an unique number which won't change in-game. Since static, and since it will be called more than one time, it would be appropriate to cache its value into a global variable one time, in plugin_init for example.
- Same for get_maxplayers(). You save the value before, it's better, but it will still be called each time the function will be run, and the returns value won't change in-game.
- Why are you using register_message for TxtMsg ? There is not reason to hook the message as pre, you don't want to modify its params, right ? You can simply use 2 register_event. It will be more efficient.
- What are you trying to delete the entity in the player's spawn ? How you can expect you find such entity when Ham_Spawn is registered with "player" ? Really doesn't make sense what you do. Search you will find snippet for that.

It does not really matter you have worked hard. Look, each time there are many things to say, it proves simply you need to learn more. Nothing wrong with that, you should just aware of your own limit. That's not the scripting section. You are supposed to know what you're doing. That's why I've said I was wondering if you can support really your plugin. You have some potential for sure, but you will understand it starts to be boring to correct you each time because our job is not to teach you how to code.

Anyway for now, it seems you can follow, fix your plugin, and really please, test your plugin before releasing.

-Cached vars in plugin_init(), including getmaxplayers
-registered 2 events, 1 for CT win and 1 for T win, using TextMsg
-It worked fine for me but I agree, it wasn't really effective. changed to use only fakemeta.


I really hope I did it right this time, I do know what I'm doing I just didn't find this amount of optimization really necessary(until now).

and I really do test my plugin before I release it
Nur56 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-30-2011 , 17:49   Re: HomeFree
Reply With Quote #25

Quote:
changed to use only fakemeta.
That's not an optimization... Look, because of that now, instead of DispatchKeyValue (one native), you call SetKeyValue (5 natives!). Guess what is the most efficient ? Of course here, it would be called one time, but it won't always the case. You should use intelligently the existing natives/forwards whatever the modules. Remember calling a native cost cpu, that's why there is no reason to use the fakemeta version here.

- You create the entity info_map_parameters, but you forget the situation where the map has already such entity. Since you create in precache time, the entity of the map is not created yet, that's why you need to hook FM_Spawn after creating your entity to block its spawn (the entity integrated to the map). Again, there is snippet about that.
- You call 2 times cs_get_user_team( id ). You should cache the value and you should understand checking 2 times the team is quite pointless. Use simply a switch.
- Oh inside the switch, instead of writting 1 and 2, some defines exist for that, CS_TEAM_CT and CS_TEAM_T, just use them.
- When you do checks, you should make testing first the variables. Like gNewR should be check before get_pcvar_num. You filter better to avoid to check natives.
- You should avoid to make multiple if() when you could do if( condition1 && condition2 && etc.. ). The compiler is idiot and won't optimize. By doing that you will generate less code.
- Your motd is static, therefore it would be appropriate to generate it one time.
- In the player's spawn, is a task really need ? 0.2 is fairly unnoticeable and I'm not how it would be useful.
- I see you use a var to pass the player's id, but as tip, you can pass directly the player's id as the task id. And it will avoid each you use id[0] (where here that's something you should cache from the start hehe)

- A word about readability : please avoid to glue all together. It won't hurt to make some white-spaces. People who will read your code will be happy. For example logevent_round_start, you can make make a new line after the var, cvar, colorchat.
- Just for your information. I see most of time your explicit the return of a function (PLUGIN_CONTINUE, etc..). When no specific value has to be returned, the value by default is anyway the PLUGIN_CONTINUE, or FMRES_IGNORED, etc.., therefore you don't need to explicit the return. It's fine if you do too and it won't matter if you want to keep it, but personally I see no point to explicit, it eats one line for nothing.
__________________

Last edited by Arkshine; 09-30-2011 at 18:06.
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-01-2011 , 02:09   Re: HomeFree
Reply With Quote #26

Please change that horrible FindPlayer stock with :
Code:
FindPlayer()
{
	static iPlayers[32], iNum
	get_players(iPlayers, iNum, "h")
	return iNum ? iPlayers[0] : -1
}
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Nur56
Member
Join Date: Apr 2007
Old 10-01-2011 , 07:12   Re: HomeFree
Reply With Quote #27

Updated source did everything you said except for the player spawn tasks, if I do it directly in the event it will give me some errors( tried 100 times, same thing ), so a task worked perfectly. motd now in plugin_init, no more multiple if conditionals, switch( cs_get_user_team( id ) ) for team, and removed buyzone with engine and FM_Spawn.

also removed ColorChat's find player and added Connor's stock.
Nur56 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-01-2011 , 07:13   Re: HomeFree
Reply With Quote #28

what errors?
__________________
Arkshine is offline
Nur56
Member
Join Date: Apr 2007
Old 10-01-2011 , 07:30   Re: HomeFree
Reply With Quote #29

Some index related errors, but since you insisted I installed a fresh copy of AMXX and it worked, so I'm guessing it was one of the plugins I had. still, with the task there were no such errors but if it's necessary I could remove the spawn tasks
Nur56 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-01-2011 , 07:34   Re: HomeFree
Reply With Quote #30

There is no reason to use tasks here. I would remove them.

In tTaskT, there is 2 cs_set_user_money.
__________________
Arkshine 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 14:55.


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