PDA

View Full Version : Award Grenades: Reloaded v1.5


Sam Tsuki
08-14-2008, 16:13
Award Grenades: Reloaded

.: Description :.
When you kill a person you'll be awarded with Grenades.
You can use 3 conditions:
1. Team
2. Head Shot
3. Weapon

.: Required Modules :.
Fun
CSX
CStrike

.: CVARs :.
award_nades 1 //Enables the plugin
award_he 1 //How many HE Grenades a player should be awarded when killing another player?
award_fb 1 //How many Flash Bangs a player should be awarded when killing another player?
award_sg 1 //How many Smoke Grenades a player should be awarded when killing another player?
he_max 3 //What's the maximum number of HEs a player can be awarded with?
fb_max 5 //What's the maximum number of FBs a player can be awarded with?
sg_max 4 //What's the maximum number of SGs a player can be awarded with?
award_team Any //Which team should be awarded? (Any, CT, T)
award_headshot 0 //Is a Head Shot needed ot get awarded?
award_weapon any //What weapon is needed to get awarded? (knife, usp, glock18, etc.).: CMDs :.
say /awardcmds //Shows Award Grenades: Reloaded Commands
say /awardmenu //Shows a menu to know the awards and conditions
award_nades_toggle <0|1> //ADMIN_LEVEL_D, Enables or disables the plugin
award_nades_awards <he><fb><sg> //ADMIN_LEVEL_D, Changes the the awarded Grenades
give_nade <name> <nade> <amount> //ADMIN_LEVEL_D, Gives a Grenade to a player
//Leave <nade> empty to give all Grenades, 'he' to give HEs, 'fb' to give Flash Bangs, 'sg' to give smoke grenades
award_team_toggle <Any|CT|T> //ADMIN_LEVEL_D, Changes which team should be awarded? *case sensetive*
award_hs_toggle <0|1> //ADMIN_LEVEL_D, Changes if a head shot is needed to get awarded
award_wpn_toggle <any|weapon name> //ADMIN_LEVEL_D, Changes if a weapon is needed to get awarded (knife, usp, glock18, etc.)
award_valid_weapons //ADMIN_LEVEL_D, Shows valid weapons
award_valid_weapons2 //ADMIN_LEVEL_D, Shows the rest of the valid weapons.: Updates :.
v1.1
- Fixed some scripting errors

v1.2
- Added award_team cvar and award_team_toggle command

v1.3
-Changed name to "Award Grenades: Reloaded"
-Added award_headshot and award_weapon CVARs
-Added award_nades_awards, award_hs_toggle, award_wpn_toggle, award_valid_weapons and award_valid_weapons2 ADMIN_LEVEL_D commands
-Added /awardcmds and /awardmenu client commands

v1.4
-Some bug fixes

v1.5
-Removed "award_fb_amount" CVAR
-Added "he_max", "fb_max" and "sg_max" CVARs
-Now the plugin uses v3x's Grenade Sack method to give nades

