Kill Score based on Ranks -
Sting. - 25.02.2018
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
Re: Kill Score based on Ranks -
RedFusion - 25.02.2018
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?
Re: Kill Score based on Ranks -
Sting. - 25.02.2018
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 ?
Re: Kill Score based on Ranks -
RedFusion - 25.02.2018
%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?
Re: Kill Score based on Ranks -
Sting. - 25.02.2018
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?
Re: Kill Score based on Ranks -
AlexMSK - 25.02.2018
Add a rank and string it
e.g
PHP код:
new pRank[MAX_PLAYERS];
getrankname(playerid)
{
new string[24];
switch(pRank[playerid])
{
case 1: string = "Newbie";
}
return string;
}
Re: Kill Score based on Ranks -
rfr - 25.02.2018
switch player rank whatever
case 0: return "Newbie"
Re: Kill Score based on Ranks -
RedFusion - 25.02.2018
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?
Re: Kill Score based on Ranks -
Sting. - 25.02.2018
Yea seems good but I don't find any like SetPlayerScore/GivePlayerScore so actually what rewards are the players getting?
Re: Kill Score based on Ranks -
RedFusion - 25.02.2018
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?