This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

RemovePlayerItem or RemoveAllWeapons crash server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jugule
AlliedModders Donor
Join Date: Apr 2020
Old 05-09-2020 , 14:44   RemovePlayerItem or RemoveAllWeapons crash server
Reply With Quote #1

If I use this function, my server crashes when it runs.

full code

PHP Code:

void RemoveAllWeapons
(int client)
{
    if(
IsValidClient(client))
    {
        
int weapon;
        for(
int i 05i++) 
        { 
            while((
weapon GetPlayerWeaponSlot(clienti)) != -1
            {
                
RemovePlayerItem(clientweapon);
                
AcceptEntityInput(weapon"Kill"); 
            } 
        }
    }

jugule is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 05-09-2020 , 16:51   Re: RemovePlayerItem or RemoveAllWeapons crash server
Reply With Quote #2

Quote:
Originally Posted by jugule View Post
If I use this function, my server crashes when it runs.

full code

PHP Code:

void RemoveAllWeapons
(int client)
{
    if(
IsValidClient(client))
    {
        
int weapon;
        for(
int i 05i++) 
        { 
            while((
weapon GetPlayerWeaponSlot(clienti)) != -1
            {
                
RemovePlayerItem(clientweapon);
                
AcceptEntityInput(weapon"Kill"); 
            } 
        }
    }

https://github.com/bcserv/smlib/tree...itional_syntax

In Clients.inc there's a function for removing all weapons safely.

Last edited by Weetabix; 05-09-2020 at 16:52.
Weetabix is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 05-09-2020 , 17:03   Re: RemovePlayerItem or RemoveAllWeapons crash server
Reply With Quote #3

PHP Code:

void RemovePlayerWeapons
(int client)
{   
    
int length GetEntPropArraySize(clientProp_Send"m_hMyWeapons");
    for (
int i 0lengthi++) 
    {
        
int weapon GetEntPropEnt(clientProp_Send"m_hMyWeapons"i); 
        if (
weapon != -1)
        {
            
RemovePlayerItem(clientweapon);
            
AcceptEntityInput(weapon"KillHierarchy");
        }
    }
    
    
SetEntPropEnt(clientProp_Send"m_hActiveWeapon", -1);

__________________
Ilusion9 is offline
jugule
AlliedModders Donor
Join Date: Apr 2020
Old 05-10-2020 , 08:42   Re: RemovePlayerItem or RemoveAllWeapons crash server
Reply With Quote #4

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:

void RemovePlayerWeapons
(int client)
{   
    
int length GetEntPropArraySize(clientProp_Send"m_hMyWeapons");
    for (
int i 0lengthi++) 
    {
        
int weapon GetEntPropEnt(clientProp_Send"m_hMyWeapons"i); 
        if (
weapon != -1)
        {
            
RemovePlayerItem(clientweapon);
            
AcceptEntityInput(weapon"KillHierarchy");
        }
    }
    
    
SetEntPropEnt(clientProp_Send"m_hActiveWeapon", -1);

Thanks!

Last edited by jugule; 05-10-2020 at 14:36.
jugule 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 15:27.


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