Requested (http://forums.alliedmods.net/showthread.php?t=75855)

ConnorMcLeod
08-14-2008, 16:22
You can remove #include <engine> as engine is not needed.
client_death is a csx forward so you need to include it.

You must use pcvars and learn how to use it.
//Check if Award Grenades is enabled
if(award_nades == 0) return PLUGIN_HANDLED

Correct way :
//Check if Award Grenades is enabled
if(get_pcvarnum(award_nades) == 0) return PLUGIN_HANDLED

There's a lot of other errors.

Sam Tsuki
08-14-2008, 16:24
You can remove #include <engine> as engine is not needed.
client_death is a csx forward so you need to include it.

You must use pcvars and learn how to use it.
//Check if Award Grenades is enabled
if(award_nades == 0) return PLUGIN_HANDLEDCorrect way :
//Check if Award Grenades is enabled
if(get_pcvarnum(award_nades) == 0) return PLUGIN_HANDLEDThere's a lot of other errors.

Done with everything

ConnorMcLeod
08-14-2008, 16:37
Then this is false :

award_nades = str_to_num(arg)

And you still don't use pcvars for :
register_cvar("award_he", "1")
register_cvar("award_fb", "1")
register_cvar("award_fb_amount", "2")
register_cvar("award_sg", "1")

Also you should use DeathMsg event instead of csx forward.

Other big error :
if(get_cvar_num("award_fb") == 1) {
give_item(attacker, "weapon_flashbang")
if(get_cvar_num("award_fb_amount") == 2)
give_item(attacker, "weapon_flashbang")
}

Value 2 will never be detected.

Sam Tsuki
08-14-2008, 16:44
Then this is false :

award_nades = str_to_num(arg)And you still don't use pcvars for :
register_cvar("award_he", "1")
register_cvar("award_fb", "1")
register_cvar("award_fb_amount", "2")
register_cvar("award_sg", "1")Also you should use DeathMsg event instead of csx forward.

Other big error :
if(get_cvar_num("award_fb") == 1) {
give_item(attacker, "weapon_flashbang")
if(get_cvar_num("award_fb_amount") == 2)
give_item(attacker, "weapon_flashbang")
}Value 2 will never be detected.
That's wierd
I test it and it's working well
When I used DeathMsg I got a no free edict error
I tried putting award_fb_amount to 1 and 2 and both worked probably
And about the:
award_nades = str_to_num(arg)Even if I used:
award_nades = argIt will still do the same
Correct me if anything is wrong
I'm still new you know

Sam Tsuki
08-14-2008, 17:01
Ok...
Converted all cvars to pcvars and they're working well
Now I need to find a solution for the no free edicts error when using DeathMsg

ConnorMcLeod
08-14-2008, 17:10
Even if I used:
award_nades = arg

Seems that you should learn more before posting plugins.
Just keep on.

Sam Tsuki
08-14-2008, 18:12
Seems that you should learn more before posting plugins.
Just keep on.

Yeah I didn't notice
I need to convert award_nades to an array to use that one

Dores
08-14-2008, 19:23
connorr you're such a cocky :)

Sam Tsuki, this:


if(equal(arg1, "")) {
console_print(id, "[AG] Usage: give_nade <name> <nade he,fb,sg> <amount 1,2>")
return PLUGIN_HANDLED
}

does the same as:

register_concmd("give_nade", "give_nade", ADMIN_LEVEL_D, "<name> <nade he,fb,sg> <amount 1,2>")
it will print the usage if nothing was put while used the console command.

same for the other concmd.

Sam Tsuki
08-14-2008, 19:34
connorr you're such a cocky :)

Sam Tsuki, this:


if(equal(arg1, "")) {
console_print(id, "[AG] Usage: give_nade <name> <nade he,fb,sg> <amount 1,2>")
return PLUGIN_HANDLED
}does the same as:

register_concmd("give_nade", "give_nade", ADMIN_LEVEL_D, "<name> <nade he,fb,sg> <amount 1,2>")it will print the usage if nothing was put while used the console command.

same for the other concmd.
Ok...
Removed

Lee
08-14-2008, 19:54
client_death is a csx forward so you need to include it.
No, you don't.

Sam Tsuki
08-14-2008, 20:01
No, you don't.
I thought so cuz it was working before I included the csx.inc :O

Dores
08-14-2008, 22:16
i'll test to make sure i'm right and to make you feel better :D (i'm reffering my other post with the usage)

EDIT: Works fine :wink: (the usage at least... haven't checked if plugin itself works..)

ConnorMcLeod
08-14-2008, 22:20
No, you don't.

Of course you have to !

Dores
08-14-2008, 22:23
Of course you have to !
The man says it works without it.... any reason he should include it?:?

Lee
08-14-2008, 22:23
Wow. I'm dumbfounded. How can both you and KWo not know how forwards work? Test it and then tell me otherwise.

ConnorMcLeod
08-15-2008, 00:38
Well, in order to this forward work, csx module need to run, so if csx module isn't declared in modules.ini, and if no other plugin make it autoload, this plugin won't work unless you include csx.
The only reason that this plugin work is that csx module is already running.

Sam Tsuki
08-15-2008, 00:49
Well, in order to this forward work, csx module need to run, so if csx module isn't declared in modules.ini, and if no other plugin make it autoload, this plugin won't work unless you include csx.
The only reason that this plugin work is that csx module is already running.
But I think if you didn't include a module and used one of its forwards then it won't compile O.o

EDIT: No I guess it will comple...
Oh well
Will leave it at this

ConnorMcLeod
08-15-2008, 01:00
But I think if you didn't include a module and used one of its forwards then it won't compile O.o

EDIT: No I guess it will comple...

Yes, it compiles as your function is declared as 'public'

Lee
08-15-2008, 01:41
Connorr, 'should' is not the same as 'have to'. :wink: You were also wrong to say "Value 2 will never be detected" since he was checking two different cvars. :P

Connorr's not being cocky. He's rightly pointing out that someone with more experience would have done a much better job. There are still numerous errors.

Scrap the loop below 'Check player names' in favour of cmd_target() or find_player().
Player names can be 31 characters long.
The fourth parameter to cmd_access() in give_nade() should be 3.
You need to check that str_to_num() doesn't return 0.
Don't return PLUGIN_HANDLED in forwards that can't be blocked.
award_fb_amount is superfluous.
Use 'break' to exit loops.
There are many places where you should cache native return values.
You should evaluate whether the first element of an array is false rather than using equal() to determine if a string is empty.
You overwrite a cvar pointer (award_nades) with a value rather than updating the cvar itself.
Don't be discouraged. Everyone writes shoddy code at first. You should learn more before attempting to release plugins though.

Sam Tsuki
08-15-2008, 01:56
Connorr's not being cocky. He's rightly pointing out that someone with more experience would have done a much better job. There are still numerous errors.nvm...
Didn't take it personally :p


Scrap the loop below 'Check player names' in favour of cmd_target() or find_player().
Names can be 31 characters long.
The fourth parameter to cmd_access() in give_nade() should be 3.
Don't return PLUGIN_HANDLED in forwards that can't be blocked.
Use 'break' to exit loops.
You should evaluate whether the first element of an array is false rather using equal() to determine if a string is empty.Got all of that and will edit ;)


You need to check that str_to_num() doesn't return 0.
award_fb_amount is superfluous.
There are many places where you should cache native return values.Didn't get these ones
Need more explaination plz :|

You overwrite a cvar pointer (award_nades) with a value rather than updating the cvar itself.But it's giving the same effect
But also, how should I fix that?

ConnorMcLeod
08-15-2008, 02:59
The cvar pointer have to stay with the same value during all map.
Only the cvar VALUE have to change with set_pcvar_num(POINTER, VALUE), where VALUE is your str_to_num thing ;)

@Lee
I don't use modules.ini except for modules that can't autoload.

Sam Tsuki
08-15-2008, 03:02
The cvar pointer have to stay with the same value during all map.
Only the cvar VALUE have to change with set_pcvar_num(POINTER, VALUE), where VALUE is your str_to_num thing ;)
Got that! :D
Can you explain these plz

