Raised This Month: $ Target: $400
 0% 

DoDs ammo ammount and weapon control


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lis
Member
Join Date: Jul 2008
Old 07-16-2008 , 10:22   DoDs ammo ammount and weapon control
Reply With Quote #1

Hi everyone.
I took <eVa>Dog dod pistol source and modified it. Now you can set the ammo for every weapon. However, if i want to give the mg gunner grenades i get a errormessage "Unknow entity weapon_frag". I searched the valve developer community for the entity names but it looks like they are wrong. Can someone help me here?

Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.1.01"
new Handle:g_Cvar_k98AmmoGer = INVALID_HANDLE
new Handle:g_Cvar_garandAmmoUS = INVALID_HANDLE
//new Handle:g_Cvar_rifleGer = INVALID_HANDLE
//new Handle:g_Cvar_rifleUS = INVALID_HANDLE
new Handle:g_Cvar_mp40AmmoGer = INVALID_HANDLE
new Handle:g_Cvar_thompsonAmmoUS = INVALID_HANDLE
//new Handle:g_Cvar_assaultGer = INVALID_HANDLE
//new Handle:g_Cvar_assaultUS = INVALID_HANDLE
new Handle:g_Cvar_k98sAmmoGer = INVALID_HANDLE
new Handle:g_Cvar_springAmmoUS = INVALID_HANDLE
//new Handle:g_Cvar_sniperGer = INVALID_HANDLE
//new Handle:g_Cvar_sniperUS = INVALID_HANDLE
new Handle:g_Cvar_stg44AmmoGer = INVALID_HANDLE
new Handle:g_Cvar_barAmmoUS = INVALID_HANDLE
//new Handle:g_Cvar_supportGer = INVALID_HANDLE
//new Handle:g_Cvar_supportUS = INVALID_HANDLE
new Handle:g_Cvar_mg42AmmoGer = INVALID_HANDLE
new Handle:g_Cvar_30calAmmoUS = INVALID_HANDLE
//new Handle:g_Cvar_mgGer = INVALID_HANDLE
//new Handle:g_Cvar_mgUS = INVALID_HANDLE
new Handle:g_Cvar_pschreckAmmoGer = INVALID_HANDLE
new Handle:g_Cvar_bazookaAmmoUS = INVALID_HANDLE
//new Handle:g_Cvar_rocketGer = INVALID_HANDLE
//new Handle:g_Cvar_rocketUS = INVALID_HANDLE
new Handle:g_Cvar_p38AmmoGer = INVALID_HANDLE
new Handle:g_Cvar_coltAmmoUS = INVALID_HANDLE
new Handle:g_Cvar_c96AmmoGer = INVALID_HANDLE
new Handle:g_Cvar_m1carbAmmoUS = INVALID_HANDLE
new Handle:g_Cvar_stickGer = INVALID_HANDLE
new Handle:g_Cvar_fragUS = INVALID_HANDLE
new Handle:g_Cvar_smokegerGer = INVALID_HANDLE
new Handle:g_Cvar_smokeusUS = INVALID_HANDLE
public Plugin:myinfo = 
{
 name = "DoD Pistols",
 author = "<eVa>Dog (edit by Lis)",
 description = "Adds a pistol for all players in DoDS and controls ammo",
 version = PLUGIN_VERSION,
 url = "http://www.theville.org"
}
public OnPluginStart()
{
 CreateConVar("sm_dod_pistols_version", PLUGIN_VERSION, "DoD Pistols", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)
 
 // Rifleman player
 g_Cvar_k98AmmoGer = CreateConVar("sm_dod_k98_ammo_ger", "60", "K98 ammo <60 default>", FCVAR_PLUGIN)
 g_Cvar_garandAmmoUS = CreateConVar("sm_dod_garand_ammo_us", "60", "Garand ammo  <72 default>", FCVAR_PLUGIN)
 
 // Assault player
 g_Cvar_mp40AmmoGer = CreateConVar("sm_dod_mp40_ammo_ger", "150", "The amount of ammo to give to Germans  <16 default>", FCVAR_PLUGIN)
 g_Cvar_thompsonAmmoUS = CreateConVar("sm_dod_thompson_ammo_us", "150", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 
 // Sniper player
 g_Cvar_k98sAmmoGer = CreateConVar("sm_dod_k98s_ammo_ger", "60", "The amount of ammo to give to Germans  <16 default>", FCVAR_PLUGIN)
 g_Cvar_springAmmoUS = CreateConVar("sm_dod_spring_ammo_us", "50", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 // Support player
 g_Cvar_stg44AmmoGer = CreateConVar("sm_dod_stg44_ammo_ger", "180", "The amount of ammo to give to Germans  <16 default>", FCVAR_PLUGIN)
 g_Cvar_barAmmoUS = CreateConVar("sm_dod_bar_ammo_us", "240", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 // MG player
 g_Cvar_mg42AmmoGer = CreateConVar("sm_dod_mg42_ammo_ger", "250", "The amount of ammo to give to Germans  <16 default>", FCVAR_PLUGIN)
 g_Cvar_30calAmmoUS = CreateConVar("sm_dod_30cal_ammo_us", "300", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 // Rocket class
 g_Cvar_pschreckAmmoGer = CreateConVar("sm_dod_pschreck_ammo_ger", "4", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 g_Cvar_bazookaAmmoUS = CreateConVar("sm_dod_bazooka_ammo_us", "4", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 
 // Secondary weapons sniper
 g_Cvar_p38AmmoGer = CreateConVar("sm_dod_p38_ammo_ger", "16", "The amount of ammo to give to Germans  <16 default>", FCVAR_PLUGIN)
 g_Cvar_coltAmmoUS = CreateConVar("sm_dod_colt_ammo_us", "14", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 // Secondary weapons rocket
 g_Cvar_c96AmmoGer = CreateConVar("sm_dod_c96_ammo_us", "40", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 g_Cvar_m1carbAmmoUS = CreateConVar("sm_dod_m1carb_ammo_us", "30", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 // Grenades
 g_Cvar_stickGer = CreateConVar("sm_dod_stick_ammo_ger", "2", "The amount of ammo to give to Allies  <2 support 1 assault>", FCVAR_PLUGIN)
 g_Cvar_fragUS = CreateConVar("sm_dod_frag_ammo_us", "2", "The amount of ammo to give to Allies  <2 support 1 assault>", FCVAR_PLUGIN)
 g_Cvar_smokegerGer = CreateConVar("sm_dod_smokeger_ammo_ger", "1", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 g_Cvar_smokeusUS = CreateConVar("sm_dod_smokeus_ammo_us", "1", "The amount of ammo to give to Allies  <14 default>", FCVAR_PLUGIN)
 HookEvent("player_spawn", PlayerSpawnEvent)
 
 AutoExecConfig(true, "dod_pistols");
}
 
public PlayerSpawnEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"))
 
    CreateTimer(0.1, EquipClientCustom, client, 0)
}
public Action:EquipClientCustom(Handle:timer, any:client)
{
 new team = GetClientTeam(client)
 new ammo_offset = FindSendPropOffs("CDODPlayer", "m_iAmmo")
 new class = GetEntProp(client, Prop_Send, "m_iPlayerClass")
 //SetEntProp(client, Prop_Send, "m_iPlayerClass", class, 1);
 
 if (class == 0)
 {
  // Rifleman class team 2 is US team 3 is GER
  if (team == 2) 
  {
   GivePlayerItem(client, "weapon_colt")
   SetEntData(client, ammo_offset+16, GetConVarInt(g_Cvar_garandAmmoUS), 4, true)
   SetEntData(client, ammo_offset+4, GetConVarInt(g_Cvar_coltAmmoUS), 4, true)
  }
 
  if (team == 3) 
  {
   GivePlayerItem(client, "weapon_p38")
   SetEntData(client, ammo_offset+20, GetConVarInt(g_Cvar_k98AmmoGer), 4, true)
   SetEntData(client, ammo_offset+8, GetConVarInt(g_Cvar_p38AmmoGer), 4, true)
  }
 }
 else if(class == 1)
 {
  // Assault class
  if (team == 2) 
  {
   SetEntData(client, ammo_offset+32, GetConVarInt(g_Cvar_thompsonAmmoUS), 4, true)
   SetEntData(client, ammo_offset+4, GetConVarInt(g_Cvar_coltAmmoUS), 4, true)
   SetEntData(client, ammo_offset+52, GetConVarInt(g_Cvar_fragUS), 4, true)
   SetEntData(client, ammo_offset+68, GetConVarInt(g_Cvar_smokeusUS), 4, true)
  }
 
  if (team == 3) 
  {
   SetEntData(client, ammo_offset+32, GetConVarInt(g_Cvar_mp40AmmoGer), 4, true)
   SetEntData(client, ammo_offset+8, GetConVarInt(g_Cvar_p38AmmoGer), 4, true)
   SetEntData(client, ammo_offset+56, GetConVarInt(g_Cvar_stickGer), 4, true)
   SetEntData(client, ammo_offset+72, GetConVarInt(g_Cvar_smokegerGer), 4, true)
  }
 }
 else if(class == 2)
 {
  // Support class
  if (team == 2) 
  {
   GivePlayerItem(client, "weapon_colt")
   SetEntData(client, ammo_offset+36, GetConVarInt(g_Cvar_barAmmoUS), 4, true)
   SetEntData(client, ammo_offset+4, GetConVarInt(g_Cvar_coltAmmoUS), 4, true)
   SetEntData(client, ammo_offset+52, GetConVarInt(g_Cvar_fragUS), 4, true)
  }
 
  if (team == 3) 
  {
   GivePlayerItem(client, "weapon_p38")
   SetEntData(client, ammo_offset+32, GetConVarInt(g_Cvar_stg44AmmoGer), 4, true)
   SetEntData(client, ammo_offset+8, GetConVarInt(g_Cvar_p38AmmoGer), 4, true)
   SetEntData(client, ammo_offset+56, GetConVarInt(g_Cvar_stickGer), 4, true)
  }
 }
 else if(class == 3)
 {
  // Sniper class
  if (team == 2) 
  {
   SetEntData(client, ammo_offset+28, GetConVarInt(g_Cvar_springAmmoUS), 4, true)
   SetEntData(client, ammo_offset+4, GetConVarInt(g_Cvar_coltAmmoUS), 4, true)
  }
 
  if (team == 3) 
  {
   SetEntData(client, ammo_offset+20, GetConVarInt(g_Cvar_k98sAmmoGer), 4, true)
   SetEntData(client, ammo_offset+8, GetConVarInt(g_Cvar_p38AmmoGer), 4, true)
  }
 }
 else if(class == 4)
 {
  // MG class
  if (team == 2) 
  {
   SetEntData(client, ammo_offset+44, GetConVarInt(g_Cvar_30calAmmoUS), 4, true)
   SetEntData(client, ammo_offset+4, GetConVarInt(g_Cvar_coltAmmoUS), 4, true)
// this following line gives unknow entity failure
   //GivePlayerItem(client, "weapon_frag")
   SetEntData(client, ammo_offset+52, GetConVarInt(g_Cvar_fragUS), 4, true)
  }
 
  if (team == 3) 
  {
   SetEntData(client, ammo_offset+40, GetConVarInt(g_Cvar_mg42AmmoGer), 4, true)
   SetEntData(client, ammo_offset+8, GetConVarInt(g_Cvar_p38AmmoGer), 4, true)
// this following line gives unknow entity failure
   //GivePlayerItem(client, "weapon_stick")
   SetEntData(client, ammo_offset+56, GetConVarInt(g_Cvar_stickGer), 4, true)
  }
 }
 else if(class == 5)
 {
  // Rocket class
  if (team == 2) 
  {
   SetEntData(client, ammo_offset+48, GetConVarInt(g_Cvar_bazookaAmmoUS), 4, true)
   //SetEntData(client, ammo_offset+4, GetConVarInt(g_Cvar_coltAmmoUS), 4, true)
   SetEntData(client, ammo_offset+24, GetConVarInt(g_Cvar_m1carbAmmoUS), 4, true)
  }
 
  if (team == 3) 
  {
   SetEntData(client, ammo_offset+48, GetConVarInt(g_Cvar_pschreckAmmoGer), 4, true)
   //SetEntData(client, ammo_offset+8, GetConVarInt(g_Cvar_p38AmmoGer), 4, true)
   SetEntData(client, ammo_offset+12, GetConVarInt(g_Cvar_c96AmmoGer), 4, true)
  }
 }
 // Handle all other classes if there are any
 else
 {
  // Do nothing
 }
 
 return Plugin_Handled
}
The offsets for m_iAmmo used by each weapon:
=============start offsets==============
m_iAmmo + 4 is the colt
m_iAmmo + 8 is the p38
m_iAmmo + 12 is the c96
m_iAmmo + 16 is the garand
m_iAmmo + 20 is the k98, k98s
m_iAmmo + 24 is the m1carb
m_iAmmo + 28 is the spring
m_iAmmo + 32 is the thompson, mp40, stg44
m_iAmmo + 36 is the bar
m_iAmmo + 40 is the 30cal
m_iAmmo + 44 is the mg42
m_iAmmo + 48 is the bazooka, panzerschreck
m_iAmmo + 52 is the frag grenade
m_iAmmo + 56 is the stick grenade
m_iAmmo + 68 is the smoke grenade us
m_iAmmo + 72 is the smoke grenade ger
m_iAmmo + 84 us rifleman us, garand grenades? Is 1 but grenades are 2
m_iAmmo + 88 us rifleman ger,k98 grenades? Is 1 but grenades are 2
=============end offsets==============

The dod_pistols.cfg
=============Start dod_pistols.cfg==============
// Possible weapons are:
// weapon_amerknife Us hand weapon
// weapon_spade Ger hand weapon
// weapon_colt Us Sniper and assault secondary
// weapon_p38 Ger Sniper and assault secondary
// weapon_garand Us Rifleman primary
// weapon_k98 Ger Rifleman primary. 5 Bullets in clip
// weapon_thompson Us Assault primary. 30 Bullets in clip
// weapon_mp40 Ger Assault primary. 30 Bullets in clip
// weapon_bar Us Support primary. 20 Bullets in clip
// weapon_mp44 Ger Support primary. 30 bullets in clip
// weapon_spring Us Sniper primary. 5 Bullets in clip.
// weapon_k98s Ger Sniper primary. 5 Bullets in clip
// weapon_30cal Us Machine Gun primary. 150 Bullets in clip.
// weapon_mg42 Ger Machine Gun primary. 250 Bullets in clip.
// weapon_bazooka Us Rocket primary. 4 Bullets in clip.
// weapon_pschreck Ger Rocket primary. 4 Bullets in clip.
// weapon_frag Us frag grenade. 1 for the assault. 2 for support.
// weapon_stick Ger frag grenade. 1 for the assault. 2 for support.
// weapon_smokeus Us smoke grenade. 1 for the assault.
// weapon_smokeger Ger smoke grenade. 1 for the assault.

sm_dod_k98_ammo_ger 60
sm_dod_garand_ammo_us 60
sm_dod_mp40_ammo_ger 150
sm_dod_thompson_ammo_us 150
sm_dod_k98s_ammo_ger 60
sm_dod_spring_ammo_us 50
sm_dod_stg44_ammo_ger 180
sm_dod_bar_ammo_us 240
sm_dod_mg42_ammo_ger 250
sm_dod_30cal_ammo_us 300
sm_dod_pschreck_ammo_ger 4
sm_dod_bazooka_ammo_us 4
sm_dod_p38_ammo_ger 160
sm_dod_colt_ammo_us 140
sm_dod_c96_ammo_us 40
sm_dod_m1carb_ammo_us 30
sm_dod_stick_ammo_ger 3
sm_dod_frag_ammo_us 3
sm_dod_smokeger_ammo_ger 1
sm_dod_smokeus_ammo_us 1
=============End dod_pistols.cfg==============

The idea is to open the gcf files and search for the grenade model names, they should match the entity name thought.
But this workarround leads me to another problem. How do i open gcf files?

Last edited by Lis; 07-16-2008 at 10:35.
Lis is offline
Send a message via ICQ to Lis Send a message via MSN to Lis
Lis
Member
Join Date: Jul 2008
Old 07-16-2008 , 10:49   Re: DoDs ammo ammount and weapon control
Reply With Quote #2

Found it:
GivePlayerItem(client, "weapon_frag_us")
GivePlayerItem(client, "weapon_frag_ger")
GivePlayerItem(client, "weapon_smoke_us")
GivePlayerItem(client, "weapon_smoke_ger")

Last edited by Lis; 07-16-2008 at 21:38.
Lis is offline
Send a message via ICQ to Lis Send a message via MSN to Lis
DarkEnergy
SourceMod Donor
Join Date: Apr 2008
Location: Georgia Tech, MSECE
Old 07-25-2008 , 17:30   Re: DoDs ammo ammount and weapon control
Reply With Quote #3

the machine gun ammo aint working, i set it to 1000 and its still 2x 150 per box

Last edited by DarkEnergy; 07-25-2008 at 17:51.
DarkEnergy is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-25-2008 , 18:32   Re: DoDs ammo ammount and weapon control
Reply With Quote #4

What's the code you used? It works fine for me with this code:
Code:
SetEntData(client, FindSendPropInfo("CBasePlayer", "m_iAmmo") + 40, 1000)
(44 for mg42)
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
DarkEnergy
SourceMod Donor
Join Date: Apr 2008
Location: Georgia Tech, MSECE
Old 07-25-2008 , 19:34   Re: DoDs ammo ammount and weapon control
Reply With Quote #5

new ammo_offset = FindSendPropOffs("CDODPlayer", "m_iAmmo")

else if(class == 4)
{
// MG class
if (team == 2)
{
SetEntData(client, ammo_offset+40, 1000, 4, true)//30cal
SetEntData(client, ammo_offset+4, 1000, 4, true)//colt
// this following line gives unknow entity failure
//GivePlayerItem(client, "weapon_frag")
SetEntData(client, ammo_offset+52, 1000, 4, true)//frag
}

if (team == 3)
{
SetEntData(client, ammo_offset+44, 1000, 4, true)//mg42
SetEntData(client, ammo_offset+8, 1000, 4, true)//p38
// this following line gives unknow entity failure
//GivePlayerItem(client, "weapon_stick")
SetEntData(client, ammo_offset+56, 1000, 4, true)//stick
}
}

the colt and p38 works
DarkEnergy is offline
Lis
Member
Join Date: Jul 2008
Old 07-25-2008 , 21:17   Re: DoDs ammo ammount and weapon control
Reply With Quote #6

Ya you need to replase it with the entitys i wrote in the second post.
Anyway check out this:
http://forums.alliedmods.net/showthread.php?p=654354

Its the completed plugin of this script.
__________________
Lis is offline
Send a message via ICQ to Lis Send a message via MSN to Lis
Reply



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 20:46.


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