Raised This Month: $ Target: $400
 0% 

Need help with menu and fm_give_item


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 05-30-2009 , 09:11   Re: Need help with menu and fm_give_item
Reply With Quote #8

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>#define PRIMARY_WEAPONS_BIT_SUM ((1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90))
#define SECONDARY_WEAPONS_BIT_SUM ((2<<CSW_P228)|(2<<CSW_ELITE)|(2<<CSW_FIVESEVEN)|(CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE))
#define SECONDARY_WEAPONS_BIT_USE (1<<CSW_USP|1<<CSW_DEAGLE|1<<CSW_P228|1<<CSW_DEAGLE|1<<CSW_GLOCK18|1<<CSW_ELITE)
#define UsingSecondaryWeapon(%1) ((1<<get_user_weapon(%1)) & SECONDARY_WEAPONS_BIT_USE)
#define MENU_STARTID g_menu_data[id][2]new g_menu_data[33][8];#define MAXLEVEL 20
new const GUNNAME[MAXLEVEL][] = { "Glock 18C""USP .45 ACP Tactical""P228 Compact""FiveseveN""Desert Eagle .50 AE""Dual Elite Berettas"
      
"Schmidt TMP""Ingram MAC-10""UMP 45""MP5 Navy""ES P90""Famas""IMI Galil""M3 Super 90""AK-47""M4A1 Carbine""Steyr AUG A1",
      
"SG-552 Commando""SG-550 Auto-Sniper""G3SG1 Auto-Sniper""M249 Para Machinegun" 
}; // Weapon Name Ranksnew const LEVELS[MAXLEVEL] = { 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 
      
66007800910010500120001360015400173003230050600150000
}; // Levels XPnew const RANK[MAXLEVEL][] = { "Warrior", "Warrior", "Warrior", "Warrior", "Mega Natural",
      
"Mega Natural""Mega Natural""Runner""Runner""Runner""Hunter""Hunter""Hunter",
      
