Raised This Month: $ Target: $400
 0% 

pev(_index, _value, any:...) function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-14-2009 , 07:12   Re: pev(_index, _value, any:...) function
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#define EXTRAOFFSET   5
#define OFFSET_MONEY   115
#define OFFSET_TEAM   114
#define OFFSET_INTERALMODEL  126
enum CsTeams
{
 
CS_TEAM_UNASSIGNED// 0
 
CS_TEAM_T// 1
 
CS_TEAM_CT// 2
 
CS_TEAM_SPECTATOR // 3
}
enum CsInternalModel
{
 
CS_DONTCHANGE// 0
 
CS_CT_URBAN// 1
 
CS_T_TERROR// 2
 
CS_T_LEET// 3
 
CS_T_ARCTIC// 4
 
CS_CT_GSG9// 5
 
CS_CT_GIGN// 6
 
CS_CT_SAS// 7
 
CS_T_GUERILLA// 8
 
CS_CT_VIP// 9
 
CZ_T_MILITIA// 10
 
CZ_CT_SPETSNAZ // 11
}
new 
cvar_drop_at_leastcvar_drop_countcvar_dropcvar_pick_levelcvar_delay_timecvar_roundcvar_drop_mincvar_drop_moneycvar_can_not_pick_up
new g_MaxPlayersg_DropCountg_Round
new bool:iCanPickUp[33]
new 
bool:iCantPickUp[33]
new 
Float:g_DropTime[33]
new 
g_MoneyModel[3][] = 
{
 
"models/Edoo/Bag_green.mdl"
 
"models/Edoo/Bag_red.mdl"
 
"models/Edoo/Bag_purple.mdl"
}
new 
g_Sounds[3][] = 
{
 
"sound/ddmoney/dispensemoney.wav"
 
"sound/ddmoney/woop.wav"
 
"sound/misc/getmoney.wav"
}
public 
plugin_init()
{
 
register_plugin("扔钱与掉钱""1.0""EdooCn")
 
 
register_dictionary("ddmoney.txt")
 
 
cvar_drop_at_least register_cvar("Ed_drop_max_num""5000")
 
cvar_drop_count  register_cvar("Ed_drop_count""100")
 
cvar_drop  register_cvar("Ed_drop""3000")
 
cvar_pick_level  register_cvar("Ed_pick_up_level""200000")
 
cvar_delay_time  register_cvar("Ed_delay_time""1.0")
 
cvar_round   register_cvar("Ed_round""1")
 
cvar_drop_min  register_cvar("Ed_drop_min""10000")
 
cvar_drop_money  register_cvar("Ed_dropmoney""100000")
 
cvar_can_not_pick_up register_cvar("Ed_can_not_pick_up""1")
 
 
register_clcmd("drop""hook_drop")
 
 
register_touch("Money_drop""player""drop_touch")
 
 
register_event("TextMsg""event_Restart""ac""2&#Game_Commencing""2&#Game_will_restart")
 
register_event("DeathMsg""event_DeathMsg""a")
 
register_event("HLTV""event_NewRound""a""1=0""2=0")
 
register_event("CurWeapon","event_CurWeapon","be","1=1")
 
 
register_logevent("event_Free_Time_End"2"0=World triggered""1=Round_Start")
 
 
g_MaxPlayers get_maxplayers()
}
public 
plugin_precache()
{
 
precache_model(g_MoneyModel[0])
 
precache_model(g_MoneyModel[1])
 
precache_model(g_MoneyModel[2])
 
precache_sound(g_Sounds[0])
 
precache_sound(g_Sounds[1])
 
precache_sound(g_Sounds[2])
}
public 
client_putinserver(id)
{
 
iCanPickUp[id] = true
 iCantPickUp
[id] = true
}
public 
client_disconnect(id)
{
 
iCanPickUp[id] = false
 iCantPickUp
[id] = false
}
public 
hook_drop(id)
{
 new 
iClipiAmmoiWeapon get_user_weapon(idiClipiAmmo)
 new 
iMoney fm_cs_get_user_money(id)
 new 
iDropMoney random_num(get_pcvar_num(cvar_drop), get_pcvar_num(cvar_drop_at_least))
 
 if (!
is_user_alive(id))
  return 
PLUGIN_HANDLED
 
if (iWeapon == CSW_KNIFE)
 {
  new 
Float:flGameTime get_gametime() 
  if( 
flGameTime g_DropTime[id] < get_gametime())
  {
   
g_DropTime[id] = 0.0
   
if (iMoney get_pcvar_num(cvar_drop_at_least))
   {
    new 
iMessage[128]
    
format(iMessage127"%L"LANG_PLAYER"NOT_ENOUGH_MONEY"get_pcvar_num(cvar_drop_at_least))
    
color_saytext(iMessageMSG_ALLid3)
    
client_cmd(id"spk %s"g_Sounds[1])
    return 
PLUGIN_HANDLED
   
}
   if (
g_DropCount get_pcvar_num(cvar_drop_count))
   {
    new 
iMessage[128]
    
format(iMessage127"%L"LANG_PLAYER"ENOUGH_MONEY_COUNT")
    
color_saytext(iMessageMSG_ALLid3)
    return 
PLUGIN_HANDLED
   
}
   
g_DropCount++
   
fm_cs_set_user_money(idiMoney-iDropMoney1)
   new 
Float:fOrigin[3], Float:fVelo[3], Float:fUserVeloCity[3]
   
pev(idpev_originfOrigin)
   
pev(idpev_velocityfUserVeloCity)
   
velocity_by_aim(id450fVelo)
   
fVelo[0] += fUserVeloCity[0]
   
fVelo[1] += fUserVeloCity[1]
   
fVelo[2] = 0.0
   fVelo
[0] += random_float(-100.0100.0)
   
fVelo[1] += random_float(-100.0100.0)
   new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"info_target"))
   
set_pev(iEntpev_classname"Money_drop")
   
engfunc(EngFunc_SetModeliEntg_MoneyModel[0])
   
set_pev(iEntpev_originfOrigin)
   
set_pev(iEntpev_solidSOLID_TRIGGER)
   
set_pev(iEntpev_movetypeMOVETYPE_TOSS)
   
set_pev(iEntpev_velocityfVelo)
   
set_pev(iEntpev_ownerid)
   
set_pev(iEntpev_iuser1g_Round)
   
set_pev(iEntpev_iuser2iDropMoney)
   
set_pev(iEntpev_fuser1get_gametime())
   
set_pev(iEntpev_teamfm_cs_get_user_team(id))
   if (
fm_cs_get_user_team(id) == CS_TEAM_CT)
   {
    
fm_set_rendering(iEntkRenderFxGlowShell00255kRenderNormal15)
   }
   else if(
fm_cs_get_user_team(id) == CS_TEAM_T){
    
fm_set_rendering(iEntkRenderFxGlowShell25500kRenderNormal15)
   }
   new 
Float:mina[3]
   
mina[0]=-10.0
   mina
[1]=-10.0
   mina
[2]=-2.0
   
new Float:maxa[3]
   
maxa[0]=10.0
   maxa
[1]=10.0
   maxa
[2]=2.0
   engfunc
(EngFunc_SetSizeiEntminamaxa)
   
client_cmd(id"spk %s"g_Sounds[0])
  }
  else 
