25.02.2018, 11:11
(
Последний раз редактировалось RedFusion; 25.02.2018 в 16:27.
)
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;
}