Trying to write some random stuff won't work for you. You lack amxx basics, your "rewrite" does not even compile. Read tutorials and start with some more simple plugins. I recommend:
http://wiki.amxmodx.org/Introduction_to_Pawn
http://wiki.amxmodx.org/Pawn_Tutorial
Debugging Plugins
http://wiki.amxmodx.org/Intro_to_AMX_Mod_X_Scripting
Once you are done with tutorials read this (info about my code):
Instead of using switch with many cases, it's better to store bonus values in arrays and create formula, so you can use it to retrieve proper bonus value for player in 1 line:
Code:
bonus = some_array[formula_return_value]
So, if you want bonus for player change every 5 (user_frags - user_deaths) then you start make formula like this:
Code:
formula_return_value = (get_user_frags(player_id) - get_user_deaths(player_id))/5
Since you want to retrieve bonus from array also for players who have more deaths than frags (formula returns negative value) and arrays are indexed starting from 0 then you need to enlarge returned value by adding some number. In the end it looks like this:
Code:
formula_return_value = 4 + (get_user_frags(player_id) - get_user_deaths(player_id))/5
After this you must add code that checks if the value returned is a proper index in array (otherwise you will get index out of bounds runtime error).
Now when you can properly get bonus value from array for any player, you can start thinking about setting player speed and health.
You can set player health only when he is alive, so the best moment to do it is just after player has spawned. To detect that moment you need to hook player spawn (in other words tell plugin what is the name of the function that should be called when player was spawned).
Trying to set player health on New Round is totally wrong because players are not spawned yet. Round Start is not the best because some players may spawn after Round Start has been called. You can find a lot info about these events and how to hook them here:
http://forums.alliedmods.net/showthread.php?t=42159
About player max speed: It is reseted to weapon speed very often (example: when player switch weapon), so changing it only 1 time after player spawn will not work. To make sure that player speed will not change to default value, you must detect every max speed reset and change it back to value you want. To detect speed reset you need to hook CurWeapon event:
Code:
register_event("CurWeapon", "reset_player_speed", "be", "1=1")
When using CurWeapon, your function can be also called during freezetime, but we don't want players to be able to move when they are not supposed to, so you need to check if you can set player speed or not. To do that you need to hook New Round and Round Start and store boolean value (is now freezetime ? ) in some global variable.
Quote:
Originally Posted by timian
note: i want to change movement speed, not weapon speed.
|
My code changes movement speed. I used weapon speed as a base, so players with same (frags - deaths)/5 will move with different speeds if they have different weapons. Otherwise player with awp could move with same speed as player with knife (if they have same (frags-deaths)/5 ).
__________________