Solved (ReAPI) AntiFlashLightSpam + ResetScore

Coding Help/Re-API Supported
User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#21

Post by Raheem » 6 years ago

These returns tell the function what to do now. For example take damage function (This function will be called when any player take damage):
    1. #include <amxmodx>
    2. #include <reapi>
    3.  
    4. public plugin_init()
    5. {
    6.     // Register our plugin first
    7.     register_plugin("Return Explaning", "1.0", "Raheem")
    8.    
    9.     // HookChains (This will be called when any player take damage)
    10.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
    11.    
    12.     // HookChains (This will be called just before damage take place)
    13.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Pre", 0)
    14. }
    15.  
    16. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
    17. {
    18.     // This return exit your function you used in this plugin so the print message won't be printed
    19.     return HC_CONTINUE;
    20.    
    21.     client_print(id, print_chat, "This message will not be printed in game!!!")
    22. }
    23.  
    24. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
    25. {
    26.     client_print(id, print_chat, "This message will be printed in game!!!")
    27.    
    28.     // After the message printed, This return will exit this function which used in this plugin
    29.     return HC_CONTINUE;
    30. }
    31.  
    32. public Fw_TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
    33. {
    34.     // This will exit the main function so player will not take damage at all (Exit real function which is taking damage)
    35.     return HC_SUPERCEDE;
    36. }
    37.  
    38. public Fw_TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
    39. {
    40.     client_print(id, print_chat, "This message will appear in the game! + No damage at all")
    41.    
    42.     // The message will appear and then the real function won't be executed so no damage will take place
    43.     return HC_SUPERCEDE;
    44. }
    45.  
    46. public Fw_TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
    47. {
    48.     // No damage will take place, Real function exit + The down client print won't be executed as this function in this plugin will exit too
    49.     return HC_SUPERCEDE;
    50.    
    51.     client_print(id, print_chat, "This message will not appear in the game! + No damage at all")
    52. }
Hope you get anything. In brief return is used to decide if you need now to stop this function and exit from it or continue? Or stop(exit) the real function that run by default by CS? Tell me what you don't get and i explain again 8-)
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#22

Post by ArminC » 6 years ago

Ok :) somehow I get it (like I don't know to code but I want to understand it atleast :D ) + if there isn't nothing to re-size that plugin from above.. I think that's the final for this topic. Amen!

Off-topic: hmm.. for this friday I had to make a ancient Egypt (powerpoint), best of the class lol :lol:

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#23

Post by Raheem » 6 years ago

ArminC wrote: 6 years ago Ok :) somehow I get it (like I don't know to code but I want to understand it atleast :D ) + if there isn't nothing to re-size that plugin from above.. I think that's the final for this topic. Amen!
Yes it's nice to know what these returns done so you understand if you need just to edit simple things. This topic will be marked as solved.
ArminC wrote: 6 years ago Off-topic: hmm.. for this friday I had to make a ancient Egypt (powerpoint), best of the class lol :lol:
Hehe, Need any help? :lol: :lol:
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#24

Post by ArminC » 6 years ago

NoNoNo, everything was already finished and reviewed by teacher ^_^ 33 slides of Egypt, about 10hours of work :X *effort was good enough for the best callificative in the classroom #rekt)

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#25

Post by Raheem » 6 years ago

Nice, Good luck and hope you best in your studies : )
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 9 guests