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

[API] CS Reward v6.1 (21 Rewards)


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-05-2014 , 12:16   Re: [API] CS Core + Reward v5.3 (18 Rewards + 4 Forwards)
Reply With Quote #121

c_24 plugin:

Your reward_menu can be build in plugin_cfg and display it only when needed with menu_display. Don't forget, you don't destroy the menu, you close it with menu_cancel(index) to close it.

Not every function need public in front of it:
Code:
public something() {     DoSomethingElse() } DoSomethingElse() { }

In this case you don't need public...

I would say that naming your publics like public1 public2 doesn't help when reading, give them proper names so we know from which commands or forwards they come. Same for the core menu, you can make it global.
I think you have some problems with <k> key, because it's missing from all your plugins, please fix that, it's annoying.

Not saying that is something wrong with if check, or that you should change them, but I'm saying just to inform you:
Code:
if(cs_is_terrorist(id))     {         // We set the HP to 120         cs_health_reward(id, 120.0, 0)     }     else     {         // We set the HP to 140         cs_health_reward(id, 140.0, 0)     } Can also be: cs_is_terrorist(id) ? cs_health_reward(id, 120.0, 0) : cs_health_reward(id, 140.0, 0)

In cs_reward:

I think I already told you to use real offset names, to keep compatibility with the game: OFFSET_ACTIVE_ITEM is a wrong name, the good one is m_pActiveItem.

Don't make a global var static, is as useless as checking if 1 is equal to 1.
A global variable is not destroyed during run-time, static has no use here.

I'm speacking about all of this:
Code:
static g_aRed, g_aGreen, g_aBlue static g_lRed, g_lGreen, g_lBlue static g_rRed, g_rGreen, g_rBlue

When printing errors from your natives, I would use log_error(AMX_ERR_NATIVE, "message"). This also show the plugin name.

Code:
switch(iType)     {         case 0:              {
Well, correct it...

Code:
set_task(0.1, "i_NoClip", id)

This seems to be useless, do i_NoClip(id). If you do it, you won't need task ids... You decide if you change it.
Also fix the "k" problem.

In native_grenade_reward, you may let them to choose which grenades to give.
In some natives you don't check the param count, but in other one you do it. It's better to prevent unexperienced or lazy coders errors.

In get_glow_color, get_aura_color you have some vars as new and some as static. :O

Code:
if(!g_bBulletForward)
If I'm not wrong g_iMsgAmmo is filled with a value only here, so remove g_bBulletForward boolean, which is useless and check instead if(!g_iMsgAmmo). Learn how to use what you already has, don't create new and new and new useless vars.

In public player_line(id) you are creating new vars in a loop, don't ever do that.

In HLTV event you are not sure that players are alive, so please remove the "a" flag from get_players.

In fw_ResetMaxSpeed new Float:current_maxspeed is not needed
Code:
set_pev(id, pev_maxspeed, pev(id, pev_maxspeed, current_maxspeed) + g_iSpeed)

In fw_PlayerJump please use offset names, not offset values, so we can know what offest you are using and to understand what you are doing.
In fw_WeaponPrimary_Pre you don't need to return HAM_IGNORED.

In cs_core:

You may want to check if your forwards were registered successfully.
Native register_native("cs_is_terrorist", "native_is_terrorist") has no purpose, cs_get_user_team does the job.

Tired to check more. Don't forget that this is only my opinion, you are not forced to change anything, and we ca talk about them.
__________________
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-05-2014 , 12:53   Re: [API] CS Core + Reward v5.3 (18 Rewards + 4 Forwards)
Reply With Quote #122

HamletEagle, I appreciate your suggestion. ;)

By the way, may you explain a little bit about this?
Quote:
Originally Posted by HamletEagle
1. In public player_line(id) you are creating new vars in a loop, don't ever do that.

2. In HLTV event you are not sure that players are alive, so please remove the "a" flag from get_players.

3. In fw_PlayerJump please use offset names, not offset values, so we can know what offest you are using and to understand what you are doing.

Last edited by zmd94; 12-05-2014 at 12:54.
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-05-2014 , 13:00   Re: [API] CS Core + Reward v5.3 (18 Rewards + 4 Forwards)
Reply With Quote #123

1. In public player_line(id) you are creating new vars in a loop, don't ever do that.

In a loop you should not create new vars:
Code:
for() {     new var } while() {     new var } do {     new var } while()
This is wrong, you must declare them outside the loop.

Code:
new var for() { } new var while() { } new var do { } while()
A variable use memory when you create it and not when you give it a value.

2. In HLTV event you are not sure that players are alive, so please remove the "a" flag from get_players.

When the new round event is called(HLTV) players can be dead, "a" flag means get only alive players, so you won't reset all players flags.

3. In fw_PlayerJump please use offset names, not offset values, so we can know what offest you are using and to understand what you are doing.

Somewhere you use OFFSET_ACTIVE_ITEM which has a value, but you work with the name, for readability purpose, do the same for other offsets.
__________________

Last edited by HamletEagle; 12-05-2014 at 13:02.
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-05-2014 , 13:18   Re: [API] CS Core + Reward v5.3 (18 Rewards + 4 Forwards)
Reply With Quote #124

Quote:
Originally Posted by HamletEagle View Post
1. In public player_line(id) you are creating new vars in a loop, don't ever do that.
I got it.
Quote:
Originally Posted by HamletEagle View Post
2. In HLTV event you are not sure that players are alive, so please remove the "a" flag from get_players.

When the new round event is called(HLTV) players can be dead, "a" flag means get only alive players, so you won't reset all players flags.
Alright.
Quote:
Originally Posted by HamletEagle View Post
3. In fw_PlayerJump please use offset names, not offset values, so we can know what offest you are using and to understand what you are doing.

Somewhere you use OFFSET_ACTIVE_ITEM which has a value, but you work with the name, for readability purpose, do the same for other offsets.
So, this is about get_pdata_int(id, 246) and get_pdata_float(id, 251), right?
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-05-2014 , 13:20   Re: [API] CS Core + Reward v5.3 (18 Rewards + 4 Forwards)
Reply With Quote #125

Yep.
__________________
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-05-2014 , 13:25   Re: [API] CS Core + Reward v5.3 (18 Rewards + 4 Forwards)
Reply With Quote #126

Alright. By the way, I have find this: https://wiki.alliedmods.net/Category:CS_Class_List

It will be useful. ;)

I will update the code after I have fully tested the whole code.

Last edited by zmd94; 12-05-2014 at 13:25.
zmd94 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-06-2014 , 01:17   Re: [API] CS Core + Reward v5.4 (18 Rewards + 4 Forwards)
Reply With Quote #127

Major update!
Quote:
v5.4
- [FIXED] Remove unnecessary code in c_24.sma file and change the way of the reward is being given at cs_fw_spawn_post(id).
- [FIXED] The readibility of the code by giving proper names. So, we know from which commands or forwards they come.
- [FIXED] Now, the cs_reward code is using real offset names to keep compatibility with the game.
- [FIXED] All of the offset values has been changed into offset names. So, we can know what offest is being used.
- [ADDED] This new update will support Linux and Mac offset values also.
- [FIXED] The variable in cs_speed_reward and cs_jump_reward natives.
- [FIXED] The code in fw_ResetMaxSpeed.
- [FIXED] Now, all the errors from native will be printed by using log_error(AMX_ERR_NATIVE, "message") instead server_print("message").
- [FIXED] Remove unnecessary set_task in cs_noclip_reward native.
- [FIXED] The problem with the static variables. ;)
- [FIXED] Remove unnecessary g_bBulletForward boolean as there is already g_iMsgAmmo variable.
- [FIXED] Remove the new variables inside the loop in public player_line(id) and public player_ring(id).
- [FIXED] Remove the "a" flag in the get_players during HLTV.
- [FIXED] Remove return HAM_IGNORED in fw_WeaponPrimary_Pre and fw_WeaponPrimary_Post.
- [ADDED] New, option in cs_grenade_reward native. Now, you can choose which grenade that you want to recieve instead recieve all of the grenades.
Credit:

