yo, i wanted to have a money mod for Sven co-op so i started scripting but somthing isn't right....
Code:
#include <amxmodx>
new moneyhave[]=500
public plugin_init()
{
register_plugin("Money Mod","1.00","StYn0!")
register_menucmd(register_menuid("Moneymod Menu"), 1023, "mh_Adminmoneymenu")
register_clcmd("amx_moneymenu", "md_showmoneyMenu", -1, " ")
register_concmd("amx_money", "showmoney", -1, "Show your money")
}
public showmoney(id)
{
client_print(0,print_chat,"You have %s $",moneyhave)
return PLUGIN_CONTINUE
}
//end of showmoney
/* Menu Admin money menu */
public mh_Adminmoneymenu(id, key) {
new name[32], authid[16]
get_user_name(id, name, 31)
get_user_authid(id, authid, 16)
switch(key) {
//give to 1
case 0: {
client_cmd(id, "localAddmoney(id,100)")
}
//give to all
case 1: {
client_cmd(id, "amx_pbmenu")//not yet
}
//take from 1
case 2: {
client_cmd(id, "amx_pbmenu")//not yet
}
//take from all
case 3: {
client_cmd(id, "amx_pbmenu")//not yet
}
}
return PLUGIN_HANDLED
}
//end of menu
public md_showmoneyMenu(id, level, cid) {
new menu[256]
format(menu, 255, "Moneymod Menu^n^n1. Give money to 1 player^n2. Give money to all players^n3. Take money from 1
player^n4. Take money from all players^n5. Exit")
show_menu(id, ((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)), menu)
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
//This function is the ONLY way this plugin should add/subtract money to a player
//There are checks to prevent overflowing
//To take money away just send the function a negative (-) number
public localAddmoney(id, money)
{
if (money > 0 && moneyhave[id] + money < moneyhave[id]) {
moneyhave[id] = 2147483647
}
else if (money < 0 && (moneyhave[id] + money < -1000000 || moneyhave[id] + money > moneyhave[id])) {
moneyhave[id] = -1000000
}
else {
moneyhave[id] += money
}
}
//end