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?