AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cs_set_weapon_ammo w/o cstrike.inc (https://forums.alliedmods.net/showthread.php?t=64369)

purple_pixie 12-14-2007 07:15

cs_set_weapon_ammo w/o cstrike.inc
 
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)

Alka 12-14-2007 07:20

Re: cs_set_weapon_ammo w/o cstrike.inc
 
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

ConnorMcLeod 12-14-2007 07:23

Re: cs_set_weapon_ammo w/o cstrike.inc
 
Yeah you can also make your own reading cstrike.h and cstrike.ccp
http://svn.alliedmods.net/viewvc.cgi.../?root=amxmodx

purple_pixie 12-14-2007 07:48

Re: cs_set_weapon_ammo w/o cstrike.inc
 
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.

ConnorMcLeod 12-14-2007 07:59

Re: cs_set_weapon_ammo w/o cstrike.inc
 
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 :P

purple_pixie 12-14-2007 08:09

Re: cs_set_weapon_ammo w/o cstrike.inc
 
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.


All times are GMT -4. The time now is 11:08.

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