So, I tried to add in It a code I found from vittu, but they aren't getting to work, not getting any error when compiling, I can see the item on shop, buy it, It actually uses my points, but it doesn't give me the XP, what is wrong there so I can fix?
Code:
#include <amxmodx>
#include <customshop>
#include <cstrike>
#include <fun>
#define PLUGIN_VERSION "3.x"
additem ITEM_XP1
#define XP1_ID "XP"
#define XP1_NAME "1500 XP"
#define XP1_PRICE 100
#define CHECK_OK 1
#define CHECK_BAD 0
#define MAP_TIMELEFT 11
#define TEAM_CT 2
#define TEAM_T 1
#define TEAM_SPEC 0
new cvar_xp
new cvar_xpcost
new bool:g_bHasItem[33]
public plugin_init()
{
register_plugin("SuperHero XP Shop System", PLUGIN_VERSION, "redemptioN-")
register_cvar("SuperHero XP Shop System", PLUGIN_VERSION)
register_cvar("shm_buyxpamt", "1500")
register_cvar("shm_buyxpcost", "100")
}
public plugin_precache()
ITEM_XP1 = cshop_register_item("XP", "1500XP", 1)
public cshop_item_selected(id, iItem)
{
if(iItem == ITEM_XP1)
g_bHasItem[id] = true
}
public cshop_item_removed(id, iItem)
{
if(iItem == ITEM_XP1)
g_bHasItem[id] = false
}
public func_buyxp(id)
{
//initialize variables
new xpp, xpcost, money
new numbuys
new name[33], authid[33]
cvar_xp = get_cvar_num("shm_buyxpamt")
cvar_xpcost = get_cvar_num("shm_buyxpcost")
xpcost = cvar_xpcost
xpp = 0
if ( CHECK_BUY(id) == CHECK_BAD )
return PLUGIN_CONTINUE
money = cs_get_user_money(id)
get_user_authid(id,authid,32)
get_user_name(id,name,32)
//check to see if user has enough cash
if( money < cvar_xpcost ){
client_print(id,print_chat,"[SHM APP_VER] Sorry, %s. You need at least $%d to buy exp", name, cvar_xpcost )
return PLUGIN_CONTINUE
}
numbuys = money / cvar_xpcost //calculate the max number of transactions (originally used in for loop)
xpp = numbuys * cvar_xp //calculate how much exp they can buy using numbuys
xpcost = numbuys * cvar_xpcost //calculate the cost of the above amount of exp
//conduct transaction
console_print(0, "[SHM APP_VER] %s PURCHASED %d XP : COST %d", name, xpp, xpcost)
cs_set_user_money( id, (money - xpcost) ,1 ) //subtract money from buys
server_cmd("amx_shaddxp ^"%s^" %d", authid, xpp) //add exp for buys
if( cs_get_user_money(id) < 0 ){
cs_set_user_money( id, 0, 1 )
}
//server_cmd("amx_csay yellow [SHM APP_VER] %s has purchased %d exp.^nTo buy exp say buyxp", name, xpp)
return PLUGIN_CONTINUE
}()
public CHECK_BUY(id)
{
new name[33]
get_user_name(id,name,32)
//check to make sure specs arent whording money and buying
//also prevents problems incase users are buying life/armor or if they are revived from the spec team
if( (get_user_team(id) != TEAM_T) && (get_user_team(id) != TEAM_CT) ){
client_print(id,print_chat,"[SHM APP_VER] Sorry, %s. Spectators may not make purchases.", name )
console_print(0, "[SHM APP_VER] CHECK_BUY() failed for reason: user in spec")
return CHECK_BAD
}
//check for invalid IDs
if( id < 1 || id > 32 ){
console_print(0, "[SHM APP_VER] CHECK_BUY() failed for reason: Invalid player ID")
return CHECK_BAD
}
if( is_user_bot(id) != 0 ){
console_print(0, "[SHM APP_VER] CHECK_BUY() failed for reason: User appears to be a bot")
return CHECK_BAD
}
//check if SHmod is disabled
if( get_cvar_num("sv_superheros") != 1 ){
console_print(0, "[SHM APP_VER] CHECK_BUY() failed for reason: SHero mod is disabled")
return CHECK_BAD
}
//disable when loading a map
new time_elasped = (get_cvar_num("mp_timelimit") * 60) - get_timeleft()
if( time_elasped < 60 ){
client_print(id,print_chat,"[SHM APP_VER] Sorry, %s. Please wait until 1 minute after a map change to purchase.", name )
console_print(0, "[SHM APP_VER] CHECK_BUY() failed for reason: map just changed")
return CHECK_BAD
}
//disable just before a map change
if( get_timeleft() < MAP_TIMELEFT ){
client_print(id,print_chat,"[SHM APP_VER] Sorry, %s. It is too close to the end of the map to purchase.", name )
console_print(0, "[SHM APP_VER] CHECK_BUY() failed for reason: map change imminent")
return CHECK_BAD
}
return CHECK_OK
}