You need to check that str_to_num() doesn't return 0.
award_fb_amount is superfluous.
There are many places where you should cache native return values.

Sam Tsuki
08-15-2008, 06:16
v1.1
Is it alright now???

Dores
08-15-2008, 11:24
i think that there are four parameters to the give_nade console command including the command itself so instead of

if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED

it should be

if (!cmd_access(id, level, cid, 4))
return PLUGIN_HANDLED

just thinking...:o (register_concmd("1.give_nade", "give_nade", ADMIN_LEVEL_D, "2.<name> 3.<nade he,fb,sg> 4.<amount 1,2>")) am i wrong here?

another thing, again not sure, i think that

new arg[21]
read_argv(1, arg, 20)
if(!arg[0]) {
console_print(id, "[AG] Usage: award_nades_toggle <0|1> 0 = off, 1 = on")
return PLUGIN_HANDLED
}
will be the same as simply not putting anything in the award_nades_toggle (for example an admin types: award_nade_toggle with nothing afterwards):

register_concmd("award_nades_toggle", "award_nades_toggle", ADMIN_RCON, "[AG] award_nades_toggle <0|1> 0 = off, 1 = on");

Lee
08-15-2008, 12:02
i think that there are four parameters to the give_nade console command including the command itself so instead of

if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED

