Raised This Month: $ Target: $400
 0% 

Removing all weapons.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 05-06-2016 , 12:35   Removing all weapons.
Reply With Quote #1

Hello, just a little problem i have. I need to strip a large amount of players and using
PHP Code:
ServerCommand("sm_disarm %s"sBuffer
would just spam the chat and I don't have the source for the command.

I cant figure out how to do it, any pointers?
Michael Shoe Maker is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 05-06-2016 , 12:44   Re: Removing all weapons.
Reply With Quote #2

smlib

EDIT: Or search - IT COST ME LIKE 30sec TO GOOGLE THAT...
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 05-06-2016 at 12:47.
KissLick is offline
Farbror Godis
AlliedModders Donor
Join Date: Feb 2016
Old 05-06-2016 , 16:30   Re: Removing all weapons.
Reply With Quote #3

Something like this:

PHP Code:
#include <sdkhooks>
#include <sdktools>

...

int weapon;
for(
int i 04i++) {
    if((
weapon GetPlayerWeaponSlot(clienti)) != -1) {
        
SDKHook_DropWeapon(clientweaponNULL_VECTORNULL_VECTOR);
        
AcceptEntityInput(weapon"Kill");
    }

You will have to adjust how many slots to iterate over depending on what game it is.
Farbror Godis is offline
Dkmuniz
Senior Member
Join Date: Jun 2013
Old 05-07-2016 , 00:29   Re: Removing all weapons.
Reply With Quote #4

PHP Code:
stock StripAllWeapons(client)
{
    new 
iEnt;
    for (new 
0<= 4i++)
    {
        while ((
iEnt GetPlayerWeaponSlot(clienti)) != -1)
        {
            
RemovePlayerItem(clientiEnt);
            
AcceptEntityInput(iEnt"Kill");
        }
    }


Last edited by Dkmuniz; 05-07-2016 at 00:29.
Dkmuniz is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-07-2016 , 02:29   Re: Removing all weapons.
Reply With Quote #5

if game is csgo, avoid using removeplayeritem function, this have halt server on round end.
@Farbor example much better
__________________
Do not Private Message @me
Bacardi is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 05-07-2016 , 06:58   Re: Removing all weapons.
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
if game is csgo, avoid using removeplayeritem function, this have halt server on round end.
@Farbor example much better
thanks, good to know
__________________
coding & free software
shanapu is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 05-07-2016 , 19:59   Re: Removing all weapons.
Reply With Quote #7

For a safer method similar to Farbor Godi's example, use the following:

PHP Code:
#include <csgoitems> 
Quote:
- Added CSGOItems_RemoveAllWeapons
This function will safely remove all the weapons a client has got equipped, with an option to skip a certain slot.

Example 1, Remove all clients weapons.
CSGOItems_RemoveAllWeapons(iClient);

Example 2, Remove all clients weapons but leave the knife slot.
CSGOItems_RemoveAllWeapons(iClient, CS_SLOT_KNIFE);

Return: Number of weapons sucessfully removed from client.
This method is crash free and will also make sure that no errors occur if you are trying to strip a weapon that does not belong to the player.

Download CSGO Items here

Last edited by SM9; 05-08-2016 at 12:39. Reason: Updated.
SM9 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-08-2016 , 02:11   Re: Removing all weapons.
Reply With Quote #8

...well depends, do people need more extensions just simply for strip weapon ?

Spoiler

Last edited by Bacardi; 05-08-2016 at 02:11.
Bacardi is offline
Farbror Godis
AlliedModders Donor
Join Date: Feb 2016
Old 05-08-2016 , 09:39   Re: Removing all weapons.
Reply With Quote #9

If the game is TF2, there's TF2_RemoveAllWeapons, so there's no need to write your own function in that case.

Last edited by Farbror Godis; 05-08-2016 at 09:39.
Farbror Godis is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 05-08-2016 , 12:40   Re: Removing all weapons.
Reply With Quote #10

Updated my example, And I have implemented your looping method Bacardi, very nice!
SM9 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 01:31.


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