hi everone
i have this scripting for transfer points with other players
but i find this bug
i can send how much points to my self
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <colorchat>
#include <fun>
#pragma dynamic 32768
#define is_valid_player(%1) (1 <= %1 <= 32)
#define NICK
native dh_get_point(id)
native dh_set_point(id, amount)
public plugin_init()
{
register_plugin("Bank Menu","1.0","noone")
register_clcmd("transfer", "transfer_ammo", ADMIN_ALL, "")
}
public transfer_ammo(id)
{
new param[6]
read_argv(2, param, charsmax(param))
for (new x; x < strlen(param); x++)
{
if(!isdigit(param[x]))
{
set_hudmessage(255, 0, 0, -1.0, 0.4, 0, 0.0, 5.0, 1.0, 1.0, false)
show_hudmessage(id,"")
return 0
}
}
new amount = str_to_num(param)
new ammo = dh_get_point(id)
if (ammo < amount)
{
ChatColor(id,"^4[M#G] ^1You Don't Have Enough Ammopacks !")
return 0
}
read_argv(1, param, charsmax(param))
new player = str_to_num(param)
new player_ammo = dh_get_point(player)
dh_set_point(id, ammo - amount)
dh_set_point(player, player_ammo + amount)
new names[2][32]
get_user_name(id, names[0], 31)
get_user_name(player, names[1], 31)
ColorChat(0, GREY, "^4[M#G] ^1Player ^4 %s ^1Donated ^4%d ^1Ammopaks To Player ^4%s ^1!", names[0], amount, names[1])
return 0
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[ 32 ]
static msg[ 191 ]
vformat( msg, 190, input, 3 )
replace_all( msg, 190, "!g", "^4" )
replace_all( msg, 190, "!y", "^1" )
replace_all( msg, 190, "!t", "^3" )
if(id) players[ 0 ] = id; else get_players( players, count, "ch" )
{
for(new i = 0; i < count; i++)
{
if( is_user_connected( players[ i ] ) )
{
message_begin( MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[ i ] )
write_byte( players[ i ] )
write_string( msg )
message_end( )
}
}
}
}