Give_Weapon? [message #482869] |
Tue, 30 July 2013 00:47 |
|
Xpert
Messages: 1588 Registered: December 2005 Location: New York City
Karma: 0
|
General (1 Star) |
|
|
Is there a script or some kind of function that you can use to give a character a weapon? I'm not looking for Give_PowerUp either before someone mentions it.
Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.
Part time streamer - https://twitch.tv/gg_wonder
|
|
|
Re: Give_Weapon? [message #482870 is a reply to message #482869] |
Tue, 30 July 2013 03:04 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
WeaponBagClass functions:
WeaponClass * Add_Weapon( const WeaponDefinitionClass * def, int rounds = 0, bool give_weapon = true );
WeaponClass * Add_Weapon( int id, int rounds = 0, bool give_weapon = true );
WeaponClass * Add_Weapon( const char *weapon_name, int rounds = 0, bool give_weapon = true );
You can get a WeaponBagClass pointer for an GameObject like:
SCRIPTS_API const wchar_t *Get_Current_Wide_Translated_Weapon(GameObject *obj)
{
if (!obj)
{
return 0;
}
PhysicalGameObj *o = obj->As_PhysicalGameObj();
if (!o)
{
return 0;
}
ArmedGameObj *o2 = o->As_ArmedGameObj();
if (!o2)
{
return 0;
}
WeaponBagClass *w = o2->Get_Weapon_Bag();
SoldierGameObj::Give_All_Weapons(void) loops through weapon definitions and grants everyone of them to a soldier withWeaponBagClass::Add_Weapon(char const*,int,bool). It loops through all definitions with DefinitionMgrClass::Get_First(ulong,DefinitionMgrClass::ID_TYPE) and call DefinitionMgrClass::Get_Next(DefinitionClass *,ulong,DefinitionMgrClass::ID_TYPE). It sets the amount of ammo for the granted weapon to -1 and passes 'true' to the 'give_weapon' bool arg. Those two DefinitionMgrClass functions return a DefinitionClass object (NOT pointer), and DefinitionClass::Get_Name() is probably called to get the weapon name to pass to Add_Weapon().
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
|
|
|
|