Raised This Month: $ Target: $400
 0% 

[HELP] Better description of some natives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-04-2017 , 12:51   [HELP] Better description of some natives
Reply With Quote #1

get_user_weapons(iPlayer, iWeapons, iNum)
get_weaponid(szWeaponName)

What these two actually retrieve ? the weapon index ( CSW_* ) or the entity index ?
__________________

Last edited by Depresie; 04-04-2017 at 12:51.
Depresie is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 04-04-2017 , 14:03   Re: [HELP] Better description of some natives
Reply With Quote #2

Code:
 /* Returns all carried weapons as bit sum. Gets  *  also theirs indexes.  * Note that num is incremental - if you pass 0, you get  *  32 weapons towards the total.  Afterwards, num will  *  will contain the number of weapons retrieved.  * However, subsequent calls to get_user_weapons() will  *  return the next batch of weapons, in case the mod  *  supports more than 32 weapons.  * This means to call get_user_weapons() on the same  *  inputs twice, you must reset num to 0 to get the  *  original output again.  */ native get_user_weapons(index,weapons[32],&num);

Code:
/**   * Returns the weapon id, otherwise 0 when no id found.  * The weapon name is case sensitive, and has the weapon_* form.  */ native get_weaponid(const name[]);

get_user_weapons returns every weapon player owns as bitsum (1<<CSW_KNIFE) and get_weaponid returns the weapon ID (CSW_KNIFE)
__________________
edon1337 is offline
Old 04-04-2017, 14:15
EFFx
This message has been deleted by EFFx. Reason: ,
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-05-2017 , 08:15   Re: [HELP] Better description of some natives
Reply With Quote #4

Any idea how you write this without a stock ?

PHP Code:
public function(index)
{
      new 
iWeaponEntity fm_find_ent_by_owner(entityszclassnameowner)
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) { /* keep looping */ }
    return 
entity;

Something like

PHP Code:
public function(index)
{
    new 
iWeaponEntity ???
    ???
    ???
    

And could someone explain to me better how it works ?
__________________

Last edited by Depresie; 04-05-2017 at 08:17.
Depresie is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-05-2017 , 08:33   Re: [HELP] Better description of some natives
Reply With Quote #5

Quote:
Originally Posted by Depresie View Post
Any idea how you write this without a stock ?

PHP Code:
public function(index)
{
      new 
iWeaponEntity fm_find_ent_by_owner(entityszclassnameowner)
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) { /* keep looping */ }
    return 
entity;

Something like

PHP Code:
public function(index)
{
    new 
iWeaponEntity ???
    ???
    ???
    

And could someone explain to me better how it works ?

No 💡
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-05-2017 , 09:20   Re: [HELP] Better description of some natives
Reply With Quote #6

Quote:
Originally Posted by Depresie View Post
Any idea how you write this without a stock ?

PHP Code:
public function(index)
{
      new 
iWeaponEntity fm_find_ent_by_owner(entityszclassnameowner)
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) { /* keep looping */ }
    return 
entity;

Easy. Just move the code from the stock into your plugin. Done. OR, just use the stock (this is the better idea).
__________________

Last edited by fysiks; 04-05-2017 at 09:20.
fysiks is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-05-2017 , 08:25   Re: [HELP] Better description of some natives
Reply With Quote #7

What exactly are you trying to do? I don't see anything wrong with that fm_find_ent_by_owner() function you provided.

Last edited by klippy; 04-05-2017 at 08:26.
klippy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-05-2017 , 08:40   Re: [HELP] Better description of some natives
Reply With Quote #8

Eh, missed some brackets/what ever initially, figured it out, mostly..

Sorry for newbie questions, i have a hobby lately of learning how every line of code works

Here is what i came up with so far, if anyone has any idea how to make it more compact for readability, i'm all ears..

PHP Code:
new iWeaponEntityID = -1

while((iWeaponEntityID engfunc(EngFunc_FindEntityByStringiWeaponEntityID"classname"szWeaponName)) && pev(iWeaponEntityIDpev_owner) != iPlayer)
{
      
// Keep Looping until we meet the conditions above

__________________

Last edited by Depresie; 04-05-2017 at 08:41.
Depresie is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-05-2017 , 09:11   Re: [HELP] Better description of some natives
Reply With Quote #9

What's wrong with using find_ent_by_owner?
__________________
Arkshine is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-05-2017 , 09:53   Re: [HELP] Better description of some natives
Reply With Quote #10

I wanted to make it more compact, without using a stock.. mainly because i want to learn more and also because i'm working on a big project which i plan to make in on single file, so making things more compact/simple would be better ( ex, no 100 function communication )

I also have this problem while coding, called symmetry obsession, it's like a cancer, haha
__________________

Last edited by Depresie; 04-05-2017 at 09:55.
Depresie 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 17:54.


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