it should be

if (!cmd_access(id, level, cid, 4))
return PLUGIN_HANDLED
No, it shouldn't. One of those parameters is optional. The command itself should not be called a parameter.


new arg[21]
read_argv(1, arg, 20)
if(!arg[0]) {
console_print(id, "[AG] Usage: award_nades_toggle <0|1> 0 = off, 1 = on")
return PLUGIN_HANDLED
}

will be the same as simply not putting anything in the award_nades_toggle (for example an admin types: award_nade_toggle with nothing afterwards):

register_concmd("award_nades_toggle", "award_nades_toggle", ADMIN_RCON, "[AG] award_nades_toggle <0|1> 0 = off, 1 = on");
I don't know what it is you're trying to say. That code detects whether the first argument is absent. It's useless since cmd_access() will have already taken care of things by then.

If I were to release this plugin (personally I think it's a pointless plugin and should have stayed in Suggestions/Requests like all of the scripts I've ever posted), I'd rewrite it from scratch. By the time it reaches a high quality, it won't be yours anymore. I'm sorry that I'm not prepared to offer anymore constructive advice, but my patience with inexperienced scripters is wearing very thin. There are a handful of people (not you Sam Tsuki) that genuinely make me angry when I read their "advice". Perhaps I should write that scripting tutorial to give me more of a right to hold people to the high standards I try to obtain myself. It's good that people are trying to learn, but learning by experimentation rather than waiting for people to correct you has to be better for everyone. :)

xjose93
08-15-2008, 13:49
Can u create a cvar to only terrorist if kill, give HE. Thx and bye.

YeanS
08-15-2008, 14:48
Good suggestion ;)

Sam Tsuki
08-15-2008, 15:03
i think that there are four parameters to the give_nade console command including the command itself so instead of
PHP Code:
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED

it should be
PHP Code:
if (!cmd_access(id, level, cid, 4))
return PLUGIN_HANDLED

just thinking...:o (register_concmd("1.give_nade", "give_nade", ADMIN_LEVEL_D, "2.<name> 3.<nade he,fb,sg> 4.<amount 1,2>")) am i wrong here?Looks like Lee answered that
another thing, again not sure, i think that
PHP Code:
new arg[21]
read_argv(1, arg, 20)
if(!arg[0]) {
console_print(id, "[AG] Usage: award_nades_toggle <0|1> 0 = off, 1 = on")
return PLUGIN_HANDLED
}

will be the same as simply not putting anything in the award_nades_toggle (for example an admin types: award_nade_toggle with nothing afterwards):
register_concmd("award_nades_toggle", "award_nades_toggle", ADMIN_RCON, "[AG] award_nades_toggle <0|1> 0 = off, 1 = on");Yea forgot about it
Will edit

Can u create a cvar to only terrorist if kill, give HE. Thx and bye.Will do :)

xjose93
08-15-2008, 15:37
ok :D

Sam Tsuki
08-15-2008, 15:41
New Version: 1.2

xjose93
08-16-2008, 03:13
And... can u put, when terrorist kill with HE grenade (ONLY) give HE award?

Dores
08-16-2008, 13:53
No, it shouldn't. One of those parameters is optional. The command itself should not be called a parameter.

