Raised This Month: $32 Target: $400
 8% 

Player Bounty


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[kirk]./musick`
Senior Member
Join Date: Jun 2007
Location: Tampa, Florida
Old 01-23-2008 , 19:47   Player Bounty
Reply With Quote #1

I have made a plugin that adds a bounty to the player, and if the user killed has a bounty of over $1000, that money is given to the killer. I need someone to test it real quick, and take a look at the code. It compiled correctly with no errors at all, and with my one player testing (for worldspawn and suicide), it seems to have worked. But since I don't have more than one player, I can't test if the bounty adding even works! If someone can test it for me, and take a look at the code and give me any suggestions that would be awesome!

Thanks,
Kirk

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new bounty[32], isHeadShotbcvarhcvar
    

public plugin_init() {
    
register_plugin("Player Bounty""1.0""kirkhalo")
    
register_event("DeathMsg""event_death""a")
    
bcvar register_cvar("amx_bounty""400")
    
hcvar register_cvar("amx_hsbounty""800")
    
register_clcmd("say /showbounty""show_bounty")
    
register_clcmd("say showbounty""show_bounty")
}

public 
client_connect(id){
    
bounty[id] = // Set the client's id bounty to 0
}

public 
event_death(id){
    new 
killer_name[32], victim_name[32], 
    new 
bounty_amount get_pcvar_num(bcvar)
    new 
bounty_hsamount get_pcvar_num(hcvar)
    new 
killer_id read_data(1// Killer id
    
new victim_id read_data(2// Victim id
    
isHeadShot read_data(3// Is headshot?
    
new weapon_name read_data(4// Get the weapon name (used for worldspawn)
    
get_user_name(killer_idkiller_name31// Get killer name
    
get_user_name(victim_idvictim_name31// Get victim name
    
if (!isHeadShot){ // If it isn't a headshot
        
if ((killer_id==victim_id)||(weapon_name=="worldspawn")) { // Check for suicide or worldspawn death
        
return PLUGIN_HANDLED
    
}
    if (
bounty[killer_id]>=0){
        
bounty[killer_id]+=bounty_amount // Add to bounty amount
        // Print message to every client
        
client_print(0print_chat"[AMXX] Player %s now has a bounty of $%i"killer_namebounty[killer_id])
    }

    else {
    if (
bounty[killer_id]>=0){
        
bounty[killer_id]+=bounty_hsamount // Add hs amount to bounty
        // Print message to all players
        
client_print(0print_chat"[AMXX] Player %s now has a bounty of $%i"killer_namebounty[killer_id])
    }
}
    if (
bounty[victim_id]>1000){ // If someone kills a player with a bounty higher than 0
        
give_bounty(killer_idvictim_id// Give the user money through function
    
}
// End event_death function
    
public client_disconnect(id){
    
bounty[id] = 0    // If client disconnects set his id's bounty to 0
}
    
public 
give_bounty(kIDvID){
    if (
is_user_connected(kID)){
        new 
kName[32], vName[32]
        
get_user_name(kIDkName31)
        
get_user_name(vIDvName31)
        new 
current_money cs_get_user_money(kID) + bounty[vID]
        
cs_set_user_money(kIDcurrent_money)    
        
client_print(0print_chat"[AMXX] Player %s has recieved $%i for killing %s"kNamebounty[vID], vName)
        
bounty[vID] = // Reset bounty of the dead
    
}
    return 
PLUGIN_HANDLED
}

public 
show_bounty(id){
    if (
bounty[id]>0){
    
// Display bounty amount to player
    
client_print(idprint_chat"[AMXX] You currently have a %s bounty on your head."bounty[id]) 
    } 
    else {     
        
// user has no bounty currently 
        
client_print(idprint_chat"[AMXX] You currently don't have a bounty.")
    }
    return 
PLUGIN_HANDLED

__________________

Last edited by [kirk]./musick`; 01-23-2008 at 20:16.
[kirk]./musick` is offline
Send a message via AIM to [kirk]./musick`
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-23-2008 , 19:59   Re: Player Bounty
Reply With Quote #2

quick code correction:

