Raised This Month: $ Target: $400
 0% 

cs_set_weapon_ammo w/o cstrike.inc


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 12-14-2007 , 07:15   cs_set_weapon_ammo w/o cstrike.inc
Reply With Quote #1

So ... I think the title sums it up, really.

I don't particularly want to include cstrike when I can most likely set a single data element / hack a single offset to do this.

Anyone know how?

(Also any ideas on giving a weapon without fun.inc would be cool too)
purple_pixie is offline
Old 12-14-2007, 07:19
ConnorMcLeod
This message has been deleted by ConnorMcLeod. Reason: deleted yeah
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 12-14-2007 , 07:20   Re: cs_set_weapon_ammo w/o cstrike.inc
Reply With Quote #2

Give / Strip weapons:

Code:
stock fm_strip_user_weapons(index)
{
 new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"));
 
 if(!pev_valid(ent))
  return 0;
 
 dllfunc(DLLFunc_Spawn, ent);
 dllfunc(DLLFunc_Use, ent, index);
 engfunc(EngFunc_RemoveEntity, ent);
 
 return 1;
}
 
stock fm_give_item(index, const item[])
{
 if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  return 0;
 
 new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
 
 if(!ent)
  return 0;
 
 new Float:origin[3];
 pev(index, pev_origin, origin);
 set_pev(ent, pev_origin, origin);
 set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
 
 dllfunc(DLLFunc_Spawn, ent);
 
 new save = pev(ent, pev_solid);
 dllfunc(DLLFunc_Touch, ent, index);
 
 if(pev(ent, pev_solid) != save)
  return ent;
 
 engfunc(EngFunc_RemoveEntity, ent);
 
 return -1;
}
And ammo thing : http://forums.alliedmods.net/showpos...86&postcount=2
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-14-2007 , 07:23   Re: cs_set_weapon_ammo w/o cstrike.inc
Reply With Quote #3

Yeah you can also make your own reading cstrike.h and cstrike.ccp
http://svn.alliedmods.net/viewvc.cgi.../?root=amxmodx
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 12-14-2007 , 07:48   Re: cs_set_weapon_ammo w/o cstrike.inc
Reply With Quote #4

I guessed cstrike.cpp would help, I just thought if someone already knew it would save me a fair bit of bother.

Thankyou, people.

Eat karma, bitches.
purple_pixie is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-14-2007 , 07:59   Re: cs_set_weapon_ammo w/o cstrike.inc
Reply With Quote #5

That's all what you need :

PHP Code:
#define EXTRAOFFSET_WEAPONS            4 // weapon offsets are obviously only 4 steps higher on Linux!

#define OFFSET_CLIPAMMO            51 //+ EXTRA_OFFSET_WEAPONS

stock cs_get_weapon_ammo(weapon_id)
{
    return 
get_pdata_int(weapon_idOFFSET_CLIPAMMOEXTRAOFFSET_WEAPONS)
}

stock cs_set_weapon_ammo(weapon_idnewammo)
{
    
set_pdata_int(weapon_idOFFSET_CLIPAMMOnewammoEXTRAOFFSET_WEAPONS)

karma deleted lol
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 12-14-2007 , 08:09   Re: cs_set_weapon_ammo w/o cstrike.inc
Reply With Quote #6

I'd probably do it as:
Code:
#define cs_get_weapon_ammo(%1) get_pdata_int(%1,OFFSET_CLIPAMMO,EXTRAOFFSET_WEAPONS) #define cs_set_weapon_ammo(%1,%2) set_pdata_int(%1,OFFSET_CLIPAMMO,%2,EXTRAOFFSET_WEAPONS)

But both should work fine.

Just one other quick question ... when should you pass FM an FM_Allocated String, and when a "real" string (cell array)?

EDIT: I'm being a tard. fakemeta_const.inc FTW.
"Int StringParamName" means it wants an Int ... just maybe an alloc handle?
And "Char *StringParamName" would be a Char pointer ... which I seem to remember means an array.

So that's how I tell.
Bonus.

Last edited by purple_pixie; 12-14-2007 at 08:20.
purple_pixie is offline
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 23:27.


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