AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
|
07-24-2015
, 11:45
Re: Change VIP on as_ maps
|
#4
|
In order to get next vip game use a function called CHalfLifeMultiplay:: PickNextVIP. It calls CHalfLifeMultiplay::ResetCurrentVIP which remove the old vip and CBasePlayer::MakeVip which is the function that actually make someone "vip".
So, all you have to do is to call CHalfLifeMultiplay::ResetCurrentVIP and CBasePlayer::MakeVip
PHP Code:
#include <amxmodx> #include <orpheu>
new g_pGameRules new gmsgScoreAttrib
new OrpheuFunction:CHalfLifeMultiplayResetVIP new OrpheuFunction:CBasePlayerMakeVip
public plugin_precache() { OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"), "OnInstallGameRules", OrpheuHookPost) }
public OrpheuHookReturn:OnInstallGameRules() { g_pGameRules = OrpheuGetReturn() }
public plugin_init() { CHalfLifeMultiplayResetVIP = OrpheuGetFunction("ResetCurrentVIP", "CHalfLifeMultiplay") CBasePlayerMakeVip = OrpheuGetFunction("MakeVip", "CBasePlayer") gmsgScoreAttrib = get_user_msgid( "ScoreAttrib" ) register_clcmd("test", "test") }
public test(id) { OrpheuCall(CHalfLifeMultiplayResetVIP, g_pGameRules) OrpheuCall(CBasePlayerMakeVip, id) message_begin(MSG_ALL, gmsgScoreAttrib) { write_byte(id) write_byte(1 << 2) message_end() }
}
Look at this test plugin. Call RemoveVIP to remove the old one and MakeVip with the new vip index to give someone else vip.
Code:
{
"name" : "InstallGameRules",
"library" : "mod",
"return" :
{
"type" : "CGameRules *"
},
"identifiers":
[
{
"os" : "windows",
"mod" : "cstrike",
"value" : [0x68,"*","*","*","*",0xFF,"*","*","*","*","*",0x83,"*","*",0xFF,"*","*","*","*","*",0xA1,"*","*","*","*",0xD9,"*","*",0xD8,"*","*","*","*","*",0xDF]
},
{
"os" : "linux",
"mod" : "cstrike",
"value" : "_Z16InstallGameRulesv"
}
]
}
Signatures here: https://forums.alliedmods.net/showpo...6&postcount=35
I don't know why, but yesterday calling ResetVIP resulted in a crash, maybe because I was too tired. So, I rewrote the two functions and I think I'll post them too, maybe someone could use them as reference or idk. And yes, some parts could be done with cs_set_user_vip, but I wanted to fully redo it.
PHP Code:
#include <amxmodx> #include <orpheu> #include <orpheu_memory> #include <fakemeta>
#if AMXX_VERSION_NUM < 183
#define INT_BYTES 4 #define BYTE_BITS 8
stock set_pdata_bool(ent, charbased_offset, bool:value, intbase_linuxdiff = 5) { set_pdata_char(ent, charbased_offset, _:value, intbase_linuxdiff) } stock set_pdata_char(ent, charbased_offset, value, intbase_linuxdiff = 5) { value &= 0xFF new int_offset_value = get_pdata_int(ent, charbased_offset / INT_BYTES, intbase_linuxdiff) new bit_decal = (charbased_offset % INT_BYTES) * BYTE_BITS int_offset_value &= ~(0xFF<<bit_decal) // clear byte int_offset_value |= value<<bit_decal set_pdata_int(ent, charbased_offset / INT_BYTES, int_offset_value, intbase_linuxdiff) return 1 }
#endif
new gmsgScoreAttrib new HandlepGameRules new MaxPlayers
public plugin_precache() { OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"), "OnInstallGameRules", OrpheuHookPost) } public OnInstallGameRules() { HandlepGameRules = OrpheuGetReturn() }
public plugin_init() { gmsgScoreAttrib = get_user_msgid( "ScoreAttrib" ) MaxPlayers = get_maxplayers() }
stock ResetCurrentVIP(const NewVip) { const m_bIsVip = 837 const m_bNotKilled = 452 const m_iModelName = 126 const m_iTeam = 114 const XoPlayer = 5 new CurrentVip = OrpheuMemoryGetAtAddress(HandlepGameRules, "m_pVIP") if(1 <= CurrentVip <= MaxPlayers) { set_pdata_bool(CurrentVip, m_bIsVip, false) set_pdata_bool(CurrentVip, m_bNotKilled, false) SendScoreAttribMessage(CurrentVip, 0) enum { MODEL_UNASSIGNED = 0, MODEL_URBAN, MODEL_TERROR, MODEL_LEET, MODEL_ARCTIC, MODEL_GSG9, MODEL_GIGN, MODEL_SAS, MODEL_GUERILLA, MODEL_VIP, MODEL_MILITIA, MODEL_SPETSNAZ } #pragma unused MODEL_MILITIA #pragma unused MODEL_GUERILLA #pragma unused MODEL_ARCTIC #pragma unused MODEL_LEET #pragma unused MODEL_TERROR #pragma unused MODEL_UNASSIGNED #pragma unused MODEL_SPETSNAZ enum ModelData { ModelIndex, ModelName[10] } new const Models[][ModelData] = { {MODEL_URBAN, "gsg9" }, {MODEL_GSG9 , "sas" }, {MODEL_SAS , "gign" }, {MODEL_GIGN , "urban" } } new RandomModel = random_num(0, 3) set_pdata_int(CurrentVip, m_iModelName, Models[RandomModel][ModelIndex], XoPlayer) engfunc(EngFunc_SetClientKeyValue, CurrentVip, engfunc(EngFunc_GetInfoKeyBuffer, CurrentVip), "model", Models[RandomModel][ModelName]) if(1 <= NewVip <= MaxPlayers) { OrpheuMemorySetAtAddress(HandlepGameRules, "m_pVIP", 1, NewVip) OrpheuMemorySetAtAddress(HandlepGameRules, "m_iConsecutiveVIP", 1, 1) SendScoreAttribMessage(NewVip, (1 << 2)) set_pdata_bool(NewVip, m_bIsVip, true) set_pdata_bool(NewVip, m_bNotKilled, false) set_pev(NewVip, pev_body, 0) set_pdata_int(NewVip, m_iModelName, MODEL_VIP, XoPlayer) set_pdata_int(NewVip, m_iTeam, 2) engfunc(EngFunc_SetClientKeyValue, NewVip, engfunc(EngFunc_GetInfoKeyBuffer, NewVip), "model", "vip") } } }
stock SendScoreAttribMessage(id, Flag) { message_begin(MSG_ALL, gmsgScoreAttrib, _, id) { write_byte(id) write_byte(Flag) message_end() } }
Offets for code above
Code:
[
{
"name" : "m_iConsecutiveVIP",
"type" : "int",
"memoryType" : "data",
"identifiers" :
[
{
"os" : "windows",
"mod" : "cstrike",
"value" : 192
},
{
"os" : "linux",
"mod" : "cstrike",
"value" : 184
}
]
},
{
"name" : "m_pVIP",
"type" : "CBaseEntity *",
"memoryType" : "data",
"identifiers" :
[
{
"os" : "windows",
"mod" : "cstrike",
"value" : 652
},
{
"os" : "linux",
"mod" : "cstrike",
"value" : 644
}
]
}
]
__________________
Last edited by HamletEagle; 08-01-2015 at 09:39.
|
|