Kod:
#include <amxmodx>
#include <reapi>
new HudColor[MAX_CLIENTS + 1][3], bool:Random[MAX_CLIENTS + 1];
new SyncHud1;
new const sColors[][][] = {
{ "Renk Adı", 0, 0, 0 }, // R G B
{ "Kırmızı", 255, 0, 0 },
{ "Mavi", 0, 0, 255 },
{ "Yeşil", 0, 255, 0 },
{ "Beyaz", 255, 255, 255 },
};
public plugin_init() {
register_plugin("ReAPI Speedometer", "1.0", "EmirCW");
register_clcmd("say /speed", "@sSpeedometer");
register_clcmd("say /speedmenu", "@sSpeedometer");
new ent = rg_create_entity("info_target");
set_entvar(ent, var_nextthink, get_gametime() + 1.01);
SetThink(ent, "@ent_think");
SyncHud1 = CreateHudSyncObj();
for (new i = 1; i <= MAX_CLIENTS; i++) {
HudColor[i][0] = 255;
HudColor[i][1] = 255;
HudColor[i][2] = 255;
}
}
@sSpeedometer(const IP_IDs) {
new iMenu = menu_create("Hız Göstergesi Ayarları", "@sSpeedometer_");
menu_additem(iMenu, "\r• \wRengarenk Yap", "31");
for (new i = 1; i < sizeof(sColors); i++) {
menu_additem(iMenu, fmt("\r• \w%s", sColors[i][0]), fmt("%i", i));
}
menu_setprop(iMenu, MPROP_EXITNAME, "Kapat");
menu_display(IP_IDs, iMenu);
}
@sSpeedometer_(const IP_IDs, const iMenu, const iItem) {
if (iItem == MENU_EXIT) {
menu_destroy(iMenu);
return PLUGIN_HANDLED;
}
new szKey[6];
menu_item_getinfo(iMenu, iItem, _, szKey, charsmax(szKey));
new key = str_to_num(szKey);
if (key == 31) {
Random[IP_IDs] = true;
} else {
Random[IP_IDs] = false;
HudColor[IP_IDs][0] = sColors[key][1][0];
HudColor[IP_IDs][1] = sColors[key][2][0];
HudColor[IP_IDs][2] = sColors[key][3][0];
}
menu_destroy(iMenu);
return PLUGIN_HANDLED;
}
@ent_think(const ent) {
static Float:velocity[3], Float:speed;
for (new IP_IDs = 1; IP_IDs <= MaxClients; IP_IDs++) {
if (is_user_connected(IP_IDs)) {
get_entvar(IP_IDs, var_velocity, velocity);
speed = vector_length(velocity);
if (Random[IP_IDs]) {
set_hudmessage(random_num(0, 255), random_num(0, 255),random_num(0, 255), -1.0, 0.85, 0, 6.0, 1.1, 0.0, 0.0, -1);
ShowSyncHudMsg(IP_IDs, SyncHud1, "%3.2f hiz", speed);
} else {
set_hudmessage(HudColor[IP_IDs][0], HudColor[IP_IDs][1], HudColor[IP_IDs][2], -1.0, 0.85, 0, 6.0, 1.1, 0.0, 0.0, -1);
ShowSyncHudMsg(IP_IDs, SyncHud1, "%3.2f hiz", speed);
}
}
}
set_entvar(ent, var_nextthink, get_gametime() + 0.1);
}