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

Round Bonus Remover v1.3 ( Remove Bonus For Win/Lose Rounds)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-04-2021 , 14:33   Re: Round Bonus Remover v1.3 ( Remove Bonus For Win/Lose Rounds)
Reply With Quote #21

Thanks for providing the code, now I see why you were confused. However, as I said, the code is wrong. Ham_Spawn is executed per player so it has an "id" argument.
PHP Code:
public e_Player_Spawn(id
Therefore, the task and iterating over players is not needed. You can simply do:

PHP Code:
public e_Player_Spawn(id)
{
    if(
is_user_alive(id))
    {
              
strip_user_weaponsid);
              
give_itemid"weapon_knife" );
              
give_itemid"weapon_awp" );
              
cs_set_user_bpammoidCSW_AWP 30 );
    }

Now you should not notice any delays. The behavior you described makes perfect sense with your original code, but it's caused, as I said, by the wrong code. Try what I proposed and see that it should work just fine.
I removed the team check because it is no longer needed: an alive, spawned player will either be tero or ct.

Also, I suggest you read this: https://forums.alliedmods.net/showthread.php?t=42159

To explain more about caching: a loop is executed multiple times. If values do not change between loop iterations then it's better to cache(save) them before the loop. This helps you avoid repeated native calls that will produce the same output. As a result, your code will be a bit faster. Assume you wanted to run a native that takes 1 second to run inside a loop that runs 32 times. This means that the time taken by that native is 32 runs * 1s per run = 32s. Now, if you cache the native before the loop, the whole run time of that native is only 1s. That's 32 times better.
__________________

Last edited by HamletEagle; 09-04-2021 at 14:40.
HamletEagle is offline
 



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 15:50.


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