"Dark Lord""Dark Lord""Dark Lord""Electric""Electric""Electric""Mystic Jumper""Mystic Jumper"
}; // Players Ranksnew const levelup[] = { "msx/levelup.wav" }
new PlayerXP[33], PlayerLevel[33], iKills[33]
new 
XP_KillSaveXP
new g_MaxPlayers
new g_maxplayers
new death_msg_enable
new PlayerHumanKills[33]
new 
PlayerZombieKills[33]
new 
PlayerHumanDeaths[33]
new 
PlayerZombieDeaths[33]const KEYSMENU = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
//============================================================//
// ~[ Sounds/Waves ]~ //
//============================================================//
new const music1[][] = {
      
"msx/brains1.wav",
      
"msx/brains2.wav",
      
"msx/brains3.wav",
      
"msx/brains4.wav"
}
new const 
music2[][] = {
      
"msx/brains5.wav",
      
"msx/brains6.wav",
      
"msx/brains7.wav",
      
"msx/brains8.wav",
      
"msx/brains9.wav",
      
"msx/brains10.wav",
      
"msx/brains11.wav",
      
"msx/brains12.wav"
}
//============================================================//
// ~[ Plugin Start ]~ //
//============================================================//
public plugin_precache()
{
      
register_forward(FM_Spawn"fwdSpawn");
      
register_forward(FM_Touch,"fwTouch");
      
g_MaxPlayers get_maxplayers();
}
public 
plugin_init()
{
      
register_plugin("Left 4 Dead XP""1.4""xFrost")
 
      
// Events //
      
register_event("DeathMsg""event_deathmsg""a")
      
// Forwards //
      
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
      
// Cvars //
      
SaveXP register_cvar("SaveXP""1")
      
XP_Kill register_cvar("XP_per_kill""7")
      
death_msg_enable register_cvar("l4d_dmsg","1")
 
      
// Comands //
      
register_clcmd("say level""ShowLevel")
      
register_clcmd("say /level""ShowLevel")
      
// Other //
      
register_dictionary("l4d.txt");
}
public 
event_deathmsg()
{
      new 
g_attacker read_data(1);
      new 
g_victim read_data(2)
      new 
attacker_msg[32]
      new 
victim_msg[32]
      
get_user_name(g_attackerattacker_msg31)
      
get_user_name(g_victimvictim_msg31)
      
PlayerXP[g_attacker] += get_pcvar_num(XP_Kill)
      
set_hudmessage(0255500.500.3312.02.1)
      
show_hudmessage(g_attacker"%L"LANG_SERVER"KILL_XP"get_pcvar_num(XP_Kill))
      while(
PlayerXP[g_attacker] >= LEVELS[PlayerLevel[g_attacker]])
      {
            
PlayerLevel[g_attacker] += 1
            client_cmd
(g_attacker"spk %s"levelup)
            
client_printcolor(g_attacker"/ctr%s /yreaches level /g%i!"PlayerLevel[g_attacker])
      }
      if(
PlayerXP[g_attacker] <= 34980)
      {
            
PlayerXP[g_attacker] += get_pcvar_num(XP_Kill)
      }
      if (
get_user_team(g_attacker) == 2// ct killed t
      
{
            if((
<= g_attacker <= g_maxplayers))
            {
                  
iKills[g_attacker]++;
            }
            if(
get_pcvar_num(death_msg_enable) == 1)
            {
                  
set_hudmessage(052550.010.3110.013.00.010.012
                  
show_hudmessage(0"%s has been owned by %s!"victim_msgattacker_msg)
                  
client_cmd0"spk %s"music2[random_num(0,sizeof music2 1)])
            }
            
PlayerZombieDeaths[g_victim] += 1
            PlayerZombieKills
[g_attacker] += 1
      
}
      if (
get_user_team(g_attacker) == 1// t killed ct
      
{
            if(
get_pcvar_num(death_msg_enable) == 1)
            {
                  
set_hudmessage(2550100.010.2110.013.00.010.013
                  
show_hudmessage(0"%s's brains has been eaten by %s!"victim_msgattacker_msg)
                  
client_cmd0"spk %s"music1[random_num(0,sizeof music1 1)])
            }
            
PlayerHumanDeaths[g_victim] += 1
            PlayerHumanKills
[g_attacker] += 1
      
}
      
ShowLevel(g_attacker)
      
SaveLevel(g_attacker)
}
public 
ShowLevel(id)
{
      
client_printcolor(id"%L"LANG_SERVER"LEVEL_TEXT"PlayerLevel[id],PlayerXP[id],LEVELS[PlayerLevel[id]])
      
client_printcolor(id"%L"LANG_SERVER"LEVEL_TEXT2"GUNNAME[PlayerLevel[id]],RANK[PlayerLevel[id]])

public 
client_connect(id)
{
      if(
get_cvar_num("SaveXP") == 1) {
            
LoadLevel(id)
            
client_printcolor(0"%L"LANG_SERVER"XP_LOADED")
      }

public 
client_disconnect(id)
{
      if(
get_pcvar_num(SaveXP) == 1)
      {
 
            
SaveLevel(id)
      }
      
PlayerXP[id] = 0
      PlayerLevel
[id] = 0
}
public 
SaveLevel(id)
{
      new 
authid[32]; 
      
get_user_authid(id,authid,31); 
      new 
vaultkey[64], vaultdata[64]; 
 
      
format(vaultkey,63,"ANIMAL-%s-xp",authid); 
      
format(vaultdata,63,"%d",PlayerXP[id]); 
      
set_vaultdata(vaultkey,vaultdata); 
      
format(vaultkey,63,"ANIMAL-%s-level",authid); 
      
format(vaultdata,63,"%d",PlayerLevel[id]); 
      
set_vaultdata(vaultkey,vaultdata);

public 
LoadLevel(id)
{
      new 
authid[32]; 
      
get_user_authid(id,authid,31); 
      new 
vaultkey[64], vaultdata[64]; 
      
format(vaultkey,63,"ANIMAL-%s-xp",authid); 
      
get_vaultdata(vaultkey,vaultdata,63); 
      
PlayerXP[id] = str_to_num(vaultdata); 
      
format(vaultkey,63,"ANIMAL-%s-level",authid); 
      
get_vaultdata(vaultkey,vaultdata,63);
      
PlayerLevel[id] = str_to_num(vaultdata);

//============================================================//
// ~[ No Pickup Weapons]~ //
//============================================================//
public fwTouchent id )
{
      if ( !( 
<= id <= g_MaxPlayers ) || !pev_valident ) || !( pevent pev_flags ) & FL_ONGROUND ) )
            return 
FMRES_IGNORED;
 
      
//This will block picking up all weapons except backpack (c4)
      
static szEntModel[32];
      
pevent pev_model szEntModel 31 );
 
      return 
equalszEntModel "models/w_backpack.mdl" ) ? FMRES_IGNORED FMRES_SUPERCEDE

//============================================================//
// ~[ No Buy ]~ //
//============================================================//
public fwdSpawn(iEnt)
{
      static 
s_szClassName[32];
      
pev(iEntpev_classnames_szClassName31);
      if (
equal(s_szClassName"func_buyzone"))
            return 
FMRES_SUPERCEDE;
      return 
FMRES_IGNORED;
}
//============================================================//
// ~[ FM Give Item ]~ //
//============================================================//
public fw_PlayerSpawn_Post(id)
{
      
set_task(0.1"show_menu_level"id);
}
public 
show_menu_level(id)
{
      if ( !
is_user_alive(id) )
            return;
 
      static 
menu[510], len, class;
      
len 0;
 
      new 
xKeys MENU_KEY_0;
      new 
max min(MENU_STARTID+7sizeof (LEVELS));
      new 
iPosNum 0;
 
      
// Title
      
len += formatex(menu[len], sizeof menu len"%L"LANG_SERVER"PLAYER_INFO"PlayerLevel[id], PlayerXP[id], LEVELS[PlayerLevel[id]])
 
      
// 1-7. Class List
      
for (class = MENU_STARTID; class < max; class++)
      {
            if ( 
PlayerLevel[id] < class)
            { 
                  
len += formatex(menu[len], sizeof menu len"%L"LANG_SERVER"INACTIVE_LEVEL", ++iPosNumGUNNAME[class], class)
            } 
            else
            {
                  
xKeys |= (1<<iPosNum++);
                  
len += formatex(menu[len], sizeof menu len"%L"LANG_SERVER"ACTIVE_LEVEL", class-MENU_STARTID+1GUNNAME[class], class)
            }
      }
      if ( 
MENU_STARTID != && MENU_STARTID != 21 )
      { 
            
xKeys |= (1<<7)
            
xKeys |= (1<<8)
 
            
len += formatex(menu[len], sizeof menu len"^n\r8.\w %L^n\r9.\w %L^n^n\r0.\w %L"id"BACK_MENU"id"NEXT_MENU"id"EXIT_MENU")
      }
      else if ( 
MENU_STARTID == )
      {
            
xKeys |= (1<<8)
 
            
len += formatex(menu[len], sizeof menu len"^n\r9.\w %L^n^n\r0.\w %L"id"NEXT_MENU"id"EXIT_MENU")
      }
      else if ( 
MENU_STARTID == 21 )
      { 
            
xKeys |= (1<<7)
 
            
len += formatex(menu[len], sizeof menu len"^n\r8.\w %L^n^n\r0.\w %L"id"BACK_MENU"id"EXIT_MENU")
      }
      switch(
key)
      {
            case 
0:{
                  
drop_secondary(id)
                  
fm_give_item(id"weapon_glock18")
                  
fm_set_user_bpammo(idCSW_GLOCK18100)
            }
            case 
1:{
                  
drop_secondary(id)
                  
fm_give_item(id"weapon_usp")
                  
fm_set_user_bpammo(idCSW_USP100)
            }
            case 
2:{
                  
drop_secondary(id)
                  
fm_give_item(id"weapon_p228")
                  
fm_set_user_bpammo(idCSW_P22852)
            }
            case 
3:{
                  
drop_secondary(id)
                  
fm_give_item(id"weapon_fiveseven")
                  
fm_set_user_bpammo(idCSW_FIVESEVEN100)
            }
            case 
4:{
                  
drop_secondary(id)
                  
fm_give_item(id"weapon_deagle")
                  
fm_set_user_bpammo(idCSW_DEAGLE35)
            }
            case 
5:{
                  
drop_secondary(id)
                  
fm_give_item(id"weapon_elite")
                  
fm_set_user_bpammo(idCSW_ELITE120)
            }
            case 
6:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_tmp")
                  
fm_set_user_bpammo(idCSW_TMP120)
            }
            case 
7:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_mac10")
                  
fm_set_user_bpammo(idCSW_MAC10120)
            }
            case 
8:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_ump45")
                  
fm_set_user_bpammo(idCSW_UMP45100)
            }
            case 
9:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_mp5navy")
                  
fm_set_user_bpammo(idCSW_MP5NAVY120)
            }
            case 
10:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_p90")
                  
fm_set_user_bpammo(idCSW_P90100)
            }
            case 
11:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_famas")
                  
fm_set_user_bpammo(idCSW_FAMAS90)
            }
            case 
12:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_galil")
                  
fm_set_user_bpammo(idCSW_GALIL90)
            }
            case 
13:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_m3")
                  
fm_set_user_bpammo(idCSW_M332)
            }
            case 
14:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_ak47")
                  
fm_set_user_bpammo(idCSW_AK4790)
            }
            case 
15:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_m4a1")
                  
fm_set_user_bpammo(idCSW_M4A190)
            }
            case 
16:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_aug")
                  
fm_set_user_bpammo(idCSW_AUG90)
            }
            case 
17:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_sg552")
                  
fm_set_user_bpammo(idCSW_SG55290)
            }
            case 
18:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_sg550")
                  
fm_set_user_bpammo(idCSW_SG55090)
            }
            case 
19:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_g3sg1")
                  
fm_set_user_bpammo(idCSW_G3SG190)
            }
            case 
20:{
                  
drop_primary(id)
                  
fm_give_item(id"weapon_m249")
                  
fm_set_user_bpammo(idCSW_M249200)
            }
      }
}
//============================================================//
// ~[ Stocks ]~ //
//============================================================//
stock client_printcolor(const id, const input[], any:...)
{
      new 
msg[191], players[32], count 1;
      
vformat(msg,190,input,3);
      
replace_all(msg,190,"/g","^4");// green clr
      
replace_all(msg,190,"/y","^1");// orange clr
      
replace_all(msg,190,"/ctr","^3");// team clr
      
if (idplayers[0] = id; else get_players(players,count,"ch");
      for (new 
i=0;i<count;i++)
            if (
is_user_connected(players[i]))
      {
            
message_begin(MSG_ONE_UNRELIABLE76_players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
      }
}
stock fm_set_user_bpammo(idiWeaponiAmount

      new 
iOffset
      switch(
iWeapon
      { 
            case 
CSW_AWPiOffset 377
                  case 
CSW_SCOUTCSW_AK47CSW_G3SG1iOffset 378
                  case 
CSW_M249iOffset 379
                  case 
CSW_FAMASCSW_M4A1CSW_AUGCSW_SG550CSW_GALICSW_SG552iOffset 380
                  case 
CSW_M3CSW_XM1014iOffset 381
                  case 
CSW_USPCSW_UMP45CSW_MAC10iOffset 382
                  case 
CSW_FIVESEVENCSW_P90iOffset 383
                  case 
CSW_DEAGLEiOffset 384
                  case 
CSW_P228iOffset 385
                  case 
CSW_GLOCK18CSW_MP5NAVYCSW_TMPCSW_ELITEiOffset 386
                  case 
CSW_FLASHBANGiOffset 387
                  case 
CSW_HEGRENADEiOffset 388
                  case 
CSW_SMOKEGRENADEiOffset 389
                  case 
CSW_C4iOffset 390
                  default:return; 
      } 
      
set_pdata_int(idiOffsetiAmount); 
}
stock fm_give_item(index, const item[])
{
      if (!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
            return 
0
      
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
      if (!
pev_valid(ent))
            return 
0
      
new Float:origin[3]
      
pev(indexpev_originorigin)
      
set_pev(entpev_originorigin)
      
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
      
dllfunc(DLLFunc_Spawnent)
      new 
save pev(entpev_solid)
      
dllfunc(DLLFunc_Touchentindex)
      if (
pev(entpev_solid) != save)
            return 
ent
      engfunc
(EngFunc_RemoveEntityent)
      return -
1
}
stock drop_secondary(id)
{
      new 
weapons[32], num
      get_user_weapons
(idweaponsnum)
      for (new 
0numi++) 
      {
            if (
SECONDARY_WEAPONS_BIT_SUM & (2<<weapons[i])) 
            {
                  static 
wname[32]
                  
get_weaponname(weapons[i], wnamesizeof wname 1)
                  
engclient_cmd(id"drop"wname)
            }
      }
}
stock drop_primary(id
{
      new 
weapons[32], num
      get_user_weapons
(idweaponsnum)
      for (new 
0numi++) {
            if (
PRIMARY_WEAPONS_BIT_SUM & (1<<weapons[i])) 
            {
                  static 
wname[32]
                  
get_weaponname(weapons[i], wnamesizeof wname 1)
                  
engclient_cmd(id"drop"wname)
            }
      }

Edit: Oh aye, didn't fix anything, just showing identitation.

Last edited by SnoW; 05-30-2009 at 09:14.
SnoW is offline
Send a message via MSN to SnoW
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode