Re: pev(_index, _value, any:...) function
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_least, cvar_drop_count, cvar_drop, cvar_pick_level, cvar_delay_time, cvar_round, cvar_drop_min, cvar_drop_money, cvar_can_not_pick_up new g_MaxPlayers, g_DropCount, g_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 iClip, iAmmo, iWeapon = get_user_weapon(id, iClip, iAmmo) 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(iMessage, 127, "%L", LANG_PLAYER, "NOT_ENOUGH_MONEY", get_pcvar_num(cvar_drop_at_least)) color_saytext(iMessage, MSG_ALL, id, 3) client_cmd(id, "spk %s", g_Sounds[1]) return PLUGIN_HANDLED } if (g_DropCount > get_pcvar_num(cvar_drop_count)) { new iMessage[128] format(iMessage, 127, "%L", LANG_PLAYER, "ENOUGH_MONEY_COUNT") color_saytext(iMessage, MSG_ALL, id, 3) return PLUGIN_HANDLED } g_DropCount++ fm_cs_set_user_money(id, iMoney-iDropMoney, 1) new Float:fOrigin[3], Float:fVelo[3], Float:fUserVeloCity[3] pev(id, pev_origin, fOrigin) pev(id, pev_velocity, fUserVeloCity) velocity_by_aim(id, 450, fVelo) fVelo[0] += fUserVeloCity[0] fVelo[1] += fUserVeloCity[1] fVelo[2] = 0.0 fVelo[0] += random_float(-100.0, 100.0) fVelo[1] += random_float(-100.0, 100.0) new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target")) set_pev(iEnt, pev_classname, "Money_drop") engfunc(EngFunc_SetModel, iEnt, g_MoneyModel[0]) set_pev(iEnt, pev_origin, fOrigin) set_pev(iEnt, pev_solid, SOLID_TRIGGER) set_pev(iEnt, pev_movetype, MOVETYPE_TOSS) set_pev(iEnt, pev_velocity, fVelo) set_pev(iEnt, pev_owner, id) set_pev(iEnt, pev_iuser1, g_Round) set_pev(iEnt, pev_iuser2, iDropMoney) set_pev(iEnt, pev_fuser1, get_gametime()) set_pev(iEnt, pev_team, fm_cs_get_user_team(id)) if (fm_cs_get_user_team(id) == CS_TEAM_CT) { fm_set_rendering(iEnt, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 15) } else if(fm_cs_get_user_team(id) == CS_TEAM_T){ fm_set_rendering(iEnt, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 15) } 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_SetSize, iEnt, mina, maxa) 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(iEnt, id) { new iMoney = fm_cs_get_user_money(id) new iOwner = pev(iEnt, pev_owner) new iMoneyTouch = pev(iEnt, pev_iuser2) new Float:iTime = pev(iEnt, pev_fuser1) new iEntTeam = pev(iEnt, pev_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(id, iMoney+iMoneyTouch, 1) engfunc(EngFunc_RemoveEntity, iEnt) g_DropCount-- new iName[32], iMessage[128] get_user_name(id, iName, 31) format(iMessage, 127, "%L", LANG_SERVER, "PLAYER_PICK_UP_MONEY", iName, iMoneyTouch) color_saytext(iMessage, MSG_ALL, id) 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(iMessage, 127, "%L", LANG_SERVER, "CANT_PICK_UP_MONEY", get_pcvar_num(cvar_pick_level)) color_saytext(iMessage, MSG_ALL, _, 3) color_saytext(iMessage, MSG_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(iMessage1, 127, "%L", LANG_SERVER, "NOTICE_ONE", get_pcvar_num(cvar_drop), get_pcvar_num(cvar_drop_at_least)) format(iMessage2, 127, "%L", LANG_SERVER, "NOTICE_TWO") format(iMessage3, 127, "%L", LANG_SERVER, "NOTICE_THREE") color_saytext(iMessage1, MSG_ALL, _, 1) color_saytext(iMessage2, MSG_ALL, _, 4) color_saytext(iMessage3, MSG_ALL, _, 4) } public event_NewRound() { g_Round++ for (new id = 1; id < g_MaxPlayers; id++) iCantPickUp[id] = true new iEnt = -1 while ((iEnt = fm_find_ent_by_class(iEnt, "Money_drop")) != 0) { if (g_Round - pev(iEnt, pev_iuser1) > get_pcvar_num(cvar_round) || g_Round == get_pcvar_num(cvar_round)) { engfunc(EngFunc_RemoveEntity, iEnt) 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_min, 1000) } if(ori_ammount>=iMinDropMoney) { new iDropMoney = get_pcvar_num(cvar_drop_money) if(iDropMoney < iMinDropMoney+1000) { iDropMoney = iMinDropMoney set_pcvar_num(cvar_drop_money, iDropMoney) } iDropControl = random_num(0, iDropMoney) if(ori_ammount >= iDropControl) return random_num(3,7)*random_num(4,8)*random_num(5,10) else return 0 } 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(iVictim, iVictimMoney-iDropedMoney, 1) new Float:fVictimCoord[3] pev(iVictim, pev_origin, fVictimCoord) g_DropCount++ new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target")) set_pev(iEnt, pev_classname, "Money_drop") set_pev(iEnt, pev_origin, fVictimCoord) set_pev(iEnt, pev_solid, SOLID_TRIGGER) set_pev(iEnt, pev_movetype, MOVETYPE_TOSS) set_pev(iEnt, pev_fuser1, get_gametime()) set_pev(iEnt, pev_iuser1, g_Round) set_pev(iEnt, pev_iuser2, iMoney) set_pev(iEnt, pev_owner, iVictim) if(iMoney<10000) engfunc(EngFunc_SetModel, iEnt, g_MoneyModel[0]) else if(iMoney<100000) engfunc(EngFunc_SetModel, iEnt, g_MoneyModel[1]) else engfunc(EngFunc_SetModel, iEnt, g_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_SetSize, iEnt, mina, maxa) new iName[32], iMessage[128] get_user_name(iVictim, iName, 31) format(iMessage, 127, "%L", LANG_SERVER, "PLAYER_DROP_MONEY", iName, iDropedMoney) color_saytext(iMessage, MSG_ALL, iVictim) } } return PLUGIN_CONTINUE } stock color_saytext(message[], dest, id = 0, color_by_team = 0 ) { if((dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE ) && !id ) return 0 new pList[32], pNum, i, color if ( color_by_team > 3 )//by current definiens, affirm MSG_ALL { get_players(pList, pNum) for ( i=0; i<pNum; i++ ) { color = pList[i] message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, color) write_byte(color) write_string(message) message_end() } return 1 } if ( color_by_team && color_by_team < 3 )//if use te or ct's team-color { new param get_players(pList, pNum) for ( i=0; i<pNum; i++ ) { 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 == 3 || !id )?33:id message_begin(dest, get_user_msgid("SayText"), {0,0,0}, (dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE)?id: 0) write_byte(color) write_string(message) return message_end() } /*Stocks*/ stock fm_cs_get_user_money(client) { return get_pdata_int(client, OFFSET_MONEY, EXTRAOFFSET) } stock fm_cs_set_user_money(client, money, flash=1) { set_pdata_int(client, OFFSET_MONEY, money, EXTRAOFFSET) static Money if( Money || (Money = get_user_msgid("Money")) ) { emessage_begin(MSG_ONE_UNRELIABLE, Money, _, client) ewrite_long(money) ewrite_byte(flash ? 1 : 0) emessage_end() } } stock CsTeams:fm_cs_get_user_team(client, &{CsInternalModel,_}:model=CS_DONTCHANGE) { model = CsInternalModel:get_pdata_int(client, OFFSET_INTERALMODEL, EXTRAOFFSET) return CsTeams:get_pdata_int(client, OFFSET_TEAM, EXTRAOFFSET) } 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(client, pev_weapons) & (1<<CSW_C4)) ) { engclient_cmd(client, "drop", "weapon_c4") } } case CS_TEAM_CT: { fm_cs_set_user_defuse(client, 0) } } } set_pdata_int(client, OFFSET_TEAM, _:team, EXTRAOFFSET) if( model != CS_DONTCHANGE ) { set_pdata_int(client, OFFSET_INTERALMODEL, _:model, EXTRAOFFSET) } dllfunc(DLLFunc_ClientUserInfoChanged, client, engfunc(EngFunc_GetInfoKeyBuffer, client)) static const team_names[CsTeams][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" } static TeamInfo if( TeamInfo || (TeamInfo = get_user_msgid("TeamInfo")) ) { emessage_begin(MSG_BROADCAST, TeamInfo) ewrite_byte(client) ewrite_string(team_names[team]) emessage_end() } }
|