Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
/*Description:
1) Adds a gravity command which gives an individual player a specific amount of gravity
which remains until player's death, in which case it is set back to normal (800).
2) Allows the players to buy their own gravities.
Credits:
v3x for some coding help which I figured out worked 3 months later. :)
Changelog
1.0 - Original Coding
1.1 - Added Description/Credits/Changelog
1.2 - Coding fixing.
1.3 - Coding fixing.
1.4 - Coding fixing.
1.5 - Coding fixing - hopefully release version.*/
new g_Nick[32]
new g_Number[10]
new Float:g_fGravity[33];
new g_Keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0
public plugin_init()
{
register_plugin("Personal Gravity", "1.5", "SatanWoJ")
register_concmd("amx_pgrav", "gravity", ADMIN_KICK, "<nick> <gravity>")
register_clcmd("say /buygrav", "bgrav", 0)
register_menucmd(register_menuid("Gravity Menu"), g_Keys, "GravMenu")
register_event("ResetHUD", "player_spawn", "b");
register_event("DeathMsg", "hook_death", "a")
}
//-----------------------------------------------------------------------------
public gravity(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
{
return PLUGIN_HANDLED;
}
read_argv(1, g_Nick, 31)
read_argv(2, g_Number, 9)
new target = cmd_target(id, g_Nick, 15)
new Float:f_Amount = str_to_float(g_Number)/800
set_user_gravity(target, f_Amount)
g_fGravity[id] = f_Amount
return PLUGIN_CONTINUE
}
//-----------------------------------------------------------------------------
public bgrav(id)
{
if(!is_user_alive(id))
{
return PLUGIN_HANDLED;
}
new menu[192]
new frags = get_user_frags(id)
if(frags < 5)
{
client_print(id, print_chat, "You do not have enough kills!")
return PLUGIN_HANDLED;
}
format(menu, 191, "Gravity Menu^n^n1. 100 - $5000^n2. 200 - $3500^n3. 400 - $2000^n4. 550 - $1500^n5. 800 - $0^n^n0. BACK.")
show_menu(id, g_Keys, menu)
return PLUGIN_HANDLED
}
//-----------------------------------------------------------------------------
public hook_death()
{
new Victim = read_data(2)
g_fGravity[Victim] = 1.0
return PLUGIN_CONTINUE
}
//-----------------------------------------------------------------------------
public GravMenu(id, key)
{
switch(key)
{
case 0:
{
new money = cs_get_user_money(id)
new Float:grav = get_user_gravity(id)
if(money <= 4999)
{
client_print(id, print_chat, "You have insufficient funds!")
return PLUGIN_HANDLED
}
else if(grav == 0.125)
{
client_print(id, print_chat, "You already are at that gravity!")
return PLUGIN_HANDLED
}
else
{
cs_set_user_money(id, money-5000)
set_user_gravity(id, 0.125)
return PLUGIN_HANDLED
}
}
case 1:
{
new money = cs_get_user_money(id)
new Float:grav = get_user_gravity(id)
if(money <= 3499)
{
client_print(id, print_chat, "You have insufficient funds!")
return PLUGIN_HANDLED
}
else if(grav == 0.25)
{
client_print(id, print_chat, "You already are at that gravity!")
return PLUGIN_HANDLED
}
else
{
cs_set_user_money(id, money-3500)
set_user_gravity(id, 0.25)
return PLUGIN_HANDLED
}
}
case 2:
{
new money = cs_get_user_money(id)
new Float:grav = get_user_gravity(id)
if(money <= 1999)
{
client_print(id, print_chat, "You have insufficient funds!")
return PLUGIN_HANDLED
}
else if(grav == 0.5)
{
client_print(id, print_chat, "You already are at that gravity!")
return PLUGIN_HANDLED
}
else
{
cs_set_user_money(id, money-2000)
set_user_gravity(id, 0.5)
return PLUGIN_HANDLED
}
}
case 3:
{
new money = cs_get_user_money(id)
new Float:grav = get_user_gravity(id)
if(money <= 1499)
{
client_print(id, print_chat, "You have insufficient funds!")
return PLUGIN_HANDLED
}
else if(grav == 0.6875)
{
client_print(id, print_chat, "You already are at that gravity!")
return PLUGIN_HANDLED
}
else
{
cs_set_user_money(id, money-1500)
set_user_gravity(id, 0.6875)
return PLUGIN_HANDLED
}
}
case 4:
{
new Float:grav = get_user_gravity(id)
if(grav == 1.0)
{
client_print(id, print_chat, "You already are at that gravity!")
return PLUGIN_HANDLED
}
else
{
set_user_gravity(id, 1.0)
return PLUGIN_HANDLED
}
}
case 9:
{
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED
}
//-----------------------------------------------------------------------------
public client_connect(id)
{
g_fGravity[id] = 1.0
}
//-----------------------------------------------------------------------------
public player_spawn(id)
{
set_user_gravity(id, g_fGravity[id])
return PLUGIN_CONTINUE
}