Obsidian Conflict Forums

Have you seen my coffee cup?
It is currently Tue Dec 12, 2017 2:24 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Feb 19, 2015 12:08 pm 
Offline
Vertex
Vertex

Joined: Tue Jan 24, 2012 4:25 pm
Posts: 9
Location: Hungary
Has thanked: 0 time
Have thanks: 0 time
Hi all,

I just try to make this plugin but I stuck on custom weapons adding because they are not in the original engine and I dont know how to get them.
I' am not the original creater I just rewrote the whole plugin.

Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

#define MAX_WEAPONS      18

public Plugin:myinfo = {
   name = "Give Weapon",
   author = "ICEMAN",
   description = "Give a weapon by type the name of the weapon if you want to give it to your self miss <target>",
   version = "0.2",
   url = "http://www.sourcemod.net/"
};

new const String:g_weapons[MAX_WEAPONS][] = {
   "weapon_crowbar", "weapon_stunstick", "weapon_physcannon", "weapon_healer", "weapon_pistol", "weapon_357", "weapon_alyxgun", "weapon_smg1", "custom_oicw", "weapon_ar2", "custom_m4a1", "weapon_shotgun", "weapon_crossbow", "weapon_gauss", "weapon_sniperrifle", "weapon_frag", "weapon_slam", "weapon_rpg"
};

public OnPluginStart()
{
   RegAdminCmd("sm_give", smGive, ADMFLAG_BAN, "- <target> <weaponname>");
   RegAdminCmd("sm_weaponslist", smWeaponsList, ADMFLAG_BAN, "- list of the weapon names");
}

public Action:smGive(id, args)
{
   if(args < 2)
   {
      ReplyToCommand(id, "[SM] Usage: sm_give <name | #userid> <weaponname>");
      return Plugin_Handled;
   }
   
   decl String:sArg[256];
   decl String:sTempArg[32];
   decl String:sWeaponName[32];
   decl String:sWeaponNameTemp[32];
   decl iL;
   decl iNL;
   
   GetCmdArgString(sArg, sizeof(sArg));
   iL = BreakString(sArg, sTempArg, sizeof(sTempArg));
   
   if((iNL = BreakString(sArg[iL], sWeaponName, sizeof(sWeaponName))) != -1)
      iL += iNL;
   
   new i;
   new iValid = 0;
   
   if(StrContains(sWeaponName, "weapon_") == -1)
   {
      FormatEx(sWeaponNameTemp, 31, "weapon_");
      StrCat(sWeaponNameTemp, 31, sWeaponName);
      
      strcopy(sWeaponName, 31, sWeaponNameTemp);
   }
   
   for(i = 0; i < MAX_WEAPONS; ++i)
   {
      if(StrEqual(sWeaponName, g_weapons[i]))
      {
         iValid = 1;
         break;
      }
   }
   
   if(!iValid)
   {
      ReplyToCommand(id, "[SM] The weaponname (%s) isn't valid", sWeaponName);
      return Plugin_Handled;
   }
   
   decl String:sTargetName[MAX_TARGET_LENGTH];
   decl sTargetList[1];
   decl bool:bTN_IsML;
   
   new iTarget = -1;
   
   if(ProcessTargetString(sTempArg, id, sTargetList, 1, COMMAND_FILTER_ALIVE|COMMAND_FILTER_NO_MULTI, sTargetName, sizeof(sTargetName), bTN_IsML) > 0)
      iTarget = sTargetList[0];
   
   if(iTarget != -1 && !IsFakeClient(iTarget))
      GivePlayerItem(iTarget, sWeaponName);
   
   return Plugin_Handled;
}

public Action:smWeaponsList(id, args)
{
   new i;
   for(i = 0; i < MAX_WEAPONS; ++i)
      ReplyToCommand(id, "%s", g_weapons[i]);
   
   ReplyToCommand(id, "");
   ReplyToCommand(id, "* No need to put weapon_ in the <weaponname>");
   
   return Plugin_Handled;
}

_________________
------------------------
------000--------------
-----0----0------------
------------0-----------
--------------0---------
----------------0-------
------------------0-----
-------------------0--0-
---------------------0--


Top
 Profile  
 
PostPosted: Thu Feb 26, 2015 11:27 am 
Offline
Lead Coder
Lead Coder
User avatar

Joined: Tue Aug 15, 2006 3:39 pm
Posts: 1812
Location: Germany
Has thanked: 12 times
Have thanks: 29 times
You just need to add support for the "custom_" prefix where you can find "weapon_".
A list of all custom weapons can be obtained by searching "scripts/customweapons",
which involves a lot of restructuring on that plugin as it's pretty static code with that MAX_WEAPONS, the array and such (I'd look for "weapon_" files in the scripts folder to get the exact amount with a more dynamic approach...)

_________________
ImageImage

Image

Image

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

Protected by Anti-Spam ACP Powered by phpBB® Forum Software © phpBB Group