PHP Code:
/* Credits -
Exolent - http://forums.alliedmods.net/showthread.php?t=74666
Emp' - http://forums.alliedmods.net/showthread.php?t=46364&highlight=emps+menu
Phil - Great help in the Raffle part :) <3
*/
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <pokemod>
#pragma semicolon 1
#define MAXPLAYERS 33
#define USESOUND "events/enemy_died.wav"
new cost, xps, pme_randxp_amount, pme_randxp_cost;
new pme_raffle_cost, pme_rafflexp_amount, mp_timelimit;
new bool:pMUsed[ MAXPLAYERS ];
new bool:RaffleBought[ MAXPLAYERS ];
new Float:ltime;
public plugin_init()
{
register_plugin("Pokemod buyxp", "1.4", "eskemo + Phil");
register_clcmd("say buyxp", "buyxp_menu");
register_clcmd("say /buyxp", "buyxp_menu");
register_clcmd("say_team buyxp", "buyxp_menu");
register_clcmd("say_team /buyxp", "buyxp_menu");
register_logevent( "EventRoundEnd", 2, "1=Round_End" );
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
pme_randxp_cost = register_cvar("pm_randomxp_cost", "14000");
cost = register_cvar("pm_exp_cost", "8000");
xps = register_cvar("pm_exp_amount", "50");
pme_randxp_amount = register_cvar("pm_randomxp_amount", "1000");
pme_raffle_cost = register_cvar("pm_raffle_cost", "16000");
pme_rafflexp_amount = register_cvar("pm_raffle_amount", "5000");
mp_timelimit = get_cvar_pointer("mp_timelimit");
set_task(0.1, "preRaffle", 0, "", 0, "b", 0);
}
public plugin_precache() {
precache_sound(USESOUND);
}
public fwHamPlayerSpawnPost(iPlayer,id) {
if (is_user_alive(iPlayer)) {
client_print(id, print_chat, "[PM] To buy xp type /buyxp in chat or team chat. Can only buy when alive and once a round.");
}
}
public EventRoundEnd()
{
for(new i = 0; i < MAXPLAYERS; i++)
{
pMUsed[i] = false;
}
}
public client_disconnect(id)
{
pMUsed[id] = false;
}
public buyxp_menu(id)
{
if(!pMUsed[id]){
new menu = menu_create("\rBuyxp:", "menu_handler");
menu_additem(menu, "\wBuyxp", "1", 0);
menu_additem(menu, "\wRandom Buyxp", "2", 0);
//menu_additem(menu, "\wRaffle Ticket!", "3", 0);
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
}else{
client_print(id, print_chat, "[PM] : Please wait till next round before you try and buyxp again.");
}
}
public menu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data);
switch(key)
{
case 1:
{
new money = cs_get_user_money(id);
new price = get_pcvar_num(cost);
new xp = get_pcvar_num(xps);
if(money < price)
{
client_print(id, print_chat, "[PM] You do not have enough money right now.");
return PLUGIN_HANDLED;
}
cs_set_user_money(id, money -= price);
Poke_Give_XP(id, -1, xp);
emit_sound(id, CHAN_ITEM, USESOUND , VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
client_print(id, print_chat, "[PM] %i Experience bought for your pokemon.", xp);
pMUsed[id] = true;
return PLUGIN_HANDLED;
}
case 2:
{
new money = cs_get_user_money(id);
new price1 = get_pcvar_num(pme_randxp_cost);
new randxp_maxamount = get_pcvar_num(pme_randxp_amount);
if(money < price1)
{
client_print(id, print_chat, "[PM] You do not have enough money right now.");
return PLUGIN_HANDLED;
}
new exp = random_num(0, randxp_maxamount);
cs_set_user_money(id, money -= price1);
Poke_Give_XP(id, -1, exp);
emit_sound(id, CHAN_ITEM, USESOUND , VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
client_print(id, print_chat, "[PM] %i Experience bought for your pokemon.", exp);
pMUsed[id] = true;
return PLUGIN_HANDLED;
}
case 3:
{
new money = cs_get_user_money(id);
new price2 = get_pcvar_num(pme_raffle_cost);
if(money < price2)
{
client_print(id, print_chat, "[PM] You do not have enough money right now.");
return PLUGIN_HANDLED;
}
cs_set_user_money(id, money -= price2);
client_print(id, print_chat, "[PM] You have Bought a Raffle Ticket." );
emit_sound(id, CHAN_ITEM, USESOUND , VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
pMUsed[id] = true;
RaffleBought[id] = true;
return PLUGIN_HANDLED;
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
GetRandomPlayer(const flags[]="", const teamORname[]="")
{
new players[32], pnum;
get_players(players, pnum, flags, teamORname);
return (pnum > 0) ? players[random(pnum)] : 0;
}
public preRaffle(id) {
static Float:GameTime;
GameTime = get_gametime();
ltime = get_pcvar_float(mp_timelimit) / 2;
if(GameTime >= ltime)
{
Raffle( id );
}
}
public Raffle( id )
{
if( RaffleBought[ id ] == true)
{
new raffleexp = get_pcvar_num( pme_rafflexp_amount );
new player = GetRandomPlayer("a");
new winner[ 32 ];
get_user_name( player, winner, 31 );
Poke_Give_XP(player, -1, raffleexp);
client_print(0, print_chat, "[PM] player %s has won the raffle of %i exp!.", winner, raffleexp);
}
}
Why woudl the raffle parts not be working please help thanks!