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

!drop weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obyboby
Veteran Member
Join Date: Sep 2013
Old 02-06-2018 , 14:10   !drop weapons
Reply With Quote #1

I would like a plugin where I can type !drop followed by the name of a weapon, perhaps including grenades.
If I have enough money to purchase such item, it will be dropped for my teammates (on the ground).
Example:

!drop ak47

-2700 on my balance and an ak is dropped on the ground.
Perhaps add support for credits or rankme points when a player drops guns, to incentivate helping team mates
this can also prevent situations where u might want to drop weapons, but u would have to drop your own one for example, and some ppl might run and steal it before u can pick it up again
Thanks!
__________________

Last edited by Obyboby; 02-06-2018 at 14:15.
Obyboby is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 02-08-2018 , 16:40   Re: !drop weapons
Reply With Quote #2

Not tested, neither I've ever used the CS_* functions...
Tested and here it's working
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_NAME           "DropWeapon"
#define PLUGIN_VERSION        "1.0"

public Plugin myinfo =
{
    
name PLUGIN_NAME,
    
author "Hexah",
    
description "",
    
version PLUGIN_VERSION,
    
url "csitajb.it"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_drop"Cmd_Drop);
}

public 
Action Cmd_Drop(int clientint args)
{
    if (!
IsPlayerAlive(client))
    {
        
ReplyToCommand(client"[SM] You can't this command now!");
    }
    
char sAlias[64];
    
GetCmdArg(1sAliassizeof(sAlias));
    
    
PrintToChatAll(sAlias);
    
    
CSWeaponID weapon GetWeaponID(sAlias);
    
PrintToChatAll(sAlias);
    
    if (!
CS_IsValidWeaponID(weapon))
    {
        
ReplyToCommand(client"[SM] Invalid weapon");
        return 
Plugin_Handled;
    }
    
    
int price CS_GetWeaponPrice(clientweapon);
    
int money GetEntProp(clientProp_Send"m_iAccount");
    
    if (
price money)
    {
        
ReplyToCommand(client"[SM] You haven't got enought money!");
        return 
Plugin_Handled;
    }
    
    
Format(sAliassizeof(sAlias), "weapon_%s"sAlias);
    
int ent CreateEntityByName(sAlias);
    
    if (
ent == -1)
    {
        
ReplyToCommand(client,  "[SM] An error occured, try again");
        return 
Plugin_Handled;
    }
    
float vPos[3];
    
float vAng[3];
    
float vFinal[3];
    
GetClientEyePosition(clientvPos);
    
GetClientEyeAngles(clientvAng);
    
TR_TraceRayFilter(vPosvAngMASK_SOLIDRayType_InfiniteTrace_DontHitSelfclient);
    
    if (
TR_DidHit())
    {
        
TR_GetEndPosition(vFinal);
        
vFinal[2] += 10.0;
    }
    else
    {
        for (
int i 0<= sizeof(vPos); i++)
            
vFinal[i] = vPos[i];
    }
    
    
TeleportEntity(entvFinalNULL_VECTORNULL_VECTOR);

    
DispatchSpawn(ent);
    
SetEntProp(clientProp_Send"m_iAccount"money price);
    return 
Plugin_Handled;
}

CSWeaponID GetWeaponID(const char[] sAlias)
{
    
char sWeapon[64];
    
CS_GetTranslatedWeaponAlias(sAliassWeaponsizeof(sWeapon));
    return 
CS_AliasToWeaponID(sWeapon);
}  

public 
bool Trace_DontHitSelf(int entityint contentsMaskany client)
{
    return 
entity != client;

__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 02-10-2018 at 13:34. Reason: Update plugin
Papero is offline
SZOKOZ
Member
Join Date: Jan 2014
Old 02-09-2018 , 06:14   Re: !drop weapons
Reply With Quote #3

When I want to drop a gun to a friend, I just press G.
The grenade and kevlar are things you can't drop willingly though so I could entertain this idea. I'll get back to you on this.
__________________
May still be available for SM scripting. Just look at my Steam profile regarding my availability.
My Steam
SZOKOZ is offline
Obyboby
Veteran Member
Join Date: Sep 2013
Old 02-09-2018 , 13:29   Re: !drop weapons
Reply With Quote #4

Quote:
Originally Posted by SZOKOZ View Post
When I want to drop a gun to a friend, I just press G.
The grenade and kevlar are things you can't drop willingly though so I could entertain this idea. I'll get back to you on this.
Dropping with G won't get u a reward. I'm trying to achieve this because most players (at least on my server, sadly) are selfish cunts who might keep 10000+ at the last round when some of their teammates could really use a drop.
So..yeah, here's why the idea.
And thanks for your interest, looking forward to seeing some updates

EDIT: does the current code from Papero give a reward to whoever drops? We could make it so that the weapon will be discounted to whoever drops. Like 25% off the regular price. Unless it's easy af to implement a rankme reward for players who drop..

EDIT2:


Why is it saying "ak47" two more times after I trigger the command?
__________________

Last edited by Obyboby; 02-11-2018 at 10:26.
Obyboby is offline
Reply


Thread Tools
Display Modes

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 11:12.


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