Witamy w Nieoficjalnym polskim support'cie AMX Mod X
Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
|
Aramis
Rejestracja: 08.05.2016Aktualnie: Nieaktywny
Poza forum Ostatnio: 17.03.2023 23:19




Statystyki
- Grupa: Użytkownik
- Całość postów: 28
- Odwiedzin: 2 124
- Tytuł: Życzliwy
- Wiek: Wiek nie został ustalony
- Urodziny: Data urodzin nie została podana
-
Imię
Patryk
-
Płeć
Mężczyzna
-
Lokalizacja
Polska
Kontakt
Narzędzia użytkownika
Znajomi
Aramis nie posiada znajomych
Ostatnio byli
#776324 [ROZWIĄZANE] [Problem] Menu wyboru VIPa tylko na mapach DE/CS
Napisane przez PANDA_2zl
w 04.02.2023 02:00
W tym zamienić || (lub) na && (i) wtedy będzie patrzeć czy ani to ani to nie pojawia się w nazwie mapy, możesz też użyć zamiast equal
https://amxx.pl/doku...a/f1362/contain
I w warunku
if(contain(szMapName, "fy_")!=0 && contain(szMapName, "aim_")!=0){
#776338 [ROZWIĄZANE] [Problem] Kościotrup po śmierci - freelook poza mapą
Napisane przez Deus Vult
w 04.02.2023 20:07
Prawdopodobnie zachodzi kolizja poprzez nadpisanie bytu corpse (zwłoki gracza):
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#define PLUGIN "DeathBones"
#define VERSION "1.1.0"
#define AUTHOR "mogel"
#define BONE_ALPHA_TASK_BASIS 1000
new pcv_deathmatch // Deathmatch-Support
new pcv_bonestime // anzeigen der Bones
#define ALPHA EV_INT_iuser4
#define PLAYER EV_INT_iuser3
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_message(get_user_msgid("DeathMsg"), "Event_Death")
register_event("HLTV", "Event_FreezeTime", "a", "1=0", "2=0")
register_cvar("DeathBones", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
pcv_deathmatch = register_cvar("db_deathmatch", "0") // per default kein DM-Support
pcv_bonestime = register_cvar("db_bonestime", "30.0") // 30 Sekunden
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
}
public plugin_precache() {
precache_model("models/skeleton.mdl")
}
public Event_FreezeTime() {
new players[32], count
get_players(players, count, "h")
for(new i = 0; i < count; i++)
{
new player = players[i]
// Render zurück setzen
set_pev(player, pev_renderfx, kRenderFxNone)
set_pev(player, pev_rendercolor, 255,255,255)
set_pev(player, pev_rendermode, kRenderNormal)
set_pev(player, pev_renderamt, 0.0)
}
remove_entity_name("deathbones")
}
public Event_Death() {
new player = get_msg_arg_int(2)
new Float:bones[3]
new Float:angle[3]
entity_get_vector(player, EV_VEC_origin, bones)
entity_get_vector(player, EV_VEC_angles, angle)
bones[2] -= 32.0 // gleich nach unten setzen
// Bones erstellen
new entity = create_entity("info_target")
entity_set_string(entity, EV_SZ_classname, "deathbones")
entity_set_model(entity, "models/skeleton.mdl")
entity_set_origin(entity, bones)
entity_set_vector(entity, EV_VEC_angles, angle)
entity_set_int(entity, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_int(entity, EV_INT_solid, SOLID_NOT)
// Bones erstmal unsichtbar
set_pev(entity, pev_renderfx, kRenderFxNone)
set_pev(entity, pev_rendercolor, 255,255,255)
set_pev(entity, pev_rendermode, kRenderTransAlpha)
set_pev(entity, pev_renderamt, 0.0)
// Spieler durch Bones wechseln
entity_set_int(entity, PLAYER, player) // den Bones dem Spieler zuweisen
entity_set_int(entity, ALPHA, 0) // aktuelles Alpha für die Bones
set_task(1.0, "BonesAlphaIn", entity)
}
public BonesAlphaIn(bones) {
if (!is_valid_ent(bones)) return
new alpha = entity_get_int(bones, ALPHA) + 1
new player = entity_get_int(bones, PLAYER)
// Spieler ausblenden, aber nur wenn kein DM-Modus
if ((is_valid_ent(player)) && !get_pcvar_num(pcv_deathmatch))
{
set_pev(player, pev_renderfx, kRenderFxNone)
set_pev(player, pev_rendercolor, 255,255,255)
set_pev(player, pev_rendermode, kRenderTransAlpha)
set_pev(player, pev_renderamt, float(256 - alpha * 16))
}
if (is_valid_ent(bones))
{
set_pev(bones, pev_renderfx, kRenderFxNone)
set_pev(bones, pev_rendercolor, 255,255,255)
set_pev(bones, pev_rendermode, kRenderTransAlpha)
set_pev(bones, pev_renderamt, float(alpha * 16 - 1))
}
// neuen Alpha-Wert merken
entity_set_int(bones, ALPHA, alpha)
// jetzt entscheiden .. .weiter Alpha oder liegen lassen
if (alpha >= 16)
{
// wenn kein DM dann Spieler jetzt nach unten setzen
if (get_pcvar_num(pcv_deathmatch))
{
// im DM-Modus nach X Sekunden wieder ausblenden
set_task(get_pcvar_float(pcv_bonestime), "BonesAlphaOut", bones)
}
} else
{
set_task(0.1, "BonesAlphaIn", bones)
}
}
public BonesAlphaOut(bones) {
if (!is_valid_ent(bones)) return
new alpha = entity_get_int(bones, ALPHA) - 1
if (is_valid_ent(bones))
{
set_pev(bones, pev_renderfx, kRenderFxNone)
set_pev(bones, pev_rendercolor, 255,255,255)
set_pev(bones, pev_rendermode, kRenderTransAlpha)
set_pev(bones, pev_renderamt, float(alpha * 16 - 1))
}
// neuen Alpha-Wert merken
entity_set_int(bones, ALPHA, alpha)
// jetzt entscheiden .. .weiter Alpha oder killen
if (alpha)
{
set_task(0.1, "BonesAlphaOut", bones)
} else
{
remove_entity(bones)
}
}
W momencie kiedy giniesz - domyślnie przerzuca Cię na podgląd kolejnego gracza. A w tym wypadku po prostu automatycznie ustawia widok całkowicie poza mapą, na dole, za teksturami. Może ciężko to wytłumaczyć, ale nie mam jak inaczej tego zobrazować
#776334 [ROZWIĄZANE] [Problem] Kościotrup po śmierci - freelook poza mapą
Napisane przez Deus Vult
w 04.02.2023 16:41
#776330 [ROZWIĄZANE] [Problem] Formatowanie w HTML
Napisane przez Deus Vult
w 04.02.2023 14:43
#776313 [ROZWIĄZANE] [Problem] Formatowanie w HTML
Napisane przez Deus Vult
w 03.02.2023 11:27
#776307 [ROZWIĄZANE] [Problem] Menu wyboru VIPa tylko na mapach DE/CS
Napisane przez PANDA_2zl
w 03.02.2023 01:11
https://amxx.pl/topi...i-oraz-zmienne/
https://amxx.pl/doku...111/get-mapname
https://amxx.pl/doku...cja/f1375/equal
https://amxx.pl/doku...acja/f161/pause
#776289 [ROZWIĄZANE] [Problem] Formatowanie w HTML
Napisane przez PANDA_2zl
w 02.02.2023 00:31
#776294 [ROZWIĄZANE] [Problem] Formatowanie w HTML
Napisane przez Deus Vult
w 02.02.2023 13:53
Bliżej niż dalej
Tak jest po zmianie:
A tak chciałbym, żeby było:
Z samym HTML i CSS problemu nie mam, tylko w kodzie pluginu wygląda to troszkę inaczej niż kodzie zwykłej strony
Możesz próbować używać dopełnienia stringa/ciągu (%-x1.x2%s). Robisz to w ten sposób:
%s zamieniasz na %-x1.x2s. Za x1 podstawiasz liczbę minimalnych znaków, a za x2 podstawiasz liczbę maksymalnych znaków.
Dajmy na przykład:
%-22.22s jeżeli ciąg znaków jest krótszy od 22 znaków to resztę dopełni spacjami.
W praktyce wygląda to tak: %-22.22s [znak - lub + po % oznacza wyrównanie do lewej lub prawej]
Wyświetli się "Nick " <- wiemy, że zajmuje 4 znaki więc plugin dopisze 18 spacji.
W przypadku typu Integer wygląda to tak: %6d <- liczba jest mniejsza niż liczba 6cyfrowa to dopisuje spacje.
#776280 [ROZWIĄZANE] [Problem] Formatowanie w HTML
Napisane przez Deus Vult
w 01.02.2023 15:28
Zakładam, że o to ci chodzi - nie kompilowałem na sztywno skleiłem w notesie.
public CmdTimeTop(id)
{
new iRanks[10], iRanking[10], szKey[5], iTemp, z
for(new x; x < 10; x++)
{
for(new i=0; i <= TotalRanks; i++)
{
num_to_str(i, szKey, sizeof(szKey) - 1)
TrieGetCell(Rank, szKey, iTemp)
if(x == 0)
{
if(iRanks[x] < iTemp)
{
iRanks[x] = iTemp
iRanking[x] = i
if(z<x)
z=x
}
}
else
{
if(iRanks[x] < iTemp && iRanks[x-1] > iTemp)
{
iRanks[x] = iTemp
iRanking[x] = i
if(z<x)
z=x
}
}
}
}
new szName[32]
new iLen
iLen = formatex(sBuffer, MAX_BUFFER_LENGTH, "<body bgcolor=#000000><font color=#FFB000><pre>%s %s %s^n", "#", "Nick", "Czas na serwerze");
for(new y=0; y <= z; y++)
{
num_to_str(iRanking[y], szKey, sizeof(szKey) - 1)
TrieGetCell(Rank, szKey, iTemp)
TrieGetString(Name, szKey, szName, sizeof(szName) - 1)
iLen += formatex(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "#%i %s %i^n", y + 1, szName, iTemp);
}
show_motd(id, sBuffer, "Czas gry - TOP 10")
}
#776263 [ROZWIĄZANE] [Problem] Licznik wizyt na serwerze
Napisane przez Deus Vult
w 31.01.2023 19:56
#776262 [ROZWIĄZANE] [Problem] Licznik wizyt na serwerze
Napisane przez mordoryjacz
w 31.01.2023 19:34
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <colorchat>
#define PLUGIN "VisitCounter"
#define VERSION "1.1"
#define AUTHOR "Sebxx"
new c_tmp3, g_vault, visits, last_visit
new stamp[11], szSteam[35], temp[19], tmp[7]
new czas_gry[33];
new g_vault_cz;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
g_vault = nvault_open("Wizyty");
g_vault_cz = nvault_open("Czas");
register_clcmd("say /visits", "show_visits");
c_tmp3 = register_cvar("visitcounter_interval", "1800") // po jakim czasie naliczyc nowe wejscie?
}
public client_connect(id) {
wczytaj_czas_gry(id);
}
public client_authorized( id, const authid[] ) {
if(!is_user_bot(id) && !is_user_hltv(id)) {
set_task(10.0, "counter", id, _, _, "a", 1)
}
}
public counter(id) {
if(is_user_connected(id)) {
get_user_authid( id, szSteam, charsmax( szSteam ) )
new sekundy = (czas_gry[id] + get_user_time(id, 1)), minuty, godziny;
while(sekundy >= 60)
{
sekundy -= 60;
minuty++;
}
while(minuty >= 60)
{
minuty -= 60;
godziny++;
}
if ( nvault_get( g_vault , szSteam , temp , charsmax( temp ) ) )
{
strtok(temp, tmp, charsmax( tmp ), stamp, charsmax( stamp ), ';');
last_visit = str_to_num( stamp )
if ( last_visit + get_pcvar_num( c_tmp3 ) <= get_systime() )
{
visits = str_to_num( tmp ) + 1
ColorChat(id, TEAM_COLOR, "^1Na serwerze spedziles^4 %ih %imin %is.^1 Jest to twoja^4 %d^1 wizyta.", godziny, minuty, sekundy, visits)
}
else
{
return PLUGIN_CONTINUE
}
}
else
{
visits = 1
ColorChat(id, TEAM_COLOR, "^1To Twoja ^3pierwsza^1 wizyta na naszym serwerze")
}
num_to_str( visits, tmp, charsmax(tmp) )
num_to_str( get_systime(), stamp, charsmax(stamp) )
new iLen = 0, iMax = sizeof( temp ) - 1;
iLen += formatex( temp[iLen], iMax - iLen, tmp )
iLen += formatex( temp[iLen], iMax - iLen, ";" )
iLen += formatex( temp[iLen], iMax - iLen, stamp )
nvault_set( g_vault, szSteam, temp )
}
return PLUGIN_CONTINUE
}
public show_visits(id) {
if(is_user_connected(id)) {
get_user_authid( id, szSteam, charsmax( szSteam ) )
nvault_get( g_vault , szSteam , temp , charsmax( temp ) )
strtok(temp, tmp, charsmax( tmp ), stamp, charsmax( stamp ), ';');
ColorChat(id, TEAM_COLOR, "^1To juz Twoja^4 %s^1 wizyta na naszym serwerze", tmp)
}
}
public wczytaj_czas_gry(id) {
new name[35],vaultkey[64],vaultdata[256];
get_user_name(id,name,34);
format(vaultkey,63,"%s-gametime",name);
nvault_get(g_vault_cz,vaultkey,vaultdata,255);
czas_gry[id] = str_to_num(vaultdata);
return PLUGIN_CONTINUE;
}
public zapisz_czas_gry(id) {
new name[35],vaultkey[64],vaultdata[256];
get_user_name(id,name,34);
czas_gry[id] += get_user_time(id, 1);
format(vaultkey,63,"%s-gametime",name);
format(vaultdata, 255, "%d", czas_gry[id]);
nvault_set(g_vault_cz,vaultkey,vaultdata)
czas_gry[id] = str_to_num(vaultdata);
return PLUGIN_CONTINUE;
}
public client_disconnected(id) {
zapisz_czas_gry(id);
czas_gry[id] = 0;
if(task_exists(id))
remove_task(id)
}
public plugin_end() {
nvault_close(g_vault)
nvault_close(g_vault_cz);
}
usun zapis czasu
#776249 [ROZWIĄZANE] [Problem] Rangi - wczytuje rangę po pierwszym fragu
Napisane przez PANDA_2zl
w 31.01.2023 00:25
#776252 [ROZWIĄZANE] [Problem] Rangi - wczytuje rangę po pierwszym fragu
Napisane przez Deus Vult
w 31.01.2023 11:45
Czyli wychodzi na to że dane gracza get_user_stats są pobierane dopiero po odrodzeniu gracza, wiec to by tłumaczyło dlaczego tak się dzieje (podczas wykonywania forwardu client_authorized, putinserver statystyki gracza wynoszą 0). W tym przypadku odradzam korzystać z taska, bo jednemu serwer może się ładować 2 sekundy drugiemu 10..
Ustawianie rang po pierwszym respawnie od dołączenia powinno rozwiązać problem.
#include <amxmodx>
#include <colorchat>
#include <hamsandwich>
#include <fakemeta>
#include <csx>
#include <fun>
#define PLUGIN "Rangi"
#define AUTHOR "Wicked - amxx.pl/user/60210-wicked/"
#pragma semicolon 1
#define DEBUG_MODE
#define MAX_PLAYERS 32
#define MAX_CHARS 33
#define MAX_RANK_NAME_LENGTH 60
#define TASK_HUD 1337
#define ForRange(%1,%2,%3) for(new %1 = %2; %1 <= %3; %1++)
#define ForArray(%1,%2) for(new %1 = 0; %1 < sizeof %2; %1++)
#define ForDynamicArray(%1,%2) for(new %1 = 0; %1 < ArraySize(%2); %1++)
#define ForFile(%1,%2,%3,%4,%5) for(new %1 = 0; read_file(%2, %1, %3, %4, %5); %1++)
new const configFilePath[] = "addons/amxmodx/configs/RanksConfig.ini";
new const configFileDataSeparator = '=';
new const configFileKillsSeparator = '-';
new const configFileForbiddenChars[] =
{
'/',
';',
'\'
};
new const ranksListMenuCommands[][] =
{
"/rangi",
"/ranga",
"/listarang"
};
new const rankHudCommands[][] =
{
"/hud",
"/hudrangi"
};
new const chatPrefix[] = "^x03[RANGI]^x01";
new const rankUpForwardName[] = "user_rank_up";
new const Float:hudInterval = 1.0;
new const nativesData[][][] =
{
{ "ranks_get_user_rank", "native_get_user_rank", 0 },
{ "ranks_get_rank_name", "native_get_rank_name", 0 },
{ "ranks_get_rank_kills", "native_get_rank_frags", 0 }
};
enum dataEnumerator (+= 1)
{
dataRank,
dataRankName[MAX_RANK_NAME_LENGTH],
bool:dataHudEnabled,
dataKills,
dataKillsRequired
};
new Array:rankNames,
Array:rankFrags[2],
userData[MAX_PLAYERS + 1][dataEnumerator],
forwardRankUp,
hudObject;
new bool:playerConnected[33];
public plugin_init()
{
register_plugin(PLUGIN, "v2.2", AUTHOR);
register_message(get_user_msgid("SayText"), "handleSayText");
RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1);
register_event("DeathMsg", "deathMessage", "a");
forwardRankUp = CreateMultiForward(rankUpForwardName, ET_IGNORE, FP_CELL, FP_CELL);
hudObject = CreateHudSyncObj();
}
public mainMenu(index)
{
new name[MAX_CHARS],
menuIndex;
menuIndex = menu_create(fmt("Twoja ranga: %s (%i / %i)^nLista rang:", userData[index][dataRankName], userData[index][dataRank] + 1, ArraySize(rankNames)), "mainMenu_handler");
ForDynamicArray(i, rankNames)
{
ArrayGetString(rankNames, i, name, charsmax(name));
menu_additem(menuIndex, fmt("%s (Od: %i || Do: %i)", name, ArrayGetCell(rankFrags[1], i), ArrayGetCell(rankFrags[0], i)));
}
menu_display(index, menuIndex);
return PLUGIN_HANDLED;
}
public mainMenu_handler(index, menu, item)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public toggleHud(index)
{
toggle_hud(index, !userData[index][dataHudEnabled]);
}
public plugin_natives()
{
ForArray(i, nativesData)
{
register_native(nativesData[i][0], nativesData[i][1], nativesData[i][2][0]);
}
}
public plugin_precache()
{
loadConfigFile();
}
public OnPlayerSpawn(index)
{
if(playerConnected[index]) {
get_user_rank(index, true);
toggle_hud(index, true);
playerConnected[index] = false;
}
}
public client_putinserver(index)
{
playerConnected[index] = true;
}
public handleSayText(msgId, msgDest, msgEnt)
{
new index = get_msg_arg_int(1);
if(!is_user_connected(index))
{
return PLUGIN_CONTINUE;
}
new chatString[2][192];
get_msg_arg_string(2, chatString[0], charsmax(chatString[]));
if(!equal(chatString[0], "#Cstrike_Chat_All"))
{
formatex(chatString[1], charsmax(chatString[]), "^x03[^x04%s^x03] %s", userData[index][dataRankName], chatString[0]);
}
else
{
get_msg_arg_string(4, chatString[0], charsmax(chatString[]));
set_msg_arg_string(4, "");
formatex(chatString[1], charsmax(chatString[]), "^x03[^x04%s^x03] %n^x01 : %s", userData[index][dataRankName], index, chatString[0]);
}
set_msg_arg_string(2, chatString[1]);
return PLUGIN_CONTINUE;
}
public deathMessage()
{
new killer = read_data(1),
victim = read_data(2);
// Return if the kill-event doesnt matter.
if(killer == victim || !is_user_connected(victim) || !is_user_connected(killer))
{
return;
}
get_user_rank(killer);
}
public displayHud(taskIndex)
{
new index = taskIndex - TASK_HUD;
if(!is_user_connected(index))
{
return;
}
new message[2 << 7];
// Format hud message.
formatex(message, charsmax(message), "Twoja ranga: %s (%i / %i)", userData[index][dataRankName], userData[index][dataRank] + 1, ArraySize(rankNames));
if(userData[index][dataKillsRequired])
{
format(message, charsmax(message), "%s^nZabic: %i / %i", message, userData[index][dataKills], userData[index][dataKillsRequired]);
}
if(userData[index][dataRank] < ArraySize(rankNames) - 1)
{
new nextrankNames[MAX_RANK_NAME_LENGTH];
ArrayGetString(rankNames, userData[index][dataRank] + 1, nextrankNames, charsmax(nextrankNames));
format(message, charsmax(message), "%s^nNastepna ranga: %s", message, nextrankNames);
}
// Display the message.
set_hudmessage(150, 150, 150, -1.0, 0.05, 0, 1.0, hudInterval + 0.1);
ShowSyncHudMsg(index, hudObject, message);
}
toggle_hud(index, bool:status)
{
userData[index][dataHudEnabled] = status;
if(userData[index][dataHudEnabled])
{
set_task(hudInterval, "displayHud", index + TASK_HUD, .flags = "b");
}
else
{
// Remove task if it exists.
if(task_exists(index + TASK_HUD))
{
remove_task(index + TASK_HUD);
}
}
}
loadConfigFile()
{
// Initiate dynamic arrays.
rankNames = ArrayCreate(MAX_RANK_NAME_LENGTH, 1);
ForRange(i, 0, 1)
{
rankFrags[i] = ArrayCreate(1, 1);
}
new currentLine[MAX_RANK_NAME_LENGTH * 3],
lineLength,
readrankNames[MAX_RANK_NAME_LENGTH],
readRankKills[2][MAX_CHARS],
key[MAX_CHARS],
value[MAX_CHARS * 2],
bool:continueLine;
ForFile(i, configFilePath, currentLine, charsmax(currentLine), lineLength)
{
// Continue if it's an empty line.
if(!currentLine[0])
{
continue;
}
// Continue if found forbidden char (ex. comment)
ForArray(j, configFileForbiddenChars)
{
if(currentLine[0] == configFileForbiddenChars[j])
{
continueLine = true;
break;
}
}
if(continueLine)
{
continueLine = false;
continue;
}
// Read line data.
parse(currentLine, readrankNames, charsmax(readrankNames));
// Divide line data into key and value.
strtok(currentLine, key, charsmax(key), value, charsmax(value), configFileDataSeparator);
// Get rid of white-characters.
trim(value);
// Divide remaining line data into kills range.
strtok(value, readRankKills[0], charsmax(readRankKills[]), readRankKills[1], charsmax(readRankKills[]), configFileKillsSeparator);
// Add rank name.
ArrayPushString(rankNames, readrankNames);
// Add rank kills.
ForRange(j, 0, 1)
{
ArrayPushCell(rankFrags[j], str_to_num(readRankKills[j]));
}
#if defined DEBUG_MODE
log_amx("Registered rank: (name = %s) (kills: %i-%i)", readrankNames, ArrayGetCell(rankFrags[0], ArraySize(rankFrags[0]) - 1), ArrayGetCell(rankFrags[1], ArraySize(rankFrags[1]) - 1));
#endif
}
// Pause plugin if no ranks were loaded.
if(!ArraySize(rankNames))
{
set_fail_state("Nie znaleziono zadnych rang.");
return;
}
#if defined DEBUG_MODE
log_amx("Zaladowano: %i rang(i) w zakresie (%i - %i).", ArraySize(rankNames), ArrayGetCell(rankFrags[0], 0), ArrayGetCell(rankFrags[1], ArraySize(rankNames) - 1));
#endif
registerCommands(ranksListMenuCommands, sizeof(ranksListMenuCommands), "mainMenu");
registerCommands(rankHudCommands, sizeof(rankHudCommands), "toggleHud");
}
get_user_rank(index, bool:connect = false, bool:notify = true)
{
new userStats[8],
blank[8];
get_user_stats(index, userStats, blank);
// Update player's kills.
userData[index][dataKills] = userStats[0];
// Make sure player's rank is not bugged.
// If so, make it right.
if(userData[index][dataRank] >= ArraySize(rankNames))
{
userData[index][dataRank] = ArraySize(rankNames);
return;
}
new oldRank = userData[index][dataRank];
ForDynamicArray(i, rankNames)
{
// Break the loop if user kills is lower than required.
// Ranks should be sorted in ascending order, so if the player
// Has less kills than required, he's surely not gonna
// Get a rank higher than the one currently proccessed.
if(userStats[0] < ArrayGetCell(rankFrags[0], i))
{
break;
}
// Continue if he's got more kills than required.
if(userStats[0] > ArrayGetCell(rankFrags[1], i) && i < ArraySize(rankNames) - 1)
{
continue;
}
// Set new rank
userData[index][dataRank] = userData[index][dataRank] + 1 >= ArraySize(rankNames) ? ArraySize(rankNames) - 1 : i;
// Set kills required for the next rank.
userData[index][dataKillsRequired] = ArrayGetCell(rankFrags[1], userData[index][dataRank]);
// Update user rank name.
ArrayGetString(rankNames, userData[index][dataRank], userData[index][dataRankName], MAX_RANK_NAME_LENGTH);
// We dont want to show messages when getting the rank for the first time.
if(connect)
{
break;
}
// Break the loop if player's rank was not updated.
if(userData[index][dataRank] <= oldRank)
{
break;
}
// Format messages if enabled.
if(notify)
{
new message[2 << 7];
formatex(message, charsmax(message), "%s^x01 Awansowales na range ^"^x03%s^x01^".", chatPrefix, userData[index][dataRankName]);
if(userData[index][dataRank] + 1 >= ArraySize(rankNames))
{
format(message, charsmax(message), "%s Nastepna ranga:^x03 Brak^x01.", message);
}
else
{
new nextrankNames[MAX_RANK_NAME_LENGTH],
nextRankFrags[2];
ArrayGetString(rankNames, userData[index][dataRank] + 1, nextrankNames, charsmax(nextrankNames));
nextRankFrags[0] = ArrayGetCell(rankFrags[0], userData[index][dataRank] + 1);
nextRankFrags[1] = ArrayGetCell(rankFrags[1], userData[index][dataRank] + 1);
format(message, charsmax(message), "%s Nastepna ranga: ^"^x03%s^x01^" (^x03%i^x01 - ^x03%i^x01).", message, nextrankNames, nextRankFrags[0], nextRankFrags[1]);
}
ColorChat(index, RED, message);
}
// Inform other plugins about player ranking up.
ExecuteForward(forwardRankUp, _, index, userData[index][dataRank]);
// No need to do another iteration.
break;
}
}
public native_get_user_rank(plugin, params)
{
// Invalid amount of parameters.
if(params != 1)
{
return -1;
}
new index = get_param(1);
// Return error value if player is not connected.
if(!is_user_connected(index))
{
return -1;
}
return userData[index][dataRank];
}
public native_get_rank_name(plugin, params)
{
// Invalid amount of parameters.
if(params != 3)
{
return;
}
new index = get_param(1);
// Return if invalid rank index was given.
if(index < 0 || index >= ArraySize(rankNames))
{
return;
}
new length = get_param(3);
// Return if invalid length was given.
if(!length)
{
return;
}
set_string(2, userData[index][dataRankName], length);
}
public native_get_rank_frags(plugin, params)
{
// Invalid amount of parameters.
if(params != 2)
{
return -1;
}
new index = get_param(1);
// Invalid index?
if(index < 0 || index >= ArraySize(rankNames))
{
return -1;
}
new which = get_param(2);
// Invalid index?
if(which < 0 || which > 2)
{
return -1;
}
return ArrayGetCell(rankFrags[which], index);
}
public ranks_get_ranks_count(plugin, params)
{
return ArraySize(rankNames);
}
stock registerCommands(const array[][], arraySize, function[])
{
#if !defined ForRange
#define ForRange(%1,%2,%3) for(new %1 = %2; %1 <= %3; %1++)
#endif
#if AMXX_VERSION_NUM > 183
ForRange(i, 0, arraySize - 1)
{
ForRange(j, 0, 1)
{
register_clcmd(fmt("%s %s", !j ? "say" : "say_team", array[i]), function);
}
}
#else
new newCommand[33];
ForRange(i, 0, arraySize - 1)
{
ForRange(j, 0, 1)
{
formatex(newCommand, charsmax(newCommand), "%s %s", !j ? "say" : "say_team", array[i]);
register_clcmd(newCommand, function);
}
}
#endif
}
#776238 [ROZWIĄZANE] [Problem] Rangi - wczytuje rangę po pierwszym fragu
Napisane przez Deus Vult
w 30.01.2023 15:48
Na pierwszy rzut oka wydaje mi się że zmienna bool powoduje problem, ustawia ci wartość connect = true co w skutku przerywa wykonywanie pętli w funkcji get_user_rank.
Nie kompilowałem, sprawdź to:
get_user_rank(index, bool:connect = false, bool:notify = true)
{
new userStats[8],
blank[8];
get_user_stats(index, userStats, blank);
// Update player's kills.
userData[index][dataKills] = userStats[0];
// Make sure player's rank is not bugged.
// If so, make it right.
if(userData[index][dataRank] >= ArraySize(rankNames))
{
userData[index][dataRank] = ArraySize(rankNames);
return;
}
new oldRank = userData[index][dataRank];
ForDynamicArray(i, rankNames)
{
// Break the loop if user kills is lower than required.
// Ranks should be sorted in ascending order, so if the player
// Has less kills than required, he's surely not gonna
// Get a rank higher than the one currently proccessed.
if(userStats[0] < ArrayGetCell(rankFrags[0], i))
{
break;
}
// Continue if he's got more kills than required.
if(userStats[0] > ArrayGetCell(rankFrags[1], i) && i < ArraySize(rankNames) - 1)
{
continue;
}
// Set new rank
userData[index][dataRank] = userData[index][dataRank] + 1 >= ArraySize(rankNames) ? ArraySize(rankNames) - 1 : i;
// Set kills required for the next rank.
userData[index][dataKillsRequired] = ArrayGetCell(rankFrags[1], userData[index][dataRank]);
// Update user rank name.
ArrayGetString(rankNames, userData[index][dataRank], userData[index][dataRankName], MAX_RANK_NAME_LENGTH);
// We dont want to show messages when getting the rank for the first time.
// Break the loop if player's rank was not updated.
if(userData[index][dataRank] <= oldRank)
{
break;
}
// Format messages if enabled.
if(notify)
{
new message[2 << 7];
formatex(message, charsmax(message), "%s^x01 Awansowales na range ^"^x03%s^x01^".", chatPrefix, userData[index][dataRankName]);
if(userData[index][dataRank] + 1 >= ArraySize(rankNames))
{
format(message, charsmax(message), "%s Nastepna ranga:^x03 Brak^x01.", message);
}
else
{
new nextrankNames[MAX_RANK_NAME_LENGTH],
nextRankFrags[2];
ArrayGetString(rankNames, userData[index][dataRank] + 1, nextrankNames, charsmax(nextrankNames));
nextRankFrags[0] = ArrayGetCell(rankFrags[0], userData[index][dataRank] + 1);
nextRankFrags[1] = ArrayGetCell(rankFrags[1], userData[index][dataRank] + 1);
format(message, charsmax(message), "%s Nastepna ranga: ^"^x03%s^x01^" (^x03%i^x01 - ^x03%i^x01).", message, nextrankNames, nextRankFrags[0], nextRankFrags[1]);
}
if(!connect) ColorChat(index, RED, message);
}
// Inform other plugins about player ranking up.
ExecuteForward(forwardRankUp, _, index, userData[index][dataRank]);
// No need to do another iteration.
break;
}
}
#776218 [ROZWIĄZANE] [Problem] Poprawne zliczanie ilości rozegranych rund przez VIP
Napisane przez PANDA_2zl
w 28.01.2023 19:53
Możesz zrobić bez tworzenia include tylko w jednym rejestrujesz natywy a w drugim pobierasz dodając je na początku pluginu, plugin pobierający coś z drugiego pluginu wtedy musi być wpisany niżej niż drugi w plugins.ini
- AMXX.pl: Support AMX Mod X i SourceMod
- → Przeglądanie profilu: Reputacja: Aramis
- Regulamin


Dodatki SourceMod



Moja zawartość



