Theggv / Kreedz

Kreedz mod for Counter-Strike 1.6
27 stars 10 forks source link

ranking system. #43

Closed gedaskofficial closed 1 year ago

gedaskofficial commented 1 year ago

Hi ggv, thanks for keeping kreedz community alive! This is the best project available publicly so far.

I am trying to implement a ranking system, because I am not familiar with Pawn I thought Im gonna be a bit cheeky and use another ranking plugin. I found a decent one here: https://github.com/OciXCrom/RankSystem , but it rewards xp for kills/headshots/bomb_defusals etc.

When looking through plugins source code I found these:

public bomb_planted(id)
{
    give_user_xp(id, get_xp_reward(id, XPREWARD_BOMB_PLANTED), CRXRANKS_XPS_REWARD)
}

I guess I would need to change this to lets say:

public map_completed(id)
{
    give_user_xp(id, get_xp_reward(id, XPREWARD_MAPFINISHED), CRXRANKS_XPS_REWARD)
}

Maybe you could point me at the right direction please? I would guess that I need to find where the Kreedz plugin decides what place the player gets when he presses stop button and depending on that place award player with XP.

Any kind of guidance would be greatly appreciated! Thanks for your time.

EDIT:

I made some progress. I have found that I need to add this line " crxranks_give_userxp(id, , "kztimer") " when run finishes.

    // Stop button detected
    if (TrieKeyExists(g_tStops, szTarget)) {
        if (g_UserData[id][ud_TimerState] != TIMER_ENABLED)
            return HAM_IGNORED;

        run_finish(id);
                crxranks_give_user_xp(id, _, "kztimer");
    }

And I guess I need to add it just after run_finish(id); ? This ends up giving XP for every run, not based on place taken.

I would greatly appreciate if someone could guide me where I can find how the top 1/2/3 etc. is generated? Thanks!

Theggv commented 1 year ago

Hi, I can implement api for your purposes, something like this:

forward kz_run_finished(id, runInfo[RunStruct], place, bestPlace);

where runInfo contains time, cp count, tp count and other useful info.

You can use it in your plugin like this:

public kz_run_finished(id, runInfo[RunStruct], place, bestPlace) {
    //
    // XP calculations
    //

    give_user_xp(id, calculatedValue, CRXRANKS_XPS_REWARD);
}

That will be fine if you want static xp system. For dynamic xp values (e.g. someone beats you record and you lose some xp) you will need more complicated solution.

gedaskofficial commented 1 year ago

Thats awesome!

forward kz_run_finished(id, runInfo[RunStruct], place, bestPlace);

so 'place' would be the #position the player took at that moment? What would be 'bestPlace'? I just looked up the RunStruct and yep, I can see time,cp,tp, etc.

I would be very happy with simple static xp system, where it just depends if the person landed in top15 and gets awarded with xp accordingly #1 being highest. I need to do some research about 'give_user_xp' to find out what the second and third values supposed to be.

Thanks for the response ggv, let me get you a coffee!

Theggv commented 1 year ago

I thought 'bestPlace' would be player's best place in top, so you can check if player already competed map with better time. But this will not work as i expected, so probably this parameter not needed.

Theggv commented 1 year ago

fa686db

gedaskofficial commented 1 year ago

Happy days! Thank you very much ggv!