Code:
#include <amxmodx>
#include <cstrike>
new bool:PickPocketed[33][33]
/*
This array is used to check who pick pockted who.
For example:
If i am in slot 1 and pick pocet someone in slot 2
I would to
PickPocketed[1][2] = true
to prevent them from pickpocketing over and over again.
*/
public plugin_init() {
register_plugin( "PickPocket", "1.0", "Zenith77" )
register_clcmd( "amx_pickpocket", "pickpocket", ADMIN_ALL, "Pickpockets the person near you!" )
register_cvar( "pp_ppradius", "10" )
register_cvar( "pp_pickamount", "1000" )
register_cvar( "sv_pickpocket", "1" )
register_logevent("Round_Start", 2, "0=World triggered", "1=Round_Start")
}
public pickpocket(id) {
if( !get_cvar_num("sv_pickpocket") ) {
client_print(id, print_chat, "[AMXX] Sorry, pick pocketing is disabled ! " )
return PLUGIN_HANDLED
}
new pocketer_origin[3]
new victim_origin[3]
new pp_radius
pp_radius = get_cvar_num("pp_ppradius")
get_user_origin(id, pocketer_origin)
for( new i = 1; i<get_maxplayers(); i++) {
if( !is_user_connected(i) ) continue
if( is_user_alive(id) && is_user_alive(i) && get_user_team(id) != get_user_team(i) ) { // prevents pick pocketing from you own team.. etc
if( i == id ) return PLUGIN_CONTINUE
get_user_origin(i, victim_origin)
new distance = get_distance( pocketer_origin, victim_origin )
if( distance <= pp_radius ) {
if( PickPocketed[id][i] ) {
client_print(id, print_chat, "[AMXX] You have already pick pocketed your target! " )
return PLUGIN_HANDLED
}
cs_get_user_money(id)
cs_get_user_money(i)
// the above is just so it can "refernce" it
//[][][][][][][][][][][][][][][][][][][]
// the below checks if the victim has no money or if
// the pick pocketer has 16000 dollars..if so action is cancled!
if(cs_get_user_money(i) == 0) {
client_print(id, print_chat, "[AMXX] Your Target has no money for you to take! Go search for someone else!" )
return PLUGIN_HANDLED
}
if(cs_get_user_money(id) == 16000){
client_print(id, print_chat, "[AMXX] Ok now your just being greedy, you already have the max amount of money [ $16000 ]" )
return PLUGIN_HANDLED
}
//[][][][][][][][][][][][][][][][][][][][]
new amount = get_cvar_num("pp_pickamount")
new result
new p_amount // pick pocketer amount of money
new v_amount // victim amount of money
p_amount = cs_get_user_money(id)
v_amount = cs_get_user_money(i)
if(get_cvar_num("pp_pickamount") > v_amount) {
new result2
// If you will noitce below this one is "equation" is different from the
// one in the code below...this prevents negative numbers and
// makes sure that if the vitim has less money than the pp_pickamount cvar
//it prevents the pickpocketer from getting all the money....
result2 = amount - v_amount
new amount_pp
amount_pp = p_amount + result2
cs_set_user_money(i, 0, 1)
cs_set_user_money(id, amount_pp, 1)
client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")
client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )
PickPocketed[id][i] = true
return PLUGIN_HANDLED
}
if(get_cvar_num("pp_pickamount") < v_amount) {
// once again...do not modify the below....
result = v_amount - amount
new amount_pp = p_amount + result
cs_set_user_money(i, result, 1)
cs_set_user_money(id, amount_pp, 1)
client_print(i, print_chat, "[AMXX] OH NO! You've been pick pocketed!")
client_print(id, print_chat, "[AMXX] Congrats on your successful Pick! You never cease to amaze me ;)" )
PickPocketed[id][i] = true
return PLUGIN_HANDLED
}
}
}
}
return PLUGIN_HANDLED
}
public Round_Start() {
/*
Globaly Resets the PickPocketed bool.
*/
/*
Debugging:
*/
log_amx("Reseting PickPocketing Bool")
new i
for( i = 1; i < get_maxplayers(); i++ ) {
if( !is_user_connected(i) ) continue
new i2
for( i2 = 1; i2 <get_maxplayers(); i++ ) {
// LINE 213 ***********************
PickPocketed[i][i2] = false
// LINE 213 ***********************
}
}
}
public client_connect(id) {
new i
for( i = 1; i < get_maxplayers(); i++) {
PickPocketed[id][i] = false
}
}