Ogólnie to przykład jest źle, ale mam nadzieję, że myśl dobra. Coś tam próbowałem zrobić, ale standardowo masa (zapewnie głupich) błędów
Stworzyłem menu, w którym po wejściu na serwer będzie możliwośc wybrania pozycji menu, coś mi się też zdaje, że w złych miejscach te floaty wprowadziłem, ale mniejsza. Nie mam pojęcia, jaką funkcją odwołać się do (akurat tutaj) coordx lub coordy, ja próbowałem floatstr ale coś nie wyszło... może już Ci bardziej obeznani pomogą
#include <amxmodx>
#include <amxmisc>
#include <csx>
#define PLUGIN "HUD"
#define AUTHOR " glut // edit Marcin"
#define VERSION "1.0"
new gVotemenu;
new float:coordx;
new float:coordy;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /hudmenu", "hudmenu")
gVotemenu=menu_create ("Z ktorej strony chcesz miec HUD?", "cVotemenu");
menu_additem(gVotemenu,"Lewej");
menu_additem(gVotemenu,"Po srodku");
menu_additem(gVotemenu,"Prawej");
}
public client_putinserver(id)
{
set_task(0.1, "pokaz_hud", id,_,_,"b");
menu_display(id, gVotemenu, 0);
}
public hudmenu(id)
menu_display(id, gVotemenu, 0);
public cVotemenu(id, menu, item){
switch(item){
case 0:{
coordx = 0.2
coordy = 0.3
}
case 1:{
coordx = -1.0
coordy = 0.05
}
case 2:{
coordx = 0.8
coordy = 0.3
}
}
}
public pokaz_hud(id)
{
new stats[8],bodyhits[8],rankpos,rankmax;
rankpos = get_user_stats(id, stats, bodyhits)
rankmax = get_statsnum()
new izStats[ 8 ], izBody[ 8 ];
new szData[10];
get_time( "%X", szData, 9 );
new hp = get_user_health(id)
new ar = get_user_armor(id)
new rank = get_user_stats( id, izStats, izBody )
new fragi = get_user_frags(id)
new dedy = get_user_deaths(id)
new czas_mapy = get_timeleft()
new name[32]
get_user_name(id, name, 31)
if(is_user_connected(id))
{
set_hudmessage(255, 255, 0, floatstr(coordx), floatstr(coordy), 0, 0.0, 0.3, 0.0, 0.0);
show_hudmessage(id, "[Nick: %s]^n[Zycie: %i | Armor: %i]^n[Fragi: %i | Zginiecia: %i]^n[Rank: %d/%d]^n[Forum: www-cs-SopliCa.com]",name,hp, ar, fragi, dedy, rankpos, rankmax)
}
else
{
remove_task(id)
}
return PLUGIN_HANDLED
}
Ale myślę, że można by spróbować innym sposobem, czyli zamiast deklarować floaty na początku to tylko 1 zmienną, później dane opcje w menu by miały swój "id" (np po srodku = 3), a później zabawa z ifami.
///edit
Jak już zacząłem to już skończe
To mi już normalnie skompilowało (nie licząc już tych Twoich powiadomień, które były)
#include <amxmodx>
#include <amxmisc>
#include <csx>
#define PLUGIN "HUD"
#define AUTHOR " glut // edit Marcin"
#define VERSION "1.0"
new gVotemenu;
new coord;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /hudmenu", "hudmenu")
gVotemenu=menu_create ("Z ktorej strony chcesz miec HUD?", "cVotemenu");
menu_additem(gVotemenu,"Lewej");
menu_additem(gVotemenu,"Po srodku");
menu_additem(gVotemenu,"Prawej");
}
public client_putinserver(id)
{
set_task(0.1, "pokaz_hud", id,_,_,"b");
menu_display(id, gVotemenu, 0);
}
public hudmenu(id)
menu_display(id, gVotemenu, 0);
public cVotemenu(id, menu, item){
switch(item){
case 0:{
coord = 1
}
case 1:{
coord = 2
}
case 2:{
coord = 3
}
}
}
public pokaz_hud(id)
{
new stats[8],bodyhits[8],rankpos,rankmax;
rankpos = get_user_stats(id, stats, bodyhits)
rankmax = get_statsnum()
new izStats[ 8 ], izBody[ 8 ];
new szData[10];
get_time( "%X", szData, 9 );
new hp = get_user_health(id)
new ar = get_user_armor(id)
new rank = get_user_stats( id, izStats, izBody )
new fragi = get_user_frags(id)
new dedy = get_user_deaths(id)
new czas_mapy = get_timeleft()
new name[32]
get_user_name(id, name, 31)
if(is_user_connected(id)){
if(coord == 1){
set_hudmessage(255, 255, 0, 0.2, 0.3, 0, 0.0, 0.3, 0.0, 0.0);
show_hudmessage(id, "[Nick: %s]^n[Zycie: %i | Armor: %i]^n[Fragi: %i | Zginiecia: %i]^n[Rank: %d/%d]^n[Forum: www-cs-SopliCa.com]",name,hp, ar, fragi, dedy, rankpos, rankmax)
}
if(coord == 2){
set_hudmessage(255, 255, 0, -1.0, 0.05, 0, 0.0, 0.3, 0.0, 0.0);
show_hudmessage(id, "[Nick: %s]^n[Zycie: %i | Armor: %i]^n[Fragi: %i | Zginiecia: %i]^n[Rank: %d/%d]^n[Forum: www-cs-SopliCa.com]",name,hp, ar, fragi, dedy, rankpos, rankmax)
}
if(coord == 3){
set_hudmessage(255, 255, 0, 0.8, 0.3, 0, 0.0, 0.3, 0.0, 0.0);
show_hudmessage(id, "[Nick: %s]^n[Zycie: %i | Armor: %i]^n[Fragi: %i | Zginiecia: %i]^n[Rank: %d/%d]^n[Forum: www-cs-SopliCa.com]",name,hp, ar, fragi, dedy, rankpos, rankmax)
}
}
else
{
remove_task(id)
}
return PLUGIN_HANDLED
}
Użytkownik `NN edytował ten post 06.11.2012 00:00