Kill Score based on Ranks
#1

Guys, I wanted to create a system where score is awarded based on the rank of the player that was killed.

For example, I killed a Rank 1 Player, I get +5 Score. Let us say, I kill a Rank 4 Player, I get +7 Score and etc. (I hope you guys get my point.)

So basically I have 6 ranks available. How do I reward the player differently with scores for different consecutive rank kills?


Here's my Rank's Score :
Код:
Score (0-499) Rank 1
Score (500-1499) Rank 2
Score (1500-3499) Rank 3
Score (3500-6499) Rank 4
Score (6500-7999) Rank 5
Score (8000-12000) Rank 6
So like can anyone show me how to send different client messages to a different rank kill and give different score? Ex: "You have killed a Rank 1 Player"

Any help will be much appreciated and +REP
Reply
#2

pawn Код:
#define MAX_PLAYER_LEVELS 6
#define MAX_LEVELNAME_LEN 10

new const g_LevelXPLimit[MAX_PLAYER_LEVELS] = {
    500,
    1500,
    3500,
    6500,
    8000,
    12000
};

new const g_LevelKillReward[MAX_PLAYER_LEVELS] = {
    5,
    7,
    10,
    14,
    19,
    25
};

new const g_LevelNames[MAX_PLAYERS_LEVELS][MAX_LEVELNAME_LEN+1 char] = {
    !"Newbie",
    !"Novice",
    !"Apprentice",
    !"Adept",
    !"Expert",
    !"Master"
};

new g_PlayerXP[MAX_PLAYERS];

GetPlayerLevel(playerid) {
    for(new lvl; lvl < MAX_PLAYER_LEVELS ; lvl ++) {
        if( g_PlayerXP[playerid] < g_LevelXPLimit[lvl] ) {
            return lvl;
        }
    }
    return MAX_PLAYER_LEVELS - 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
    if( killerid != INVALID_PLAYER_ID ) {
        new
            dead_lvl = GetPlayerLevel(playerid),
            dead_name[MAX_PLAYER_NAME+1],
            dead_lvl_name[MAX_LEVELNAME_LEN+1],
            msg_str[144+1]
        ;
       
        SetPlayerScore(killerid, GetPlayerScore(killerid) +  g_LevelKillReward[dead_lvl]); // added recently

        GetPlayerName(playerid, dead_name, sizeof dead_name);
        strunpack(dead_lvl_name, g_LevelNames[dead_lvl], sizeof dead_lvl_name);
        format(msg_str, sizeof msg_str, "Score +%i for killing %s (%s)!", g_LevelKillReward[dead_lvl], dead_name, dead_lvl_name);
        SendClientMessage(killerid, 0xFFFFFFFF, msg_str);
    }
    return 1;
}
Something like this?
Reply
#3

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
#define MAX_PLAYER_LEVELS 6
new const g_LevelXPLimit[MAX_PLAYER_LEVELS] = {
    500,
    1500,
    3500,
    6500,
    8000,
    12000
};

new const g_LevelKillReward[MAX_PLAYER_LEVELS] = {
    5,
    7,
    10,
    14,
    19,
    25
};

new g_PlayerXP[MAX_PLAYERS];

GetPlayerLevel(playerid) {
    for(new lvl; lvl < MAX_PLAYER_LEVELS ; lvl ++) {
        if( g_PlayerXP[playerid] < g_LevelXPLimit[lvl] ) {
            return lvl;
        }
    }
    return MAX_PLAYER_LEVELS - 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
    if( killerid != INVALID_PLAYER_ID ) {
        new dead_lvl = GetPlayerLevel(playerid), msg_str[144+1];
        format(msg_str, sizeof msg_str, "You have killed a Rank %i Player, you have gained %i XP", dead_lvl + 1, g_LevelKillReward[dead_lvl]);
        SendClientMessage(killerid, 0xFFFFFFFF, msg_str);
    }
    return 1;
}
Something like this?
Hmm yea but let us say I was going to use names instead of numbers like Rank 0/1/2 etc.... how do I do that?
"You have killed a Rank %i Player,, what value will be displayed over at %i ?
Reply
#4

%i is a format specifier to display integer values.
%s is used to display string values

I'm confused - do you want to assign names to your ranks? Or do you want to show the player name?
Reply
#5

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
%i is a format specifier to display integer values.
%s is used to display string values

I'm confused - do you want to assign names to your ranks? Or do you want to show the player name?
Hmm, I would prefer to show both. The player name and also the Rank.