yeah i thought about that. that's why i wasn't sure.

Sam Tsuki
08-18-2008, 22:42
And... can u put, when terrorist kill with HE grenade (ONLY) give HE award?
I'll try to make that possible :wink:

Sam Tsuki
08-21-2008, 11:43
New Version: 1.3

Frogstomp
09-02-2008, 05:25
does it work with CSDM? because i'm having trouble getting it to work

Sam Tsuki
09-02-2008, 17:57
does it work with CSDM? because i'm having trouble getting it to work
Didn't try it
But I think it should work
Check your CSDM settings maybe it's preventing players to have grenades

Dores
09-03-2008, 10:33
does it work with CSDM? because i'm having trouble getting it to work
Yeah, there's a special feature to allow grenades in CSDM.

benamo6
09-03-2008, 14:35
I have a problem with the cvars...
i have them like this:
award_nades = register_cvar("award_nades", "1")
award_he = register_cvar("award_he", "0")
award_fb = register_cvar("award_fb", "0")
award_fb_amount = register_cvar("award_fb_amount", "0")
award_sg = register_cvar("award_sg", "1")
award_team = register_cvar("award_team", "T")
award_headshot = register_cvar("award_headshot", "0")
award_weapon = register_cvar("award_weapon", "deagle, scout")

it just doesnt work. it compile well but when i try it, it gaves nades to ct if they do headshot or kill with weapon. Im using this on a hns server with weaponchance. I want it to give a sg if t kill a ct with a deagle or scout.
Sorry for my bad inglish.
Thanks

Sam Tsuki
09-03-2008, 21:38
I have a problem with the cvars...
i have them like this:
award_nades = register_cvar("award_nades", "1")
award_he = register_cvar("award_he", "0")
award_fb = register_cvar("award_fb", "0")
award_fb_amount = register_cvar("award_fb_amount", "0")
award_sg = register_cvar("award_sg", "1")
award_team = register_cvar("award_team", "T")
award_headshot = register_cvar("award_headshot", "0")
award_weapon = register_cvar("award_weapon", "deagle, scout")

it just doesnt work. it compile well but when i try it, it gaves nades to ct if they do headshot or kill with weapon. Im using this on a hns server with weaponchance. I want it to give a sg if t kill a ct with a deagle or scout.
Sorry for my bad inglish.
Thanks


You can only use one weapon
The "award_weapon" should have one value, otherwise it won't work

benamo6
09-03-2008, 23:08
You can only use one weapon
The "award_weapon" should have one value, otherwise it won't work
i tried without the deagle,scout to.. but it doesnt works if im a ct and i kill a t with knife headshot
it give me all the nades no just sg?

lowled
09-03-2008, 23:42
Nice dude i add it to our hsbonus server =)

Frogstomp
09-05-2008, 19:12
OK i have it working now i just this problem were none of your cvars are working in the hlds console. The only thing that works is "award_nades".

Sam Tsuki
09-05-2008, 19:54
OK i have it working now i just this problem were none of your cvars are working in the hlds console. The only thing that works is "award_nades".
Use the toggle commands

letgoofmyeggs
09-07-2008, 01:05
im runnin this plugin wit v3x's grenade sack and i was wonderin if u can make it so each kil u get ur grenades can build up. currently u stop at 1 he 2 flash n 1 smoke, so can u make it so u keep getin grenades until u reach the limit

Sam Tsuki
09-07-2008, 09:14
im runnin this plugin wit v3x's grenade sack and i was wonderin if u can make it so each kil u get ur grenades can build up. currently u stop at 1 he 2 flash n 1 smoke, so can u make it so u keep getin grenades until u reach the limit
I'll do some research on grenade sack and see what I can do :wink:

Sam Tsuki
09-07-2008, 12:04
New Version: 1.5

letgoofmyeggs
09-07-2008, 17:39
hm so do i stil need v3x's plugin or not