g_DropTime[id] = flGameTime
  
return PLUGIN_HANDLED
 
}
 return 
PLUGIN_CONTINUE
}
public 
event_CurWeapon(id)
{
 new 
iWeapon read_data(2)
 if (
iWeapon == CSW_KNIFE)
 {
  
g_DropTime[id] = 0.0
 
}
 else 
g_DropTime[id] = get_gametime()
}
public 
drop_touch(iEntid)
{
 new 
iMoney fm_cs_get_user_money(id)
 new 
iOwner pev(iEntpev_owner)
 new 
iMoneyTouch pev(iEntpev_iuser2)
 new 
Float:iTime pev(iEntpev_fuser1)
 new 
iEntTeam pev(iEntpev_team)
 new 
iTeam get_user_team(id)
 if (!
is_user_alive(id))
  return 
PLUGIN_HANDLED
 
if (get_gametime()-iTime<0.3)
  return 
PLUGIN_HANDLED
 
if (iEntTeam)
 {
  if (
id == iOwner)
   return 
PLUGIN_HANDLED
  
if (iEntTeam != iTeam)
   return 
PLUGIN_HANDLED
 
}
 if (
iMoney  get_pcvar_num(cvar_pick_level))
 {
  if (
iCantPickUp[id])
  {
   
iCantPickUp[id] = false
   set_task
(0.1"cant_Pickup"id)
  }
  return 
PLUGIN_HANDLED
 
}
 if (
iCanPickUp[id])
 {
  
iCanPickUp[id] = false
  set_task
(get_pcvar_float(cvar_delay_time), "can_Pickup"id)
  
fm_cs_set_user_money(idiMoney+iMoneyTouch1)
  
engfunc(EngFunc_RemoveEntityiEnt)
  
g_DropCount--
  new 
iName[32], iMessage[128]
  
get_user_name(idiName31)
  
format(iMessage127"%L"LANG_SERVER"PLAYER_PICK_UP_MONEY"iNameiMoneyTouch)
  
color_saytext(iMessageMSG_ALLid)
  
client_cmd(id"spk %s"g_Sounds[2])
 
 }
 return 
PLUGIN_HANDLED
}
public 
can_Pickup(id)
{
 
iCanPickUp[id] = true
}
public 
cant_Pickup(id)
{
 if (
get_pcvar_num(cvar_can_not_pick_up))
 {
  new 
iMessage[128]
  
format(iMessage127"%L"LANG_SERVER"CANT_PICK_UP_MONEY"get_pcvar_num(cvar_pick_level))
  
color_saytext(iMessageMSG_ALL_3)
  
color_saytext(iMessageMSG_ALL_3)
  return 
PLUGIN_HANDLED
 
}
 return 
PLUGIN_CONTINUE
}
public 
event_Restart()
{
 
g_Round 0
}
public 
event_Free_Time_End()
{
 new 
iMessage1[128], iMessage2[128], iMessage3[128]
 
format(iMessage1127"%L"LANG_SERVER"NOTICE_ONE"get_pcvar_num(cvar_drop), get_pcvar_num(cvar_drop_at_least))
 
format(iMessage2127"%L"LANG_SERVER"NOTICE_TWO")
 
format(iMessage3127"%L"LANG_SERVER"NOTICE_THREE")
 
color_saytext(iMessage1MSG_ALL_1)
 
color_saytext(iMessage2MSG_ALL_4)
 
color_saytext(iMessage3MSG_ALL_4)
}
public 
event_NewRound()
{
 
g_Round++
 for (new 
id 1id g_MaxPlayersid++) iCantPickUp[id] = true
 
new iEnt = -1
 
while ((iEnt fm_find_ent_by_class(iEnt"Money_drop")) != 0)
 {
  if (
g_Round pev(iEntpev_iuser1) > get_pcvar_num(cvar_round) || g_Round == get_pcvar_num(cvar_round))
  {
   
engfunc(EngFunc_RemoveEntityiEnt)
   
g_DropCount--
  }
 }
}
public 
random_drop_money(ori_ammount)
{
 new 
iDropControl
 
new iMinDropMoney get_pcvar_num(cvar_drop_min)
 if(
iMinDropMoney<1000)
 {
  
iMinDropMoney 1000
  set_pcvar_num
(cvar_drop_min1000)
 }
 if(
ori_ammount>=iMinDropMoney)
 {
  new 
iDropMoney get_pcvar_num(cvar_drop_money)
  if(
iDropMoney iMinDropMoney+1000)
  {
   
iDropMoney iMinDropMoney
   set_pcvar_num
(cvar_drop_moneyiDropMoney)
  }
  
iDropControl random_num(0iDropMoney)
  if(
ori_ammount >= iDropControl)
   return 
random_num(3,7)*random_num(4,8)*random_num(5,10)
  else
   return 

 
}
 return 
0
}
public 
event_DeathMsg()
{
 new 
iKiller read_data(1)
 new 
iVictim read_data(2)
 if (!
iKiller) return PLUGIN_CONTINUE
 
if (fm_cs_get_user_team(iKiller) == fm_cs_get_user_team(iVictim)) return PLUGIN_CONTINUE
 
 
new iVictimMoney fm_cs_get_user_money(iVictim)
 if (
g_DropCount get_pcvar_num(cvar_drop_count))
 {
  new 
iDropPrec random_drop_money(iVictimMoney)
  if(
iDropPrec>0)
  {
   new 
iDropedMoney iVictimMoney*iDropPrec/1000
   
new iMoney iDropedMoney*80/100
   fm_cs_set_user_money
(iVictimiVictimMoney-iDropedMoney1)
   new 
Float:fVictimCoord[3]
   
pev(iVictimpev_originfVictimCoord)
   
g_DropCount++
   new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"info_target"))
   
set_pev(iEntpev_classname"Money_drop")
   
set_pev(iEntpev_originfVictimCoord)
   
set_pev(iEntpev_solidSOLID_TRIGGER)
   
set_pev(iEntpev_movetypeMOVETYPE_TOSS)
   
set_pev(iEntpev_fuser1get_gametime())
   
set_pev(iEntpev_iuser1g_Round)
   
set_pev(iEntpev_iuser2iMoney)
   
set_pev(iEntpev_owneriVictim)
   if(
iMoney<10000)
    
engfunc(EngFunc_SetModeliEntg_MoneyModel[0])
   else if(
iMoney<100000)
    
engfunc(EngFunc_SetModeliEntg_MoneyModel[1])
   else
    
engfunc(EngFunc_SetModeliEntg_MoneyModel[2])
   new 
Float:mina[3]
   
mina[0]=-10.0
   mina
[1]=-10.0
   mina
[2]=-2.0
   
new Float:maxa[3]
   
maxa[0]=10.0
   maxa
[1]=10.0
   maxa
[2]=2.0
   engfunc
(EngFunc_SetSizeiEntminamaxa)
   new 
iName[32], iMessage[128]
   
get_user_name(iVictimiName31)
   
format(iMessage127"%L"LANG_SERVER"PLAYER_DROP_MONEY"iNameiDropedMoney)
   
color_saytext(iMessageMSG_ALLiVictim)
  }
 }
 return 
