AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help on understanding the coding of a plugin (https://forums.alliedmods.net/showthread.php?t=159714)

anupm 06-20-2011 13:48

Need help on understanding the coding of a plugin
 
Hi ,

I am a learner . I try to read many source code of plugins . I was going through one code but I can't understand a bit of it :( .

Please help .

The plugin url

http://forums.alliedmods.net/showthread.php?p=597185

The part I can't understand


stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)
{
new strtype[11] = "classname", ent = index
switch (jghgtype)
{
case 1: strtype = "target"
case 2: strtype = "targetname"
}

while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}

return ent
}

fysiks 06-20-2011 14:03

Re: Need help on understanding the coding of a plugin
 
It finds an entity of "classname" that is owned by "owner". Also, I believe the search starts at "index".

drekes 06-20-2011 14:05

Re: Need help on understanding the coding of a plugin
 
It is a fakemeta conversion of Engine's find_ent_by_owner() function.

fysiks 06-20-2011 14:07

Re: Need help on understanding the coding of a plugin
 
Quote:

Originally Posted by drekes (Post 1492330)
It is a fakemeta conversion of Engine's find_ent_by_owner() function.

Which should be used instead of fm_find_ent_by_owner() since it's does the same thing.

anupm 06-20-2011 14:31

Re: Need help on understanding the coding of a plugin
 
so can i block a firing completely with this function ?

fysiks 06-20-2011 14:40

Re: Need help on understanding the coding of a plugin
 
Quote:

Originally Posted by anupm (Post 1492351)
so can i block a firing completely with this function ?

This function has nothing to do with firing a weapon.

anupm 06-20-2011 14:51

Re: Need help on understanding the coding of a plugin
 
Quote:

Originally Posted by fysiks (Post 1492360)
This function has nothing to do with firing a weapon.

then how come he is delaying the firing ?

Exolent[jNr] 06-20-2011 15:12

Re: Need help on understanding the coding of a plugin
 
Quote:

Originally Posted by anupm (Post 1492365)
then how come he is delaying the firing ?

With that logic, you could say that is_user_alive() gives me noclip because I check that before giving player noclip.
You have to understand what the code does by knowing what specific functions do.

drekes 06-20-2011 15:14

Re: Need help on understanding the coding of a plugin
 
If a player buys or picks up a weapon, he becomes the owner of that weapon.
The player's id gets assigned to pev_owner of the weapon.

What that stock does is go through all the weapons & check if the weapon belongs to the id that is passed as the thirth param of the function.

It are these that change the fire rate.
PHP Code:

static Float:Delay,Float:M_Delay
Delay 
get_pdata_floatEnt464) * N_Speed
M_Delay 
get_pdata_floatEnt474) * N_Speed
if (Delay 0.0)
{
    
set_pdata_floatEnt46Delay4)
    
set_pdata_floatEnt47M_Delay4)



fysiks 06-20-2011 16:39

Re: Need help on understanding the coding of a plugin
 
Quote:

Originally Posted by drekes (Post 1492382)
What that stock does is go through all the weapons & check if the weapon belongs to the id that is passed as the first third param of the function.



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

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