Sam Tsuki
09-07-2008, 21:05
hm so do i stil need v3x's plugin or not
Nope!
But mine doesn't allow you to buy more nades than the original amount
So, it will be better to run both :wink:

letgoofmyeggs
09-07-2008, 22:24
hmmmm nice job. so the new cvars r basicaly the same as v3x's cvars? they need to b the same amount.. correct?

Sam Tsuki
09-07-2008, 22:50
hmmmm nice job. so the new cvars r basicaly the same as v3x's cvars? they need to b the same amount.. correct?
Yup!
But even if they were diffirent, nothing will go wrong
Like, if you put my max HEs cvar to 2 and v3x's to 4
If the user has 2 or 3 HEs, he won't get awards while he still can buy or pick them up until he reachs 4...

Aww my head :shock:

benamo6
09-12-2008, 09:52
Hi, the plugins now works well for me i just have 1 error.
My cvars:
award_nades = register_cvar("award_nades", "1")
award_he = register_cvar("award_he", "0")
award_fb = register_cvar("award_fb", "0")
award_sg = register_cvar("award_sg", "1")
he_max = register_cvar("he_max", "0")
fb_max = register_cvar("fb_max", "0")
sg_max = register_cvar("sg_max", "1")
award_team = register_cvar("award_team", "T")
award_headshot = register_cvar("award_headshot", "0")
award_weapon = register_cvar("award_weapon", "any")

when a ct kill a t with a weapon it gives him 1 sg 2 fb and 1 he?
thats the only mistake i found.

Sam Tsuki
09-13-2008, 11:52
Hi, the plugins now works well for me i just have 1 error.
My cvars:
award_nades = register_cvar("award_nades", "1")
award_he = register_cvar("award_he", "0")
award_fb = register_cvar("award_fb", "0")
award_sg = register_cvar("award_sg", "1")
he_max = register_cvar("he_max", "0")
fb_max = register_cvar("fb_max", "0")
sg_max = register_cvar("sg_max", "1")
award_team = register_cvar("award_team", "T")
award_headshot = register_cvar("award_headshot", "0")
award_weapon = register_cvar("award_weapon", "any")

when a ct kill a t with a weapon it gives him 1 sg 2 fb and 1 he?
thats the only mistake i found.


Will look into it :wink:

benamo6
10-20-2008, 22:09
sam .. can you fix this or not?

Frogstomp
01-03-2009, 02:39
uh i have encountered a new problem... i have random guns, so my csdm_equip.amxx file is different and so i don't think it will allow grenades

koleos
02-02-2009, 17:04
Does this plugin supports zombie mod?

Calibru09
09-07-2022, 05:10
Any ideas why am I getting this ?

L 09/07/2022 - 12:07:40: Function is not present (function "award_notice") (plugin "award_nades.amxx")
L 09/07/2022 - 12:07:40: [AMXX] Displaying debug trace (plugin "award_nades.amxx", version "1.5")
L 09/07/2022 - 12:07:40: [AMXX] Run time error 10: native error (native "set_task")
L 09/07/2022 - 12:07:40: [AMXX] [0] award_nades.sma::client_connect (line 124)
L 09/07/2022 - 12:08:31: Function is not present (function "award_notice") (plugin "award_nades.amxx")
L 09/07/2022 - 12:08:31: [AMXX] Displaying debug trace (plugin "award_nades.amxx", version "1.5")
L 09/07/2022 - 12:08:31: [AMXX] Run time error 10: native error (native "set_task")
L 09/07/2022 - 12:08:31: [AMXX] [0] award_nades.sma::client_connect (line 124)

ChillerX
01-22-2023, 11:42
award_wpn_toggle and cvar will work only for one weapon. Having HE equipped after a knife kill is the dumbest thing period.

Yet another untested and bad plugin in the approved section

gabuch2
01-24-2023, 14:55
There are no active approvers in AMXX.