Raised This Month: $ Target: $400
 0% 

even the odds mod can't compile. find my bugs please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
timian
Member
Join Date: Oct 2006
Location: Denmark
Old 06-17-2009 , 13:58   even the odds mod can't compile. find my bugs please
Reply With Quote #1

try to rewirte my code, with a little help from sylwesters code.


try compile it but get some erros, please tell me the bugs.

cs don't "load" my plugins i tryed to compile sylvesters version, but cs still won't load it, why not?

PHP Code:
//Even the Odds
//V 0.2 rewrite

#include <amxmodx>
#include <fun>
#include <hamsandwich>

#define MAX_PLAYERS 32
#define MAX_LEVEL = 30

new gPlayerLevel[MAX_PLAYERS 1//player level and ID
new gCalcHealth gPlayerLevel[id]

public 
plugin_init() {
    
register_plugin("Even The Odds""0.2""Beancake12")
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
    
register_event("HLTV""event_new_round""a""1=0""2=0")
}

public 
player_spawn(id) {
    if(
is_user_alive(id))
        
set_level(id)
        new 
gCalcHealth 310
        set_user_health
(idgCalcHealth-(10*gPlayerLevel[id]))
}

public 
set_level(id) {
    if(!
is_user_connected(id))
        return
    
gPlayerLevel[id] = (get_user_frags(id) - get_user_deaths(id))
    if(
gPlayerLevel[id] < 1)
        
gPlayerLevel[id] = 1
    
if(gPlayerLevel[id] > MAX_LEVEL)
        
gPlayerLevel[id] = MAX_LEVEL


Last edited by timian; 06-19-2009 at 05:42.
timian is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-17-2009 , 14:02   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #2

You need to define 'get_max_players', use a var and save into 'get_maxplayers()', and gModIsOn = 1 shoud be ==.

Since you're new, this thread can be useful for you : http://forums.alliedmods.net/showthread.php?t=94381 and http://forums.alliedmods.net/showthread.php?t=91207
__________________
Arkshine is offline
timian
Member
Join Date: Oct 2006
Location: Denmark
Old 06-17-2009 , 14:10   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #3

thanks! i try it now, compile is done!

//after trying

fail!!! my cs don't do my plugin!?

think it don't load my plugin?

why not!?

Last edited by timian; 06-17-2009 at 14:36.
timian is offline
P i x e L
Junior Member
Join Date: Jun 2009
Location: eBaum's World
Old 06-17-2009 , 14:38   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #4

post your new one?
P i x e L is offline
timian
Member
Join Date: Oct 2006
Location: Denmark
Old 06-17-2009 , 14:44   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #5

okay, look at top for my new code.

Last edited by timian; 06-17-2009 at 15:14.
timian is offline
P i x e L
Junior Member
Join Date: Jun 2009
Location: eBaum's World
Old 06-17-2009 , 19:18   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #6

You don't have:
register_event("HLTV", "event_new_round","a", "1=0", "2=0")
in plugin_init
I think you'll need that
P i x e L is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-17-2009 , 21:34   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #7

Even if he add this line, nothing will change since players are not spawned yet when new round is called.

I would do it like this:
PHP Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>

#define MAX_LVLS 10
#define DIFF 5  // level = 4 + (kills-deaths)/DIFF
#define MAX_PLAYERS 32

new bool:g_freezetime
new g_max_hp[MAX_LVLS] =  {2502001501251008060403020}
new 
Float:g_speed_bonus[MAX_LVLS] = { 50.035.020.010.00.0, -10.0, -20.0, -30.0, -40.0, -50.0}
new 
Float:g_weap_speed[32] = {0.0250.00.0260.0250.0240.0250.0250.0240.0,
250.0250.0250.0250.0210.0240.0240.0250.0250.0210.0250.0220.0230.0,
230.0250.0210.0250.0250.0235.0221.0250.0245.00.0}
new 
g_p_lvl[MAX_PLAYERS 1]


public 
plugin_init() {
    
register_plugin("Even The Odds""1.0""Sylwester")
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
    
register_event("CurWeapon""reset_player_speed""be""1=1")
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_logevent("logevent_round_start"2"1=Round_Start")
}


public 
reset_player_speed(id){
    if(
g_freezetime)
        return
    
set_user_maxspeed(idg_weap_speed[get_user_weapon(id)] + g_speed_bonus[g_p_lvl[id]])
}


public 
player_spawn(id){
    if(
is_user_alive(id)){
        
set_lvl(id)
        
set_user_health(idg_max_hp[g_p_lvl[id]])
    }
}


public 
set_lvl(id){
    if(!
is_user_connected(id))
        return
    
g_p_lvl[id] = (get_user_frags(id) - get_user_deaths(id))/DIFF 4
    
if(g_p_lvl[id] < 0)
        
g_p_lvl[id] = 0
    
if(g_p_lvl[id] > MAX_LVLS-1)
        
g_p_lvl[id] = MAX_LVLS-1
}


public 
event_new_round(){
    
g_freezetime true
}


public 
logevent_round_start(){
    
g_freezetime false

Store max hps and speed bonuses in some arrays. Update odds and set health on player spawn and set max speed on curweapon.
__________________
Impossible is Nothing

Last edited by Sylwester; 06-17-2009 at 21:36.
Sylwester is offline
timian
Member
Join Date: Oct 2006
Location: Denmark
Old 06-18-2009 , 05:11   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #8

Sylwester - i think you're right... but the big problem is: if you just make the total answer, and don't tell very much i don't learn anything... so thanks for your answer, and it is really much more simple than mine. but i don't get any exp by this.

can you explain it?

note: i want to change movement speed, not weapon speed.
timian is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-18-2009 , 07:03   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #9

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 View Post
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 ).
__________________
Impossible is Nothing

Last edited by Sylwester; 06-18-2009 at 07:08.
Sylwester is offline
timian
Member
Join Date: Oct 2006
Location: Denmark
Old 06-18-2009 , 07:34   Re: even the odds mod can't compile. find my bugs please
Reply With Quote #10

thanks i would look at all your links!

i looked at your code, and under stand it a way better now. i tried to make the mod more simpel (look at the 2nd code at top).

i have fixed some erroes. but there is still 2, cant find them. thanks sylwester.
timian 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 15:36.


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