AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking for number of kills (https://forums.alliedmods.net/showthread.php?t=159235)

dreamedward 06-14-2011 11:59

Checking for number of kills
 
So hey guys. I was wondering how could I check if a player has made 3 Kills with a knife?

DjOptimuS 06-14-2011 12:01

Re: Checking for number of kills
 
use an array with all players and count the knife kills

dreamedward 06-14-2011 14:18

Re: Checking for number of kills
 
Could you give me a sample?

Erox902 06-15-2011 03:22

Re: Checking for number of kills
 
Quote:

Originally Posted by dreamedward (Post 1488222)
Could you give me a sample?

Code:
#include <amxmodx> #include <amxmisc> new KnifeKills[33] public plugin_init() {     register_plugin("KnifeCount" ,"0,1", " AUTHOR")     register_event("event_DeathMsg", "eventDeath", "a") } public eventDeath() {     new iAtkr = read_data(1)     static weapon[20]     read_data(4, weapon, charsmax(weapon))         if(weapon[iAtkr] == CSW_KNIFE)     {         KnifeKills[iAtkr] ++         if(KnifeKills[iAtkr] == 2)         {             //do your function         }     }     else     {         return PLUGIN_CONTINUE;     }     return PLUGIN_HANDLED; }
Something like this I believe he ment

Exolent[jNr] 06-15-2011 03:33

Re: Checking for number of kills
 
Quote:

Originally Posted by Erox902 (Post 1488537)
Code:
    static weapon[20]     read_data(4, weapon, charsmax(weapon))         if(weapon[iAtkr] == CSW_KNIFE)

Completely wrong.

weapon is a string containing the weapon name.
It is not an array that you would index by a player's index to get the weapon index.

You would need to check if the string is "knife".

Devil259 06-15-2011 04:08

Re: Checking for number of kills
 
You could use get_weaponname ( id, weapon[], len ) too.

Exolent[jNr] 06-15-2011 04:40

Re: Checking for number of kills
 
Quote:

Originally Posted by Devil259 (Post 1488557)
You could use get_weaponname ( id, weapon[], len ) too.

That gets the weapon name for a given weapon index, not the player's id.

Erox902 06-15-2011 05:18

Re: Checking for number of kills
 
Quote:

Originally Posted by Exolent[jNr] (Post 1488541)
Completely wrong.

weapon is a string containing the weapon name.
It is not an array that you would index by a player's index to get the weapon index.

You would need to check if the string is "knife".

so I could do if(contain(weapon, "knfe") then?

matsi 06-15-2011 05:33

Re: Checking for number of kills
 
Use get_user_weapon( id )

Devil259 06-15-2011 07:08

Re: Checking for number of kills
 
Quote:

Originally Posted by Exolent[jNr] (Post 1488565)
That gets the weapon name for a given weapon index, not the player's id.

Yes, sorry, I confuse. :P


All times are GMT -4. The time now is 23:24.

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