killer_name[] and victim_name[] dont need to be global
since they are only used in the event_death(), use them locally there.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
[kirk]./musick`
Senior Member
Join Date: Jun 2007
Location: Tampa, Florida
Old 01-23-2008 , 20:15   Re: Player Bounty
Reply With Quote #3

Thanks a lot, noted.
__________________
[kirk]./musick` is offline
Send a message via AIM to [kirk]./musick`
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-23-2008 , 20:36   Re: Player Bounty
Reply With Quote #4

Have a look at this version

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define MAX_PLAYERS    32

new g_iBounty[MAX_PLAYERS+1]

new 
g_pBountyg_pHsBountyg_pEnable
    

public plugin_init() {
    
register_plugin("Player Bounty""1.0""kirkhalo")

    
g_pEnable register_cvar("amx_bounty_enabled""1")
    
g_pBounty register_cvar("amx_bounty""400")
    
g_pHsBounty register_cvar("amx_hsbounty""800")

    
register_event("DeathMsg""eDeathMsg""a""1>0")

    
register_clcmd("say /showbounty""show_bounty")
    
register_clcmd("say showbounty""show_bounty")
}

public 
client_putinserver(id)
{
    
g_iBounty[id] = 0
}

public 
eDeathMsg()
{
    if(!
get_pcvar_num(g_pEnable))
        return

    new 
iKillerId read_data(1)
    new 
iVictimId read_data(2)

    if( 
iKillerId == iVictimId )
        return

    if( 
get_user_team(iKillerId) == get_user_team(iVictimId) )
        return

    new 
iBountyAmount get_pcvar_num(read_data(3) ? g_pHsBounty g_pBounty)

    new 
szKillerName[32]
    
get_user_name(iKillerIdszKillerName31)

    
g_iBounty[iKillerId] += iBountyAmount
    client_print
(0print_chat"[AMXX] Player %s now has a bounty of $%i"szKillerNameg_iBounty[iKillerId])

    if(
g_iBounty[iVictimId] >= 1000 && is_user_connected(iKillerId))
    {
        new 
szVictimName[32]
        
get_user_name(iVictimIdszVictimName31)
        
cs_set_user_money(iKillerIdcs_get_user_money(iKillerId) + g_iBounty[iVictimId])
        
client_print(0print_chat"[AMXX] Player %s has recieved $%i for killing %s"szKillerNameg_iBounty[iVictimId], szVictimName)
        
g_iBounty[iVictimId] = 0
    
}
}

public 
show_bounty(id){
    if(
g_iBounty[id]>0)
    {
        
client_print(idprint_chat"[AMXX] You currently have a $%i bounty on your head."g_iBounty[id]) 
    } 
    else
    {     
        
client_print(idprint_chat"[AMXX] You currently don't have a bounty.")
    }
    return 
PLUGIN_HANDLED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
[kirk]./musick`
Senior Member
Join Date: Jun 2007
Location: Tampa, Florida
Old 01-23-2008 , 21:30   Re: Player Bounty
Reply With Quote #5

Very nice, I had some ideas of publishing this, since there isn't a plugin that is like it. I don't want to use your code, but I'll be sure to make more compact and concise code. Only if you think I should though.
__________________
[kirk]./musick` is offline
Send a message via AIM to [kirk]./musick`
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-24-2008 , 00:32   Re: Player Bounty
Reply With Quote #6

You should'nt. Don't rush to release some plugins. You should learn more to be able to support your plugin. For the moment, you can't.

Here what I've done for his request.: http://forums.alliedmods.net/showthr...337#post577337

I don't think it's a good idea to display all players. If there are severals bounty players it will flood chat...
__________________

Last edited by Arkshine; 01-24-2008 at 00:34.
Arkshine is offline
[kirk]./musick`
Senior Member
Join Date: Jun 2007
Location: Tampa, Florida
Old 01-24-2008 , 07:47   Re: Player Bounty
Reply With Quote #7

Sounds good, thanks.

Just a quick question, what does the 'MSG_ONE' message look like on the receivers end? Is it in the normal chat area but obviously without a players name or anything?

-Kirk
__________________
[kirk]./musick` is offline
Send a message via AIM to [kirk]./musick`
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-24-2008 , 07:55   Re: Player Bounty
Reply With Quote #8

I'm not sure to understand well. ( Sorry I'm french and my english is very poor ).

You're talking about PrintMessage() function ?

If so, using SayText event allows you to display message with color. ( ^4 : green, ^3 : team color, ^1 : normal color (yellow) )

If not, can you rephraze please ?
__________________
Arkshine is offline
pharse
Senior Member
Join Date: Jan 2008
Location: Germany, BW
Old 01-24-2008 , 08:23   Re: Player Bounty
Reply With Quote #9

I think he meant if it is in the normal chat area like
pharse: [AMXX]You currently have...
or without playername:
[AMXX]You currently have...

I think it is the latter.
__________________
pharse is offline
[kirk]./musick`
Senior Member
Join Date: Jun 2007
Location: Tampa, Florida
Old 01-24-2008 , 15:49   Re: Player Bounty
Reply With Quote #10

Yeah I'm asking about this snippet here:
PHP Code:
    PrintMessageid, const s_Message[] )
    {
        
message_beginMSG_ONEg_iMsg_SayText_id );
        
write_byteid );
        
write_strings_Message );
        
message_end();
    } 
What I was asking was where exactly that message would appear? In the normal chat area (bottom left), or somewhere else?
__________________
[kirk]./musick` is offline
Send a message via AIM to [kirk]./musick`
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 22:12.


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