AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   !drop weapons (https://forums.alliedmods.net/showthread.php?t=305092)

Obyboby 02-06-2018 14:10

!drop weapons
 
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!

Papero 02-08-2018 16:40

Re: !drop weapons
 
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;



SZOKOZ 02-09-2018 06:14

Re: !drop weapons
 
When I want to drop a gun to a friend, I just press G.:wink:
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.

Obyboby 02-09-2018 13:29

Re: !drop weapons
 
Quote:

Originally Posted by SZOKOZ (Post 2577230)
When I want to drop a gun to a friend, I just press G.:wink:
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:

https://i.imgur.com/4rbQy6W.png
Why is it saying "ak47" two more times after I trigger the command? :D


All times are GMT -4. The time now is 23:32.

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