For example: "Score +%i for killing Daniel (Newbie)!"

Let us consider Newbie as Rank 0.

So hmm, how do I do this then?
Reply
#6

Add a rank and string it
e.g
PHP код:
new pRank[MAX_PLAYERS];
getrankname(playerid)
{
    new 
string[24];
    switch(
pRank[playerid])
    {
        case 
1string "Newbie";
    }
    return 
string;

Reply
#7

switch player rank whatever
case 0: return "Newbie"
Reply
#8

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
#define MAX_PLAYER_LEVELS 6
#define MAX_LEVELNAME_LEN 10

new const g_LevelXPLimit[MAX_PLAYER_LEVELS] = {
    500,
    1500,
    3500,
    6500,
    8000,
    12000
};

new const g_LevelKillReward[MAX_PLAYER_LEVELS] = {
    5,
    7,
    10,
    14,
    19,
    25
};

new const g_LevelNames[MAX_PLAYERS_LEVELS][MAX_LEVELNAME_LEN+1 char] = {
    !"Newbie",
    !"Novice",
    !"Apprentice",
    !"Adept",
    !"Expert",
    !"Master"
};

new g_PlayerXP[MAX_PLAYERS];

GetPlayerLevel(playerid) {
    for(new lvl; lvl < MAX_PLAYER_LEVELS ; lvl ++) {
        if( g_PlayerXP[playerid] < g_LevelXPLimit[lvl] ) {
            return lvl;
        }
    }
    return MAX_PLAYER_LEVELS - 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
    if( killerid != INVALID_PLAYER_ID ) {
        new
            dead_lvl = GetPlayerLevel(playerid),
            dead_name[MAX_PLAYER_NAME+1],
            dead_lvl_name[MAX_LEVELNAME_LEN+1],
            msg_str[144+1]
        ;
       
        GetPlayerName(playerid, dead_name, sizeof dead_name);
        strunpack(dead_lvl_name, g_LevelNames[dead_lvl], sizeof dead_lvl_name);
        format(msg_str, sizeof msg_str, "Score +%i for killing %s (%s)!", g_LevelKillReward[dead_lvl], dead_name, dead_lvl_name);
        SendClientMessage(killerid, 0xFFFFFFFF, msg_str);
    }
    return 1;
}
Okay, is this what you're looking for?
Reply
#9

Yea seems good but I don't find any like SetPlayerScore/GivePlayerScore so actually what rewards are the players getting?
Reply
#10

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
#define MAX_PLAYER_LEVELS 6
#define MAX_LEVELNAME_LEN 10

new const g_LevelXPLimit[MAX_PLAYER_LEVELS] = {
    500,
    1500,
    3500,
    6500,
    8000,
    12000
};

new const g_LevelKillReward[MAX_PLAYER_LEVELS] = {
    5,
    7,
    10,
    14,
    19,
    25
};

new const g_LevelNames[MAX_PLAYERS_LEVELS][MAX_LEVELNAME_LEN+1 char] = {
    !"Newbie",
    !"Novice",
    !"Apprentice",
    !"Adept",
    !"Expert",
    !"Master"
};

new g_PlayerXP[MAX_PLAYERS];

GetPlayerLevel(playerid) {
    for(new lvl; lvl < MAX_PLAYER_LEVELS ; lvl ++) {
        if( g_PlayerXP[playerid] < g_LevelXPLimit[lvl] ) {
            return lvl;
        }
    }
    return MAX_PLAYER_LEVELS - 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
    if( killerid != INVALID_PLAYER_ID ) {
        new
            dead_lvl = GetPlayerLevel(playerid),
            dead_name[MAX_PLAYER_NAME+1],
            dead_lvl_name[MAX_LEVELNAME_LEN+1],
            msg_str[144+1]
        ;
       
        SetPlayerScore(killerid, GetPlayerScore(killerid) +  g_LevelKillReward[dead_lvl]); // added recently

        GetPlayerName(playerid, dead_name, sizeof dead_name);
        strunpack(dead_lvl_name, g_LevelNames[dead_lvl], sizeof dead_lvl_name);
        format(msg_str, sizeof msg_str, "Score +%i for killing %s (%s)!", g_LevelKillReward[dead_lvl], dead_name, dead_lvl_name);
        SendClientMessage(killerid, 0xFFFFFFFF, msg_str);
    }
    return 1;
}
Sorry, i forgot that part. What about now?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)