Raised This Month: $ Target: $400
 0% 

[CS:GO] GetSlotFromWeaponID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
You9
Member
Join Date: Mar 2016
Old 05-15-2016 , 12:23   [CS:GO] GetSlotFromWeaponID
Reply With Quote #1

Hey,

basically i trying to do stock what removes client all weapons expect 1 slot.
Using m_hMyWeapons but it returns WeaponIDs, but now how i get slot from WeaponID?
You9 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-15-2016 , 13:42   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #2

why not just get the weapon in the player's slot and remove it that what?
Mitchell is offline
You9
Member
Join Date: Mar 2016
Old 05-16-2016 , 08:08   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #3

Because it's not removing all granades somehow.
You9 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-16-2016 , 12:44   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #4

Do while
GetPlayerWeaponSlot > -1
__________________
Neuro Toxin is offline
You9
Member
Join Date: Mar 2016
Old 05-17-2016 , 15:32   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #5

Marked with comment line giving error logs: Plugin encountered error 30: Script execution timed out
RemoveAllWeapon(i, CS_SLOT_C4);

PHP Code:
stock RemoveAllWeapons(int clientint SkipSlot = -1

    
int wepremovedWep 0;
    for (
int i 06i++){
        if(
!= SkipSlot){
            while ((
wep GetPlayerWeaponSlot(clienti)) != -1){ 
                if(
DeleteClientWeapon(clientwep)) //ERROR LINE
                    
removedWep++;
            }
        }
    }
    return 
removedWep;

PHP Code:
stock DeleteClientWeapon(int clientint weapon)
{
    if(!
IsValidWeapon(weapon) || !IsPlayerAlive(client) || GetEntSendPropOffs(weapon"m_bStartedArming") != -1)
        return 
false;
    
    
int iOwnerEntity GetEntPropEnt(weaponProp_Send"m_hOwnerEntity");
    if (
iOwnerEntity != client)
        
SetEntPropEnt(weaponProp_Send"m_hOwnerEntity"client);
    
    
SDKHooks_DropWeapon(clientweaponNULL_VECTORNULL_VECTOR); //CS_DropWeapon(client, weapon, false, true);
    
if (iOwnerEntity != -1)
        
SetEntPropEnt(weaponProp_Send"m_hOwnerEntity"iOwnerEntity);
        
    return 
AcceptEntityInput(weapon"Kill");


Last edited by You9; 05-17-2016 at 15:33.
You9 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-17-2016 , 16:38   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #6

Because you are looping if DeleteClientWeapon returns false it will go back the the same weapon over and over creating an infinite loop. Some of these checks within DeleteClientWeapon should be in the method before, theres no need to constantly check if the player is alive or if the client owns the weapon, the weapon is in the client's slot, how would he not own it?
I'd also recommend starting the loop backwards so it starts with c4/grenades then moves to the primary.

Last edited by Mitchell; 05-17-2016 at 16:40.
Mitchell is offline
You9
Member
Join Date: Mar 2016
Old 05-17-2016 , 18:31   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #7

Thanks, working now but why backwards loop is better?

Last edited by You9; 05-17-2016 at 18:42.
You9 is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 05-17-2016 , 19:06   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #8

Quote:
Originally Posted by You9 View Post
Thanks, working now but why backwards loop is better?
I suppose because it's less likely you'd be using those slots (weapons), so when they're stripped it would be less likely to cause issues.
Maybe more to it, or different entirely.
Maxximou5 is offline
You9
Member
Join Date: Mar 2016
Old 05-18-2016 , 09:01   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #9

When i use RemoveAllWeapons(client, CS_SLOT_KNIFE); on the OnClientSpawn then some people still have AK-47's and stuff, weapons are not removed, someone know the issue?
You9 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-18-2016 , 09:20   Re: [CS:GO] GetSlotFromWeaponID
Reply With Quote #10

Quote:
Originally Posted by You9 View Post
When i use RemoveAllWeapons(client, CS_SLOT_KNIFE); on the OnClientSpawn then some people still have AK-47's and stuff, weapons are not removed, someone know the issue?
Are there any logs, also i'd recommend using RemovePlayerItem(client, weapon); instead of killing it.
Mitchell 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:35.


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