Raised This Month: $51 Target: $400
 12% 

Change VIP on as_ maps


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 07-23-2015 , 13:54   Change VIP on as_ maps
Reply With Quote #1

How to change vip on map on another player? With cs_set_user_vip(id, 0, 1, 1) old player anyway stay as vip.

From cstrike.inc

Quote:
* It does not alter game play; the one being VIP at start of round will retain internal status as VIP; terrorists
* can terminate him and accomplish their objective, etc.
FromTheFuture is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 07-23-2015 , 14:20   Re: Change VIP on as_ maps
Reply With Quote #2

Hum, if setting 0 in one and 1 in another won't work as you want, than you should block as_ objectives, taking of vip and choose one as you want and then hardcode the objectives. Wouldn't be hard anyway, just seems to be a little bit poor way.
__________________
Jhob94 is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 07-23-2015 , 14:39   Re: Change VIP on as_ maps
Reply With Quote #3

I dont know how engine detect vip player if vip_flag is not change old player on new.

PHP Code:
set_pdata_int(idOFFSET_VIPget_pdata_int(idOFFSET_VIP) & ~PLAYER_IS_VIP
FromTheFuture is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-24-2015 , 11:45   Re: Change VIP on as_ maps
Reply With Quote #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(CHalfLifeMultiplayResetVIPg_pGameRules)
    
OrpheuCall(CBasePlayerMakeVipid)
    
    
message_begin(MSG_ALLgmsgScoreAttrib)
    {
        
write_byte(id)
        
write_byte(<< 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(entcharbased_offsetbool:valueintbase_linuxdiff 5

    
set_pdata_char(entcharbased_offset_:valueintbase_linuxdiff
}
stock set_pdata_char(entcharbased_offsetvalueintbase_linuxdiff 5

    
value &= 0xFF 
    
new int_offset_value get_pdata_int(entcharbased_offset INT_BYTESintbase_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
(entcharbased_offset INT_BYTESint_offset_valueintbase_linuxdiff
    return 



#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(
<= CurrentVip <= MaxPlayers)
    {
        
set_pdata_bool(CurrentVipm_bIsVipfalse)
        
set_pdata_bool(CurrentVipm_bNotKilledfalse)
        
        
SendScoreAttribMessage(CurrentVip0)
        
        
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(03)
        
set_pdata_int(CurrentVipm_iModelNameModels[RandomModel][ModelIndex], XoPlayer)
        
engfunc(EngFunc_SetClientKeyValueCurrentVipengfunc(EngFunc_GetInfoKeyBufferCurrentVip), "model"Models[RandomModel][ModelName])
        
        if(
<= NewVip <= MaxPlayers)
        {
            
OrpheuMemorySetAtAddress(HandlepGameRules"m_pVIP"1NewVip)
            
OrpheuMemorySetAtAddress(HandlepGameRules"m_iConsecutiveVIP"11)
            
            
SendScoreAttribMessage(NewVip, (<< 2))
            
set_pdata_bool(NewVipm_bIsViptrue)
            
set_pdata_bool(NewVipm_bNotKilledfalse)
            
            
set_pev(NewVippev_body0)
            
set_pdata_int(NewVipm_iModelNameMODEL_VIPXoPlayer)
            
set_pdata_int(NewVipm_iTeam2)
            
            
engfunc(EngFunc_SetClientKeyValueNewVipengfunc(EngFunc_GetInfoKeyBufferNewVip), "model""vip")
        }
    }
}

stock SendScoreAttribMessage(idFlag)
{
    
message_begin(MSG_ALLgmsgScoreAttrib_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.
HamletEagle is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 07-30-2015 , 18:31   Re: Change VIP on as_ maps
Reply With Quote #5

Thank u for helping! : ) I will try it in some future.
FromTheFuture is offline
MAJESTIC_SZ
Senior Member
Join Date: Mar 2020
Location: Portugal
Old 06-07-2021 , 18:44   Re: Change VIP on as_ maps
Reply With Quote #6

Hello!
Sorry for wakening this but, any news about this ?
And is there any solution for this to work with REHLDS ?
MAJESTIC_SZ is offline
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 16:04.


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