View Single Post
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen.
Old 10-30-2016 , 06:25   Re: Give ammo / drop comands
Reply With Quote #4

Not tested.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
//#include <sdkhooks>

#define PLUGIN_AUTHOR     "Arkarr"
#define PLUGIN_VERSION     "1.0"

public Plugin myinfo 
{
    
name "[CSS/CSGO] Prop cash",
    
author PLUGIN_AUTHOR,
    
description "Spawn prop wich give cash upon touch",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net"
};

public 
void OnPluginStart()
{
    
EngineVersion game GetEngineVersion();
    if(
game != Engine_CSGO && game != Engine_CSS)
        
SetFailState("This plugin is for CSGO/CSS only.");
        
    
RegConsoleCmd("sm_ammo"CMD_Ammo"Set the number of ammo of the specified weapon.");
    
RegConsoleCmd("sm_drop"CMD_Drop"Force to drop the specified weapon.");
    
    
LoadTranslations("common.phrases");
}

public 
Action CMD_Ammo(int clientint args)
{
    if(
args != 3)
    {
        
ReplyToCommand(client"Usage : sm_ammo <userid> <weapon slot> <ammo>");
        return 
Plugin_Handled;
    }
    
    
char arg1[45];
    
char arg2[45];
    
char arg3[45];
    
    
GetCmdArg(1arg1sizeof(arg1));
    
GetCmdArg(2arg2sizeof(arg2));
    
GetCmdArg(3arg3sizeof(arg3));
    
    
int target FindTarget(clientarg1);
    
    if(
target == -1)
        return 
Plugin_Handled;
    
    
int weaponSlot StringToInt(arg2);
    
int weapon GetPlayerWeaponSlot(targetweaponSlot);
    
    if(
weapon == -1)
    {
        
ReplyToCommand(client"%N doesn't have a weapon in slot %i"weaponSlot);
        return 
Plugin_Handled;
    }
    
    
int ammo StringToInt(arg3);
    
SetEntProp(weaponProp_Data"m_iClip1"ammo);
    
    
ReplyToCommand(client"%N got %i ammo for his weapon slot %i"targetammoweaponSlot);
    return 
Plugin_Handled;
}

public 
Action CMD_Drop(int clientint args)
{
    if(
args != 2)
    {
        
ReplyToCommand(client"Usage : sm_drop <userid> <weapon slot>");
        return 
Plugin_Handled;
    }
    
    
char arg1[45];
    
char arg2[45];
    
    
GetCmdArg(1arg1sizeof(arg1));
    
GetCmdArg(2arg2sizeof(arg2));
    
    
int target FindTarget(clientarg1);
    
    if(
target == -1)
        return 
Plugin_Handled;
    
    
int weaponSlot StringToInt(arg2);
    
int weapon GetPlayerWeaponSlot(targetweaponSlot);
    
    if(
weapon == -1)
    {
        
ReplyToCommand(client"%N doesn't have a weapon in slot %i"targetweaponSlot);
        return 
Plugin_Handled;
    }
    
    
CS_DropWeapon(targetweapontruetrue);
    
ReplyToCommand(client"%N dropped his weapon !"target);
    return 
Plugin_Handled;

__________________
Want to check my plugins ?

Last edited by Arkarr; 10-30-2016 at 08:10.
Arkarr is offline