|
Member
|

04-02-2015
, 10:14
Re: [req] very simple edit plugin
|
#9
|
Quote:
Originally Posted by Hedgehog95
morrow,
Oops, my bad.
PHP Code:
#include <amxmodx>
#include <colorchat>
#include <hamsandwich>
#include <cstrike>
#include <nvault>
#include <fun>
new Lives[33];
new pCvarLifeBuy, pCvarLifeSell;
new pCvarHudsON;
new iLifeBuy, iLifeSell, iHudsON;
new Vault;
public plugin_cfg()
{
iLifeBuy = get_pcvar_num(pCvarLifeBuy);
iLifeSell = get_pcvar_num(pCvarLifeSell);
iHudsON = get_pcvar_num(pCvarHudsON);
}
public plugin_init()
{
new const PLUGIN[] = "DeathRun Advanced Life System";
new const AUTHOR[] = "Gh0s7";
static const VER[] = "1.1c";
register_plugin(PLUGIN, VER, AUTHOR);
register_clcmd("say /lifemenu", "ClCmdLifeMenu");
register_clcmd("say /lives", "ClCmdLives");
//register_event("DeathMsg", "DeathMsg", "ad");
RegisterHam(Ham_Killed, "player", "Ham_Killed", 1);
pCvarLifeBuy = register_cvar("pCvarLifeBuy", "20");
pCvarLifeSell = register_cvar("pCvarLifeSell", "10");
pCvarHudsON = register_cvar("pCvarHudsON", "1");
Vault = nvault_open("DeathRun-Lives");
}
public client_putinserver(id)
LoadLives(id);
public client_disconnect(id)
SaveLives(id);
public ClCmdLifeMenu(id)
{
new Title[64], Item1[64], Item2[64], Item3[64];
formatex(Title, sizeof(Title), "%s You Have %d %s", Lives[id] > 0 ? "\y" : "\d", Lives[id], Lives[id] != 1 ? "Lives" : "life");
formatex(Item1, sizeof(Item1), "%s Use one life^n", Lives[id] > 0 ? "\y" : "\d");
formatex(Item2, sizeof(Item2), "%s Buy one life - $%d", cs_get_user_money(id) >= iLifeBuy ? "\y" : "\d", iLifeBuy);
formatex(Item3, sizeof(Item3), "%s Sell one life - $%d", Lives[id] > 0 ? "\y" : "\d", iLifeSell);
new menu = menu_create(Title, "LifeMenuHandler");
menu_additem(menu, Item1, "1", 0);
menu_additem(menu, Item2, "2", 0);
menu_additem(menu, Item3, "3", 0);
menu_setprop(menu, MPROP_EXITNAME, "\yIesire");
menu_display(id, menu, 0);
return PLUGIN_HANDLED;
}
public LifeMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
return 1;
}
new money = cs_get_user_money(id);
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,sizeof(data), szName,sizeof(szName), callback);
new key = str_to_num(data);
switch(key)
{
case 1:
{
if(is_user_alive(id))
{
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x01 You must be dead to use a life! !");
ClCmdLifeMenu(id);
return PLUGIN_HANDLED;
}
else
{
if(Lives[id] <= 0)
{
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x01 You must to have al least a life to revive !");
ClCmdLifeMenu(id);
return PLUGIN_HANDLED;
}
else
{
Lives[id] -= 1;
ExecuteHamB(Ham_CS_RoundRespawn, id);
ClCmdLifeMenu(id);
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x01 You used a life, now you have^x03 %d %s", Lives[id], Lives[id] == 1 ? "Life" : "Lives");
}
}
}
case 2:
{
if(money < iLifeBuy)
{
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x01 You need^x03 $%d^x01 to buy one life !", iLifeBuy);
ClCmdLifeMenu(id);
return PLUGIN_HANDLED;
}
else if(money >= iLifeBuy)
{
Lives[id] += 1;
cs_set_user_money(id, money - get_pcvar_num(iLifeBuy))
ClCmdLifeMenu(id);
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x03 You bought a life^x01 and gave^x03 $%d^x01 ! Now you have^x03 %d %s", iLifeBuy, Lives[id], Lives[id] == 1 ? "Life" : "Lives");
}
}
case 3:
{
if(Lives[id] <= 0)
{
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x01 You need^x03 at least one life^x01 to sell !");
ClCmdLifeMenu(id);
return PLUGIN_HANDLED;
}
else
{
Lives[id] -= 1;
cs_set_user_money(id, money + get_pcvar_num(iLifeSell));
ClCmdLifeMenu(id);
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x03 You sold a life^x01 and you received^x03 $%d^x01 ! Now You have^x03 %d %s", iLifeSell, Lives[id], Lives[id] == 1 ? "Life" : "Lives");
}
}
}
menu_destroy(menu);
return 1;
}
public ClCmdLives(id)
{
new NamePlayer[32];
get_user_name(id, NamePlayer, sizeof(NamePlayer) - 1);
ColorChat(id, RED, "^x04 [DeathRun - Lives]^x01 Hello^x03 %s^x01! At the moment you have^x03 %d %s^x01 !", NamePlayer, Lives[id], Lives[id] == 1 ? "Life" : "Lives")
return PLUGIN_HANDLED;
}
public Ham_Killed(iVictim, iAttacker)
{
/*-------------------------------*/
new bool:bHeadShot;
new hitGroup = get_pdata_int(iVictim , 75);
if(hitGroup == HIT_HEAD)
bHeadShot = true;
/*-------------------------------*/
new NamePlayer[32];
get_user_name(iVictim, NamePlayer, sizeof(NamePlayer) - 1);
set_hudmessage(0, 255, 255, -1.0, -1.0);
if(iVictim == iAttacker)
return PLUGIN_HANDLED;
if(bHeadShot && iVictim != iAttacker)
{
Lives[iAttacker] += 2;
if(iHudsON >= 1)
show_hudmessage(iAttacker, "[Head Shot] You've got two lives because you killed %s !", NamePlayer);
}
if(!bHeadShot && iVictim != iAttacker)
{
Lives[iAttacker] += 1;
if(iHudsON >= 1)
show_hudmessage(iAttacker, "[Kill] You've got one live because you killed %s !", NamePlayer);
}
if(Lives[iVictim] > 0 || (Lives[iVictim] >= 0 && cs_get_user_money(iVictim) >= get_pcvar_num(pCvarLifeBuy)))
ClCmdLifeMenu(iVictim);
return PLUGIN_CONTINUE;
}
public SaveLives(id)
{
new NamePlayer[32];
get_user_name(id, NamePlayer, sizeof(NamePlayer) - 1);
new VaultKey[64],VaultData[256];
format(VaultKey, 63, "%s-DeathRun-Lives", NamePlayer);
format(VaultData, 255, "%i ", Lives[id]);
nvault_set(Vault, VaultKey, VaultData);
}
public LoadLives(id)
{
new NamePlayer[32];
get_user_name(id, NamePlayer, sizeof(NamePlayer) - 1);
new VaultKey[64], VaultData[256];
format(VaultKey, sizeof(VaultKey) - 1, "%s-DeathRun-Lives", NamePlayer);
format(VaultData, sizeof(VaultData), "%i ", Lives[id]);
nvault_get(Vault, VaultKey, VaultData, sizeof(VaultData));
new PlayerLives[32];
parse(VaultData, PlayerLives, sizeof(PlayerLives) - 1);
Lives[id] = str_to_num(PlayerLives);
}
|
error line 35
RegisterHam(Ham_Killed, "player", "Ham_Killed", 1);
does it fixible  ?
|
|