PLUGIN_CONTINUE
}
stock color_saytext(message[], destid 0color_by_team )
{
 if((
dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE ) && !id )
  return 
0
 
new pList[32], pNumicolor
 
if ( color_by_team )//by current definiens, affirm MSG_ALL
 
{
  
get_players(pListpNum)
  for ( 
i=0i<pNumi++ )
  {
   
color pList[i]
   
message_begin(MSG_ONEget_user_msgid("SayText"), {0,0,0}, color)
   
write_byte(color)
   
write_string(message)
   
message_end()
  }
  return 
1
 
}
 if ( 
color_by_team && color_by_team )//if use te or ct's team-color
 
{
  new 
param
  get_players
(pListpNum)
  for ( 
i=0i<pNumi++ )
  {
   
param pList[i]
   if ( 
get_user_team(param) == color_by_team )
   {
    
color param
    
break
   }
  }
 }
 if ( !
color )//if cannot find any player by team or not const id, use gray color
 
color = (color_by_team == || !id )?33:id
 message_begin
(destget_user_msgid("SayText"), {0,0,0}, (dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE)?id0)
 
write_byte(color)
 
write_string(message)
 return 
message_end()
}
/*Stocks*/
stock fm_cs_get_user_money(client)
{
 return 
get_pdata_int(clientOFFSET_MONEYEXTRAOFFSET)
}
stock fm_cs_set_user_money(clientmoneyflash=1)
{
 
set_pdata_int(clientOFFSET_MONEYmoneyEXTRAOFFSET)
 
 static 
Money
 
if( Money || (Money get_user_msgid("Money")) )
 {
  
emessage_begin(MSG_ONE_UNRELIABLEMoney_client)
  
ewrite_long(money)
  
ewrite_byte(flash 0)
  
emessage_end()
 }
}
stock CsTeams:fm_cs_get_user_team(client, &{CsInternalModel,_}:model=CS_DONTCHANGE)
{
 
model CsInternalModel:get_pdata_int(clientOFFSET_INTERALMODELEXTRAOFFSET)
 return 
CsTeams:get_pdata_int(clientOFFSET_TEAMEXTRAOFFSET)
}
stock fm_cs_set_user_team(client, {CsTeams,_}:team, {CsInternalModel,_}:model=CS_DONTCHANGE)
{
 new 
CsTeams:oldteam fm_cs_get_user_team(client)
 if( 
oldteam != team )
 {
  switch( 
oldteam )
  {
   case 
CS_TEAM_T:
   {
    if( 
is_user_alive(client) && (pev(clientpev_weapons) & (1<<CSW_C4)) )
    {
     
engclient_cmd(client"drop""weapon_c4")
    }
   }
   case 
CS_TEAM_CT:
   {
    
fm_cs_set_user_defuse(client0)
   }
  }
 }
 
set_pdata_int(clientOFFSET_TEAM_:teamEXTRAOFFSET)
 if( 
model != CS_DONTCHANGE )
 {
  
set_pdata_int(clientOFFSET_INTERALMODEL_:modelEXTRAOFFSET)
 }
 
dllfunc(DLLFunc_ClientUserInfoChangedclientengfunc(EngFunc_GetInfoKeyBufferclient))
 static const 
team_names[CsTeams][] =
 {
  
"UNASSIGNED",
  
"TERRORIST",
  
"CT",
  
"SPECTATOR"
 
}
 static 
TeamInfo
 
if( TeamInfo || (TeamInfo get_user_msgid("TeamInfo")) )
 {
  
emessage_begin(MSG_BROADCASTTeamInfo)
  
ewrite_byte(client)
  
ewrite_string(team_names[team])
  
emessage_end()
 }

__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Reply



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:40.


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