Raised This Month: $32 Target: $400
 8% 

Give ammo / drop comands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maxolahird
Veteran Member
Join Date: Dec 2012
Old 10-30-2016 , 06:01   Give ammo / drop comands
Reply With Quote #1

Hi everyone, if anyone could help me do this

- sm_ammo <userid> <weapon slot> <amount of ammo>
Is it possible to make that it will only work on the weapon the person was using at the time?

- sm_drop <userid> <weapon slot>
drops player weapon depending on weapon slot

I will really appreciate if any of you help me as I have no skills in C++ to make it myself.. this is really important for my server and I can't get it done without you guys.

Thanks in advance.
maxolahird is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 06:06   Re: Give ammo / drop comands
Reply With Quote #2

Tell for wich game you need that plugin and I'll drop the code. Also, you don't need C++ to script Sourcemod plugins, but Sourcepawn wich is kinda easy to learn if you give yourself 2-3 houres.
__________________
Want to check my plugins ?
Arkarr is offline
maxolahird
Veteran Member
Join Date: Dec 2012
Old 10-30-2016 , 06:09   Re: Give ammo / drop comands
Reply With Quote #3

Quote:
Originally Posted by Arkarr View Post
Tell for wich game you need that plugin and I'll drop the code. Also, you don't need C++ to script Sourcemod plugins, but Sourcepawn wich is kinda easy to learn if you give yourself 2-3 houres.
Sorry I forgot! Its for CS:S.

I will definitely look into sourcepawn tutorials very soon.

Thanks.
maxolahird is offline
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
maxolahird
Veteran Member
Join Date: Dec 2012
Old 10-30-2016 , 06:40   Re: Give ammo / drop comands
Reply With Quote #5

Quote:
Originally Posted by Arkarr View Post
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];
    
    
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;
    }
    
    
CS_DropWeapon(clientweapontruetrue);
    
ReplyToCommand(client"%N dropped his weapon !"target);
    return 
Plugin_Handled;

I tested and this is what i found saw:
-give ammo for weapon slot 2 doesn't seem to work
- tho giving ammo to pistol works fine and it doesnt pass to other pistols just like it should do.
-drop says "more than one player corresponds to what you typed."
-And also its taking player username instead of userid, if that's not hard to change of course.

Thanks for your help and time.

Last edited by maxolahird; 10-30-2016 at 06:41.
maxolahird is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 07:18   Re: Give ammo / drop comands
Reply With Quote #6

Quote:
Originally Posted by maxolahird View Post
-give ammo for weapon slot 2 doesn't seem to work
Valid weapon slot are : 0, 1.
0 = primmary
1 = secondary
Quote:
Originally Posted by maxolahird View Post
-drop says "more than one player corresponds to what you typed."
My bad. You should put the name (or part of it) of the target. For exemple :
!drop Arkarr 1
__________________
Want to check my plugins ?
Arkarr is offline
maxolahird
Veteran Member
Join Date: Dec 2012
Old 10-30-2016 , 07:26   Re: Give ammo / drop comands
Reply With Quote #7

Quote:
Originally Posted by Arkarr View Post
Valid weapon slot are : 0, 1.
0 = primmary
1 = secondary

My bad. You should put the name (or part of it) of the target. For exemple :
!drop Arkarr 1
Oh i see, ammo is ok! But even with playername for drop it says the same message "more than 1 match found"

And is it possible to use only userid ? For example: /drop 22 ...(rest of the cvar)

-edit-

no need to do anything else, just a fix for drop and its perfect! thanks

Last edited by maxolahird; 10-30-2016 at 07:36.
maxolahird is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 07:44   Re: Give ammo / drop comands
Reply With Quote #8

Updated my code above

EDIT: It's still by name, I forgot a part of code, that's why it always gave you an error haha !
__________________
Want to check my plugins ?

Last edited by Arkarr; 10-30-2016 at 07:45.
Arkarr is offline
maxolahird
Veteran Member
Join Date: Dec 2012
Old 10-30-2016 , 08:08   Re: Give ammo / drop comands
Reply With Quote #9

Okay, it works now but it seems drop only work on myself not other players.. ammo seems to be fine related to that

Thanks
maxolahird is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 08:10   Re: Give ammo / drop comands
Reply With Quote #10

Quote:
Originally Posted by maxolahird View Post
Okay, it works now but it seems drop only work on myself not other players.. ammo seems to be fine related to that

Thanks
Yeah, that's right. 'cause I'm stupid. It's fixed now.
__________________
Want to check my plugins ?
Arkarr 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 23:28.


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