Raised This Month: $51 Target: $400
 12% 

[Alien Swarm] Finding current equipped weapon name


Post New Thread Reply   
 
Thread Tools Display Modes
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-30-2010 , 07:48   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #11

Quote:
Originally Posted by psychonic View Post
More followup...

Since I'm nice (sometimes) and this will eventually be needed anyway, here is a plugin library to provide natives for these. Just do "#include <swarmtools>". I can/will also add natives to replicate any sdktools_functions natives that require a client index but need to be executed on a marine. Just let me know what doesn't work directly with a marine index.

This is completely untested as I don't have the desire or time to do so right now, but if you can confirm that it works, I'll post it in the New Plugins section (or fix it first).

Code:
/**
* Gets the marine entity controlled by the given player
*
* @param client Client index
* @return Marine entity index or -1 for none or not found
* @error Invalid client index
*/
native Swarm_GetMarine(client);

/**
* Gets the client index controlling given marine
*
* @param marine Marine entity index
* @return Client index of controller or -1 for none or not found
* @error Invalid marine index
*/
native Swarm_GetClientOfMarine(marine);



This requires SDK Tools and SDK Hooks. I will post a temporary build of SDK Hooks 1.3 shortly that will work on Alien Swarm.
first thing, there's an error with your swarmtools.smx... the plugin check is wrong, resulting in the swarmtools.smx unable to be loaded, so i have to delete the game check line until u modify it to a correct check... more results coming rite up..

Last edited by comp_noob; 11-30-2010 at 08:08.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-30-2010 , 08:06   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #12

Quote:
Originally Posted by comp_noob View Post
first thing, there's an error with your swarmtools.smx... the plugin check is wrong, resulting in the swarmtools.smx unable to be loaded, so i have to delete the game check line until u modify it to a correct check... more results coming rite up..

EDIT: error number 2, when i tried to use Swarm_GetMarine(client), it returns a marine id, which is correct, i think... but when i used Swarm_GetClientOfMarine(marine), there's an error:
PHP Code:
 Marine 28:#asw_name_crash SetInitialCommander id to STEAM_x:x:xxxxxxxx
 
Marine 65:#asw_name_sarge SetInitialCommander id to STEAM_x:x:xxxxxxxx
 
Marine 88:#asw_name_wildcat SetInitialCommander id to STEAM_x:x:xxxxxxxx
 
