Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <vault>
#include <engine>
#define KeysPayForItMenu (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<Cool // Keys: 123456789
new bool:ammo[33] //bool can either by true(1) or false(0)
new bool:noflash[33] //[33] means it has 33 slots ranging from 0 to 32
//Player id's range from 1 to 32 so slot 0 wont be used
new bool:norecoil[33] //In this example let's say id is 6
new bool:speed[33] // ammo[id] = true this means set slot 6 to true (1)
new g_nMsgScreenFade // normal integer varaiable with no slots
public plugin_init()
{
// (Plugin name, Version, Author)
register_plugin("PayForIt","1.0","Fire")
// Make a cvar and make it's value 1
register_cvar("sv_payforit","1")
register_cvar("silentwalk_cost", "500")
register_cvar("noclip_cost", "500")
register_cvar("looklikeenemy_cost", "500")
register_cvar("ammo_cost", "500")
register_cvar("invisibility_cost", "500")
register_cvar("noflash_cost", "500")
register_cvar("norecoil_cost", "500")
register_cvar("speed_cost", "500")
register_clcmd( "payforit_menu","ShowPayForItMenu", ADMIN_MENU) /* clcmds are client commands which can be used*/
register_clcmd( "say /pfm","ShowPayForItMenu", ADMIN_MENU) /* by players*/
register_clcmd( "admin_say /pfm","ShowPayForItMenu", ADMIN_MENU) /*(command you type, function it calls, access needed)*/
//calls check_ammo when CurWeapon event is triggered. 1=1 means the weapon must be active (current weapon)
register_event("CurWeapon","check_ammo","be","1=1")
register_event("ScreenFade","FlashedEvent","be","4=255","5=255","6=255","7>199")
//no idea why this is registed twice as it can be done in 1 function
register_event("CurWeapon","change_weapon","be","1=1")
// calls RoundStart function when a player's hud resets (when they spawn)
register_event("ResetHUD","RoundStart","b")
register_menucmd(register_menuid("PayForItMenu"), KeysPayForItMenu, "PressedPayForItMenu")
// repeat the "fast" function every 0.1 seconds
set_task(0.1,"fast",0,"",0,"b")
g_nMsgScreenFade = get_user_msgid("ScreenFade")
}
public ShowPayForItMenu(id, level, cid)
{
// if they dont have access... (1 is total amount of arguments, command included)
if (!cmd_access(id, level, cid, 1))
// stop the function and dont continue to engine (the chat message wont appear)
// code below will not be executed (menu will not show up)
return PLUGIN_HANDLED
// Show the menu
show_menu(id, KeysPayForItMenu, "Menu: ^n1: SilentWalk ^n2: NoClip^n3: Look Like Enemy ^n4: Ammo ^n5: Invisibility ^n6: NoFlash ^n7: NoRecoil ^n8: Speed ^n9: Exit^n", -1, "PayForItMenu") // Display menu
return PLUGIN_HANDLED
}
public PressedPayForItMenu(id, key)
{
/* Menu:
* Menu:
* 1: SilentWalk
* 2: NoClip
* 3: Look Like Enemy
* 4: Ammo
* 5: Invisibility
* 6: NoFlash
* 7: NoRecoil
* 8: Speed
* 9: Exit
*/
// switch is a faster way of doing alot of if's
// for example:
// if (key == 0)
// if (key == 1)
// etc
switch (key)
{
// if the key code pressed is 0 (it's actually 1)
// when seen while playing
// this is the same as:
// if (key == 0)
case 0:
{ // 1
// if the cvar sv_payforit is 0...
if(get_cvar_num("sv_payforit") == 0)
{
// Show a chat message to the person who pressed the key on the menu
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
// get his money and put it in a new variable called 'money'
new money = cs_get_user_money(id)
new silentwalkcost = get_cvar_num("silentwalk_cost")
// if he has less money than needed
if(money < silentwalkcost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", silentwalkcost)
// stop the function and continue to engine (code below won't be executed)
return PLUGIN_CONTINUE
}
// he had enough money, now take some away for the cost
cs_set_user_money(id, money - silentwalkcost)
// 1 means no foot steps, 0 means footsteps
set_user_footsteps(id, 1)
client_print(id, print_chat, "[PFI] Now No one Can Hear You Walking!")
}
// if key == 1
case 1:
{ // 2
if(get_cvar_num("sv_payforit") == 0)
{
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new noclipcost = get_cvar_num("noclip_cost")
if(money < noclipcost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", noclipcost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - noclipcost)
set_user_noclip(id, 1)
client_print(id, print_chat, "[PFI] You Now Have NoClip!")
}
// if key == 2
case 2:
{ // 3
if(get_cvar_num("sv_payforit") == 0)
{
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new looklikeenemycost = get_cvar_num("looklikeenemy_cost")
if(money < looklikeenemycost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", looklikeenemycost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - looklikeenemycost)
// if his team is TERRORIST...
if (get_user_team(id)==1)
// give him ct model
cs_set_user_model(id, "urban")
// if his team is CT...
if (get_user_team(id)==2)
// give him terrorist model
cs_set_user_model(id, "guerilla")
client_print(id, print_chat, "[PFI] Now You Look Like The Enemy!")
}
// if key == 3
case 3:
{ // 4
if(get_cvar_num("sv_payforit") == 0)
{
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new ammocost = get_cvar_num("ammo_cost")
if(money < ammocost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", ammocost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - ammocost)
// if id were 6 then slot 6 of ammo[33] would be true
// this is so we can check if he has unlimited ammo later on
ammo[id]=true
client_print(id, print_chat, "[PFI] Now You Have Unlimted Ammo!")
}
// if key == 4
case 4:
{ // 5
if(get_cvar_num("sv_payforit") == 0)
{
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new invisibilitycost = get_cvar_num("invisibility_cost")
if(money < invisibilitycost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", invisibilitycost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - invisibilitycost)
// Makes him appear transparent, 30 is how much transparent he will be
// 0 would be totally invisible
set_user_rendering(id,kRenderFxNone, 0,0,0, kRenderTransAdd,30)
client_print(id, print_chat, "[PFI] Now No one Can See You!")
}
// if key == 5
case 5:
{ // 6
if(get_cvar_num("sv_payforit") == 0)
{
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new noflashcost = get_cvar_num("noflash_cost")
if(money < noflashcost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", noflashcost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - noflashcost)
noflash[id]=true
client_print(id, print_chat, "[PFI] Now You Cant Be Flashed!")
}
// if key == 6
case 6:
{ // 7
if(get_cvar_num("sv_payforit") == 0)
{
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new norecoilcost = get_cvar_num("norecoil_cost")
if(money < norecoilcost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", norecoilcost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - norecoilcost)
norecoil[id]=true
client_print(id, print_chat, "[PFI] Now You Have No Recoil!")
}
// if key == 7
case 7:
{ // 8
if(get_cvar_num("sv_payforit") == 0)
{
client_print(id, print_chat, "[PFI] This Plugin Is Disabled.")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new speedcost = get_cvar_num("speed_cost")
if(money < speedcost)
{
client_print(id, print_chat, "[PFI] You Don't Have Enough Money ($%i Needed).", speedcost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - speedcost)
speed[id]=true
// makes the player execute a command
// this is so he can run fast
client_cmd(id,"cl_forwardspeed 999")
client_cmd(id,"cl_sidespeed 999")
client_cmd(id,"cl_backspeed 999")
client_print(id, print_chat, "[PFI] Now You Are Much Faster!")
}
// if key == 8
case 8:
{ // 9
client_print(id, print_chat, "[PFI] You Have Exited The PayForIt Menu!")
}
}
return PLUGIN_CONTINUE
}
public check_ammo(id)
{
new clip,wammo
// the function get_user_weapon returns a weapon id
// and it is put into the new variable 'weapon'
new weapon = get_user_weapon(id,clip,wammo)
// || means OR
// if the weapon is a hegrenade OR smokegrenade OR flashbang OR C4
// stop running the function and continue to engine
if(weapon == CSW_HEGRENADE
|| weapon == CSW_SMOKEGRENADE
|| weapon == CSW_FLASHBANG
|| weapon == CSW_C4) return PLUGIN_CONTINUE
// && means AND
// if clip is empty AND he has unlimited ammo...
if(!(clip) && (ammo[id] == true))
{
new weap[32]
get_weaponname(weapon,weap,31)
// give him the weapon he already had
// it will have full ammo
give_item(id,weap)
// emulate the client doing a command
// in this case it switches to the gun
engclient_cmd(id,weap)
engclient_cmd(id,weap)
engclient_cmd(id,weap)
}
return PLUGIN_CONTINUE
}
public FlashedEvent(id)
{
if(!noflash[id])
{
return PLUGIN_CONTINUE
}
message_begin( MSG_ONE,g_nMsgScreenFade,{0,0,0},id )
write_short( read_data( 1 ) ) // Duration
write_short( read_data( 2 ) ) // Hold time
write_short( read_data( 3 ) ) // Fade type
write_byte (0) // Red
write_byte (0) // Green
write_byte (0) // Blue
write_byte (0) // Alpha
message_end()
return PLUGIN_HANDLED
}
public change_weapon(id)
{
// if he has no recoil...
if (norecoil[id])
{
entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})
}
}
public fast()
{
// loops through all players
// 32 is the max number of players in
// the half-life engine
for(new i=0;i<=32;i++)
{
// if hes connected...
if(is_user_connected(i))
{
// if he has the speed boost
if(speed[i])
{
// the server needs sv_maxspeed high to allow
// higher speeds
server_cmd("sv_maxspeed 1000")
set_user_maxspeed(i,1000.0)
}
}
}
return PLUGIN_HANDLED
}
public RoundStart(id)
// someone re-spawned...lets get rid of all their powers
{
ammo[id]=false
noflash[id]=false
norecoil[id]=false
speed[id]=false
client_cmd(id,"cl_forwardspeed 400")
client_cmd(id,"cl_sidespeed 400")
client_cmd(id,"cl_backspeed 400")
set_user_footsteps (id, 0)
set_user_rendering(id,kRenderFxNone, 0,0,0, kRenderNormal,255)
cs_reset_user_model(id)
}