1. HamletEagle for code helping. ;)

Last edited by zmd94; 12-06-2014 at 01:18.
zmd94 is offline
schmurgel1983
Veteran Member
Join Date: Aug 2006
Location: Germany
Old 12-06-2014 , 03:44   Re: [API] CS Core + Reward v5.4 (18 Rewards + 4 Forwards)
Reply With Quote #128

hi zmd94, what is the point of iTerrorist? When you already get the value with iTEcount?
Code:
public native_get_terrorist_count(iPlugin, iParams)
{
	new iTEcount, players[32], iTerrorist
	
	new iType = get_param(1)
	if(iType < 0 || iType > 2)
	{
		log_error(AMX_ERR_NATIVE, "cs_get_terrorist_count native is incorrect. iType must not less than 0 or more than 2")
		return 0
	}
	
	switch(iType)
        {
		case 0:     
                {
			get_players(players, iTEcount, "e", "TERRORIST")
			
			iTerrorist += iTEcount
		}
		case 1:
		{
			get_players(players, iTEcount, "ae", "TERRORIST")
			
			iTerrorist += iTEcount
		}
		case 2:
		{
			get_players(players, iTEcount, "be", "TERRORIST")
			
			iTerrorist += iTEcount
		}
	}
	
	return iTerrorist
	
	return iTEcount <---
}
and when you made iTEcount, iCTcount, players[32] as global, it will be much faster
in my opinion the core plugin is really slow.
regards!
__________________

Working on:
nothing
schmurgel1983 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-06-2014 , 04:04   Re: [API] CS Core + Reward v5.4 (18 Rewards + 4 Forwards)
Reply With Quote #129

Schmurgel1983, I appreciate your suggestion. I will fix it. ;)

New update!
Quote:
v5.4
- [FIXED] iTEcount, iCTcount, players[32] in cs_core.sma file is changed into global variables. ;)
- [FIXED] Remove unnecessary variables in native_get_terrorist_count and native_get_counter_count.
Credit:

1. Schmurgel1983 for code helping. ;)

Last edited by zmd94; 12-06-2014 at 05:10.
zmd94 is offline
schmurgel1983
Veteran Member
Join Date: Aug 2006
Location: Germany
Old 12-06-2014 , 09:32   Re: [API] CS Core + Reward v5.5 (18 Rewards + 4 Forwards)
Reply With Quote #130

take a look and tell me what you think.
Attached Files
File Type: sma Get Plugin or Get Source (cs_core.sma - 376 views - 5.6 KB)
__________________

Working on:
nothing
schmurgel1983 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 04:57.


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