Marine 98:#asw_name_faith SetInitialCommander id to STEAM_x:x:xxxxxxxx
getmarine 1
Marine ID is 28.
getuser 28
L 11
/30/2010 20:53:48: [SMNative "Swarm_GetClientOfMarine" reportedEntity index 2 is a asw_mission_managernot a marine
L 11
/30/2010 20:53:48: [SMDisplaying call stack trace for plugin "new.smx":
L 11/30/2010 20:53:48: [SM]   [0]  Line 26, new.sp::Get_Marine_User() 
Thanks for the feedback.

I fixed the game check on my end. It will be in the next version I post. (I forgot to actually populate the gamedir var before comparing it.)

As for the error you got, can you paste the test code you're using?

It seems that the console command you made, "getuser" is only sending the first digit to the native, hence the error "Entity index 2 is..." instead of "Entity index 28 is...".
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-30-2010 , 08:53   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #13

Quote:
Originally Posted by psychonic View Post
Thanks for the feedback.

I fixed the game check on my end. It will be in the next version I post. (I forgot to actually populate the gamedir var before comparing it.)

As for the error you got, can you paste the test code you're using?

It seems that the console command you made, "getuser" is only sending the first digit to the native, hence the error "Entity index 2 is..." instead of "Entity index 28 is...".
yup that error is my fault... i only gave the string an array value of 2, which is not enough. so i increased it to 5 and it's working perfectly now.. the plugin that u posted is fully working, except that the gamecheck is not working, that's all.. is there any way that you can include a native to get the weapon that the marine is currently holding? because i am trying to make a plugin that increases the ammo of the weapons, as alien swarm's weapon have limited ammo, and they run out pretty fast...
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-30-2010 , 08:58   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #14

Quote:
Originally Posted by comp_noob View Post
is there any way that you can include a native to get the weapon that the marine is currently holding?
Absolutely. I already have a stock for it and am adding more right now. I'll post a new version in just a bit with many more functions. I also removed the SDK Hooks requirement.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-30-2010 , 09:01   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #15

Quote:
Originally Posted by psychonic View Post
Absolutely. I already have a stock for it and am adding more right now. I'll post a new version in just a bit with many more functions. I also removed the SDK Hooks requirement.
Wow, you are so nice! thanks~ will be looking forward to your plugin!
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-30-2010 , 09:25   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #16

Quote:
Originally Posted by psychonic View Post
Absolutely. I already have a stock for it and am adding more right now. I'll post a new version in just a bit with many more functions. I also removed the SDK Hooks requirement.
Version should read as 1.1.0.

If you could please test some of it again, this can be the version I will officially post. Also let me know if there's anything else you would like to be exposed.

Code:
/**  * Gets the marine entity controlled by the given player  *  * @param client        Client index  * @return              Marine entity index or -1 for none or not found  * @error               Invalid client index  */ native Swarm_GetMarine(client); /**  * Gets the client index controlling given marine  *  * @param marine        Marine entity index  * @return              Client index of controller or -1 for none or not found  * @error               Invalid marine index  */ stock Swarm_GetClientOfMarine(marine); /**  * Gets the marine resource entity index of given client  *  * @param client        Client index  * @return              Marine resource entity index of client or -1 for none or not found  * @error               Invalid client index  */ native Swarm_GetMarineResFromCommander(client); /**  * Gets the marine resource entity index of given marine  *  * @param marine        Marine entity index  * @return              Marine resource entity index of entity or -1 for none or not found  * @error               Invalid marine index  */ native Swarm_GetMarineResOfMarine(marine); /**  * Returns the weapon in a marine's slot.  *  * @param marine        Marine entity index  * @param slot          Slot index (0-based)  * @return              Entity index on success, -1 if no weapon existed.  * @error               Invalid entity or unable to find marine's weapons  */ stock Swarm_GetMarineWeaponSlot(marine, slot); /**  * Returns the marine's current weapon.  *  * @param marine        Marine entity index  * @return              Entity index on success, -1 if no weapon existed.  * @error               Invalid entity  */ stock Swarm_GetMarineActiveWeapon(marine); /**  * Returns the marine's health.  *  * @param marine        Marine entity index  * @return              Health value  * @error               Invalid entity  */ stock Swarm_GetMarineHealth(marine); /**  * Set the marine's health. (same as SetEntityHealth)  *  * @param marine        Marine entity index  * @param amount        Health amount  * @error               Invalid entity  */ stock Swarm_SetMarineHealth(marine, health); /**  * Returns the marine's max health.  *  * @param marine        Marine entity index  * @return              Max Health value  * @error               Invalid entity  */ stock Swarm_GetMarineMaxHealth(marine); /**  * Returns the marine's ammo amount of the specified type.  *  * @param marine        Marine entity index  * @return              Amount  * @error               Invalid entity or unable to find marine ammo offset  */ stock Swarm_GetMarineAmmo(marine, SwarmAmmoType:ammotype); /**  * Set the marine's ammo amount of the specified type.  *  * @param marine        Marine entity index  * @param amount        Amount  * @error               Invalid entity or unable to find marine ammo offset  */ stock Swarm_SetMarineAmmo(marine, SwarmAmmoType:ammotype, amount); /**  * Returns if a marine is infested  *  * @param marine        Marine entity index  * @return              True if marine is infested, false otherwise  * @error               Invalid entity  */ stock bool:Swarm_IsMarineInfested(marine); /**  * Returns if a marine is on fire  *  * @param marine        Marine entity index  * @return              True if marine is on fire, false otherwise  * @error               Invalid entity  */ stock bool:Swarm_IsMarineOnFire(marine); enum SwarmAmmoType {     SwarmAmmo_AR2,     SwarmAmmo_Rifle,     SwarmAmmo_RifleGrenades,     SwarmAmmo_Autogun,     SwarmAmmo_Shotgun,     SwarmAmmo_AssaultShotgun,     SwarmAmmo_Flamer,     SwarmAmmo_Pistol,     SwarmAmmo_MiningLaser,     SwarmAmmo_TeslaGun,     SwarmAmmo_Railun,     SwarmAmmo_ChainSaw,     SwarmAmmo_Flares,     SwarmAmmo_Medkit,     SwarmAmmo_MedSatchel,     SwarmAmmo_MedSatchelSelf,     SwarmAmmo_Stim,     SwarmAmmo_Welder,     SwarmAmmo_FireExtinguisher,     SwarmAmmo_VGrenades,     SwarmAmmo_PDW,     SwarmAmmo_HandGrenades,     SwarmAmmo_GrenadeLauncher,     SwarmAmmo_SniperRifle, }

Edit: Removed attachments. go here https://forums.alliedmods.net/showthread.php?t=144324

Last edited by psychonic; 12-02-2010 at 08:51.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-30-2010 , 09:28   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #17

ok i will start testing now! if there's any errors i will report it after i tested.. thanks again

EDIT: first error:
PHP Code:
L 11/30/2010 22:35:57: [swarmtools.smxUnable to locate marine resources
L 11
/30/2010 22:35:57: [SMNative "GetEntDataEnt2" reportedOffset -1 is invalid
L 11
/30/2010 22:35:57: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 11/30/2010 22:35:57: [SM]   [0]  Line 71swarmtools.sp::GetMarineResources()
L 11/30/2010 22:35:57: [SM]   [1]  Line 45swarmtools.sp::OnMapStart() 
2nd error: with your new swarmtools.smx, swarm_getmarine always return -1...
3rd error: Swarm_GetMarineResOfMarine(marine) and Swarm_GetMarineResFromCommander(client) always return -1...

Last edited by comp_noob; 11-30-2010 at 09:46.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-30-2010 , 09:51   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #18

Quote:
Originally Posted by comp_noob View Post
ok i will start testing now! if there's any errors i will report it after i tested.. thanks again

EDIT: first error:
PHP Code:
L 11/30/2010 22:35:57: [swarmtools.smxUnable to locate marine resources
L 11
/30/2010 22:35:57: [SMNative "GetEntDataEnt2" reportedOffset -1 is invalid
L 11
/30/2010 22:35:57: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 11/30/2010 22:35:57: [SM]   [0]  Line 71swarmtools.sp::GetMarineResources()
L 11/30/2010 22:35:57: [SM]   [1]  Line 45swarmtools.sp::OnMapStart() 
2nd error: with your new swarmtools.smx, swarm_getmarine always return -1...
3rd error: Swarm_GetMarineResOfMarine(marine) and Swarm_GetMarineResFromCommander(client) always return -1...
Blah, sorry about that. Forget to actually assign the offset to the variable after getting it. Updated the smx and sp on the above post. Version should read 1.1.1.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-30-2010 , 10:08   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #19

1st error:
PHP Code:
L 11/30/2010 23:06:57: [SMNative "EntIndexToEntRef" reportedInvalid entity index -1
L 11
/30/2010 23:06:57: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 11/30/2010 23:06:57: [SM]   [0]  Line 72swarmtools.sp::GetMarineResources()
L 11/30/2010 23:06:57: [SM]   [1]  Line 45swarmtools.sp::OnMapStart() 
and after this error, all the other natives return the wrong value of -1...
and i've found out that m_iClip1 returns the correct current ammo in the active weapon... maybe it can be of some help..

Last edited by comp_noob; 11-30-2010 at 10:25.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-30-2010 , 10:28   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #20

Quote:
Originally Posted by comp_noob View Post
1st error:
PHP Code:
L 11/30/2010 23:06:57: [SMNative "EntIndexToEntRef" reportedInvalid entity index -1
L 11
/30/2010 23:06:57: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 11/30/2010 23:06:57: [SM]   [0]  Line 72swarmtools.sp::GetMarineResources()
L 11/30/2010 23:06:57: [SM]   [1]  Line 45swarmtools.sp::OnMapStart() 
and after this error, all the other natives return the wrong value of -1...
and i've found out that m_iClip1 returns the correct current ammo in the active weapon... maybe it can be of some help..
The clip amount is the amount if ammo in the weapon's clip. The ammo stocks set the players ammo stock for that weapon (what is used when the clip runs out).

Post is updated again, version 1.1.2. I had some misconceptions about how/when the marine resources were allocated. I was able the mix the first method I was using with sdkhooks with the later findings. It should work now and still not require sdkhooks.

I do appreciate the time you're taking to test for me.
psychonic 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 16:41.


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