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

[Reapi] Hook player spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
2t_rider
Junior Member
Join Date: Dec 2018
Location: Hungary
Old 03-11-2021 , 05:33   [Reapi] Hook player spawn
Reply With Quote #1

Hello!

I write a weapon menu with reapi.

PHP Code:
RegisterHookChain(RG_CBasePlayer_Spawn"RG_Spawn_Post"true); 
PHP Code:
public RG_Spawn_Post(id){
    if(
is_user_alive(id)){
        
set_bit(g_bitAliveid); 
        
g_iPlayerTeam[id] = get_user_team(id); 
        
g_iPlayerCount[g_iPlayerTeam[id]]++  
        if(
g_bOpenWeaponmenu[id]&&!get_member(idm_bIsVIP)&&!get_bit(g_bitFake,id)){
            
openWeaponmenu(id)
            
set_task(g_flFreezeTime,"grenade",id+GRENTASKID)
        }
    } 

The problem is:

The weapon menu open only when the player was dead, so if i was the killer, and i was alive, in the next round the menu dont open, but if i was dead then will open.

Whats the solution?

I want to use Reapi anyway, because since i use reapi in plugins, they are very fast, and have small CPU usage.
2t_rider is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-11-2021 , 11:48   Re: [Reapi] Hook player spawn
Reply With Quote #2

It depends on when g_bOpenWeaponmenu[id] becomes true for user id.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
2t_rider
Junior Member
Join Date: Dec 2018
Location: Hungary
Old 03-12-2021 , 03:56   Re: [Reapi] Hook player spawn
Reply With Quote #3

Yes, depends on g_bOpenWeaponmenu on player id.

But this variable didnt change in the round, only on connect or disconnect or say /gunoff.

But i said i tested in many rounds, and sometimes didnt open, but the variable didnt change.

PHP Code:
public client_putinserver(id){
    
set_bit(g_bitConnectedid)
    
g_bOpenWeaponmenu[id]=true
    
if(is_user_bot(id) ||is_user_hltv(id))
        
set_bit(g_bitFakeid)
    else 
set_task(0.2,"loadvault",id)

    
}

public 
loadvault(id){
    new 
szAuthid[33], szData[3];
    
get_user_authididszAuthidcharsmax(szAuthid));
    
nvault_get(g_nVaultszAuthidszData2);
    
    if(
str_to_num(szData)==1)
        
g_bOpenWeaponmenu[id]=false
    
else
        
g_bOpenWeaponmenu[id]=true
}

public 
client_disconnect(id){
    if(!
get_bit(g_bitFake,id))
        
savevault(id)
    
clr_bit(g_bitAliveid);
    
clr_bit(g_bitConnectedid);
    
g_iPlayerTeam[id]=0
    has_awp
[id]=false
    g_bOpenWeaponmenu
[id]=true


public 
savevault(id){
    new 
szAuthid33 ], szData];
    
get_user_authididszAuthidcharsmax(szAuthid));
    if(
g_bOpenWeaponmenu[id])
        
num_to_str(0szData,2)
    else
        
num_to_str(1szData,2)
    
nvault_set(g_nVaultszAuthidszData)

maybe i do it wrong?
2t_rider is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-12-2021 , 05:24   Re: [Reapi] Hook player spawn
Reply With Quote #4

show the full code otherwise you won't get a proper help.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 03-12-2021, 07:03
2t_rider
This message has been deleted by 2t_rider.
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 08:46.


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