←  Problemy

AMXX.pl: Support AMX Mod X i SourceMod

»

US Military Mod - prośba o przerobienie ;)

Zablokowany

PEREF - zdjęcie PEREF 09.05.2008

Link do pluginu: http://forums.allied... ... ht=bf2 mod

SMA:

#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define MAXCLASSES 27

new PlayerXP[33];
new PlayerLevel[33];
new PlayerKills[33]
new <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill, g_vault, SaveXP;

new const CLASSES[MAXCLASSES][] = {
	"Private",
	"Private 1st Class",
	"Specialist",
	"Corporal",
	"Sergant",
	"Staff Sergeant",
	"Sergeant 1st Class",
	"Master Sergeant",
	"1st Sergeant",
	"Sergeant Major",
	"Command Sergeant Major",
	"Sergeant Major Of The Army",
	"Warrant Officer",
	"Chief Warrant Officer[1]",
	"Chief Warrant Officer[2]",
	"Chief Warrant Officer[3]",
	"Master Chief Warrant Officer",
	"2nd Lieutenant",
	"1st Lieutenant",
	"Captian",
	"Major",
	"Lieutenant Colonel",
	"Colonel",
	"Brigadier General",
	"Major General",
	"Lieutenant General",
	"General"
};

new const LEVELS[26] = {
	25,
	50,
	75,
	100,
	150,
	200,
	250,
	300,
	400,
	500,
	600,
	800,
	1000,
	1200,
	1400,
	1600,
	1800,
	2000,
	2500,
	3000,
	3500,
	4000,
	5500,
	6000,
	7000,
	8000
};

public plugin_init()
{
	register_plugin("Rank Mod", "1.00", "Robert aka Wicked");
	
	//CVAR line, adds a cvar command to the plugin (on/off)
	register_cvar("sv_rankmod", "1");
	
	register_event("DeathMsg", "eDeath", "a");
	register_clcmd("say /rank","ShowHud")
	register_clcmd("say /resetxp","client_disconnect")
	
	SaveXP = register_cvar("SaveXP","1");
	<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill=register_cvar("XP_per_kill", "1");
	g_vault = nvault_open("VAULT");
}

public SaveData(id)
{
	new AuthID[35];
	get_user_authid(id,AuthID,34);
	
	new vaultkey[64],vaultdata[256];
	format(vaultkey,63,"%s-Rank Mod",AuthID);
	format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerKills[id]);
	nvault_set(g_vault,vaultkey,vaultdata);
	return PLUGIN_CONTINUE;
}

public LoadData(id)
{
	new authid[35];
	get_user_authid(id,authid,34);
	
	new vaultkey[64],vaultdata[256];
	format(vaultkey,63,"%s-Rank Mod",authid);
	format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerKills[id]);
	nvault_get(g_vault,vaultkey,vaultdata,255);
	
	replace_all(vaultdata, 255, "#", " ");
	
	new playerxp[32], playerlevel[32],playerkills[32];
	
	parse(vaultdata, playerxp, 31, playerlevel, 31, playerkills, 31);
	
	PlayerXP[id] = str_to_num(playerxp);
	PlayerLevel[id] = str_to_num(playerlevel);
	PlayerKills[id] = str_to_num(playerkills);
	
	return PLUGIN_CONTINUE;
}

//Loads Class, Level, and <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> connect
public client_connect(id)
{
	if(get_pcvar_num(SaveXP) == 1)
	{
		
		LoadData(id);
	}
}

//Saves <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> on disconnect
public client_disconnect(id)
{
	if(get_pcvar_num(SaveXP) == 1)
	{
		
		SaveData(id);
	}
	PlayerXP[id] = 0;
	PlayerLevel[id] = 0;
	PlayerKills[id] = 0;
	
	if(is_user_connected(id))
		client_print(id,print_chat,"Saved Data Erased")
	
}

public eDeath(  ) 
{
	new attacker = read_data( 1 )
	new <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> = get_pcvar_num(<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill)
	
	
	client_print(attacker,print_chat,"You Gained %i <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> for your kill!",<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />)
	PlayerKills[attacker] += 1
	PlayerXP[attacker] += <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />
	
	if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
	{
		PlayerLevel[attacker] += 1;
		client_print(attacker,print_chat,"You have been promoted have a nice day %s ",CLASSES[PlayerLevel[attacker]])
	}
	ShowHud(attacker);
	SaveData(attacker);
}

public ShowHud(id)
{
	set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0);
	show_hudmessage(id, "Rank: %s^nKills: %i^nXP: %i/%i",CLASSES[PlayerLevel[id]],PlayerKills[id],PlayerXP[id],LEVELS[PlayerLevel[id]]);
}  

Zmiany jakie chciałbym wprowadzić w tym pluginie:

- zmiana menu, które wyświetla informacje o fragach i ranku w hudzie na czerwono na taki o to mniej więcej pasek (patrz dolny lewy rog na onrazku niżej)
Dołączona grafika
pasek tego pluginu wyglądał by mniej więcej tak : [uS]Fragi: 0/15 Stopień: bleble, no i ewetualnie xP ale myślę, że to zbędne.

- po wpisaniu przykładowo /topranks wyświetla się motd, w którym jest top10/15 graczy którzy mają najwyższy stopień

Na chwilę obecną to wszystko, jeśli jest to do zrobienia to bardzo proszę o pomoc ;)

Pozdrawiam.
Odpowiedz

  • +
  • -
Salamon - zdjęcie Salamon 09.05.2008

co do tego pasku zamiast hudmessage to zamiast tego:
public ShowHud(id)
{
    set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0);
    show_hudmessage(id, "Rank: %s^nKills: %i^nXP: %i/%i",CLASSES[PlayerLevel[id]],PlayerKills[id],PlayerXP[id],LEVELS[PlayerLevel[id]]);
}
dajesz to:

public ShowHud(id)
{
    new cus[51] 
    formatex(cus, 50, "Rank: %s^nKills: %i^nXP: %i/%i",CLASSES[PlayerLevel[id]],PlayerKills[id],PlayerXP[id],LEVELS[PlayerLevel[id]]) 

    message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, id) 
    write_byte(0) 
    write_string(cus) 
    message_end() 
}

powinno zadzialac :)
Odpowiedz

PEREF - zdjęcie PEREF 10.05.2008

too many errors przy kompilacji ;)
Odpowiedz

  • +
  • -
Salamon - zdjęcie Salamon 10.05.2008

ahh :P czekaj bo jedna linijke trzeba dopisac na gorze (tu juz wpisane;P)

#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define MAXCLASSES 27

new PlayerXP[33];
new PlayerLevel[33];
new PlayerKills[33]
new <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill, g_vault, SaveXP;
new g_msgStatusText

new const CLASSES[MAXCLASSES][] = {
    "Private",
    "Private 1st Class",
    "Specialist",
    "Corporal",
    "Sergant",
    "Staff Sergeant",
    "Sergeant 1st Class",
    "Master Sergeant",
    "1st Sergeant",
    "Sergeant Major",
    "Command Sergeant Major",
    "Sergeant Major Of The Army",
    "Warrant Officer",
    "Chief Warrant Officer[1]",
    "Chief Warrant Officer[2]",
    "Chief Warrant Officer[3]",
    "Master Chief Warrant Officer",
    "2nd Lieutenant",
    "1st Lieutenant",
    "Captian",
    "Major",
    "Lieutenant Colonel",
    "Colonel",
    "Brigadier General",
    "Major General",
    "Lieutenant General",
    "General"
};

new const LEVELS[26] = {
    25,
    50,
    75,
    100,
    150,
    200,
    250,
    300,
    400,
    500,
    600,
    800,
    1000,
    1200,
    1400,
    1600,
    1800,
    2000,
    2500,
    3000,
    3500,
    4000,
    5500,
    6000,
    7000,
    8000
};

public plugin_init()
{
    register_plugin("Rank Mod", "1.00", "Robert aka Wicked");
   
    //CVAR line, adds a cvar command to the plugin (on/off)
    register_cvar("sv_rankmod", "1");
   
    register_event("DeathMsg", "eDeath", "a");
    register_clcmd("say /rank","ShowHud")
    register_clcmd("say /resetxp","client_disconnect")
   
    SaveXP = register_cvar("SaveXP","1");
    <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill=register_cvar("XP_per_kill", "1");
    g_vault = nvault_open("VAULT");
    g_msgStatusText = get_user_msgid("StatusText")
}

public SaveData(id)
{
    new AuthID[35];
    get_user_authid(id,AuthID,34);
   
    new vaultkey[64],vaultdata[256];
    format(vaultkey,63,"%s-Rank Mod",AuthID);
    format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerKills[id]);
    nvault_set(g_vault,vaultkey,vaultdata);
    return PLUGIN_CONTINUE;
}

public LoadData(id)
{
    new authid[35];
    get_user_authid(id,authid,34);
   
    new vaultkey[64],vaultdata[256];
    format(vaultkey,63,"%s-Rank Mod",authid);
    format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerKills[id]);
    nvault_get(g_vault,vaultkey,vaultdata,255);
   
    replace_all(vaultdata, 255, "#", " ");
   
    new playerxp[32], playerlevel[32],playerkills[32];
   
    parse(vaultdata, playerxp, 31, playerlevel, 31, playerkills, 31);
   
    PlayerXP[id] = str_to_num(playerxp);
    PlayerLevel[id] = str_to_num(playerlevel);
    PlayerKills[id] = str_to_num(playerkills);
   
    return PLUGIN_CONTINUE;
}

//Loads Class, Level, and <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> connect
public client_connect(id)
{
    if(get_pcvar_num(SaveXP) == 1)
    {
       
        LoadData(id);
    }
}

//Saves <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> on disconnect
public client_disconnect(id)
{
    if(get_pcvar_num(SaveXP) == 1)
    {
       
        SaveData(id);
    }
    PlayerXP[id] = 0;
    PlayerLevel[id] = 0;
    PlayerKills[id] = 0;
   
    if(is_user_connected(id))
        client_print(id,print_chat,"Saved Data Erased")
   
}

public eDeath(  )
{
    new attacker = read_data( 1 )
    new <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> = get_pcvar_num(<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill)
   
   
    client_print(attacker,print_chat,"You Gained %i <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> for your kill!",<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />)
    PlayerKills[attacker] += 1
    PlayerXP[attacker] += <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />
   
    if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
    {
        PlayerLevel[attacker] += 1;
        client_print(attacker,print_chat,"You have been promoted have a nice day %s ",CLASSES[PlayerLevel[attacker]])
    }
    ShowHud(attacker);
    SaveData(attacker);
}

public ShowHud(id)
{
    new cus[51]
    formatex(cus, 50, "Rank: %s^nKills: %i^nXP: %i/%i",CLASSES[PlayerLevel[id]],PlayerKills[id],PlayerXP[id],LEVELS[PlayerLevel[id]])

    message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, id)
    write_byte(0)
    write_string(cus)
    message_end()
}
Odpowiedz

PEREF - zdjęcie PEREF 12.05.2008

no teraz nie ma błędu przy kompilacji i pasek działa, ale jeszcze coś trzeba zmienić.

- pasek wyświetla się tylko gdy zabijemy przeciwnika lub wpiszemy /rank na kilka sekund, a ja chciałbym, żeby był przez cały czas wyświetlany.

-
public ShowHud(id)
{
    new cus[51]
    formatex(cus, 50, "[uS][Military] Ranga: %s Fragi: %i/%i",CLASSES[PlayerLevel[id]],PlayerXP[id],LEVELS[PlayerLevel[id]]) 

    message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, id)
    write_byte(0)
    write_string(cus)
    message_end()
}

Chciałbym aby na pasku pierwsze były fragi, a potem ranga, gdy zamieniałem je miejscami pasek wariował tj. zamiast rangi były wyświetlane jakieś pierdolniki, fragi też nie działały prawidłowo zamiast np. 25/50 fragow to bylo 50/25 ;)

Aktualnie sma wygląda tak:

#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define MAXCLASSES 27

new PlayerXP[33];
new PlayerLevel[33];
new PlayerKills[33]
new <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill, g_vault, SaveXP;
new g_msgStatusText

new const CLASSES[MAXCLASSES][] = {
     "Rekrut",
     "Szeregowy",
     "Starszy Szeregowy",
     "Mlodszy Kapral",
     "Kapral",
     "Starszy Kapral",
     "Plutonowy",
     "Sierzant",
     "Sierzant Sztabowy",
     "Sierzant Broni",
     "Starszy Sierzant",
     "Pierwszy Sierzant",
     "Starszy Sierzant Broni",
     "Sierzant Major",
     "Podchorazy",
     "Chorazy",
     "Podporucznik",
     "Porucznik",
     "Kapitan",
     "Major",
     "Podpulkownik",
     "Pulkownik",
     "General Brygady",
     "General Major",
     "General Porucznik",
     "General",
     "Marszalek"
};

new const LEVELS[26] = {
    50,
    100,
    150,
    200,
    250,
    300,
    350,
    400,
    450,
    500,
    600,
    800,
    1000,
    2000,
    3000,
    4000,
    5000,
    6000,
    7000,
    8000,
    10000,
    12000,
    14000,
    16000,
    18000,
    20000
};

public plugin_init()
{
    register_plugin("Military", "1.00", "SEARCHER");
   
    //CVAR line, adds a cvar command to the plugin (on/off)
    register_cvar("sv_rankmod", "1");
   
    register_event("DeathMsg", "eDeath", "a");
    register_clcmd("say /rank","ShowHud")
   
    SaveXP = register_cvar("SaveXP","1");
    <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill=register_cvar("XP_per_kill", "1");
    g_vault = nvault_open("VAULT");
    g_msgStatusText = get_user_msgid("StatusText")
}

public SaveData(id)
{
    new AuthID[35];
    get_user_authid(id,AuthID,34);
   
    new vaultkey[64],vaultdata[256];
    format(vaultkey,63,"%s-Rank Mod",AuthID);
    format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerKills[id]);
    nvault_set(g_vault,vaultkey,vaultdata);
    return PLUGIN_CONTINUE;
}

public LoadData(id)
{
    new authid[35];
    get_user_authid(id,authid,34);
   
    new vaultkey[64],vaultdata[256];
    format(vaultkey,63,"%s-Rank Mod",authid);
    format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerKills[id]);
    nvault_get(g_vault,vaultkey,vaultdata,255);
   
    replace_all(vaultdata, 255, "#", " ");
   
    new playerxp[32], playerlevel[32],playerkills[32];
   
    parse(vaultdata, playerxp, 31, playerlevel, 31, playerkills, 31);
   
    PlayerXP[id] = str_to_num(playerxp);
    PlayerLevel[id] = str_to_num(playerlevel);
    PlayerKills[id] = str_to_num(playerkills);
   
    return PLUGIN_CONTINUE;
}

//Loads Class, Level, and <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> connect
public client_connect(id)
{
    if(get_pcvar_num(SaveXP) == 1)
    {
       
        LoadData(id);
    }
}

//Saves <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> on disconnect
public client_disconnect(id)
{
    if(get_pcvar_num(SaveXP) == 1)
    {
       
        SaveData(id);
    }
    PlayerXP[id] = 0;
    PlayerLevel[id] = 0;
    PlayerKills[id] = 0;
   
    if(is_user_connected(id))
        client_print(id,print_chat,"Saved Data Erased")
   
}

public eDeath(  )
{
    new attacker = read_data( 1 )
    new <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' /> = get_pcvar_num(<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_Kill)
   
   
    PlayerKills[attacker] += 1
    PlayerXP[attacker] += <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />
   
    if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
    {
        PlayerLevel[attacker] += 1;
        client_print(attacker,print_chat,"Gratulacje! Zdobyles wyzsza range %s ",CLASSES[PlayerLevel[attacker]])
    }
    ShowHud(attacker);
    SaveData(attacker);
}

public ShowHud(id)
{
    new cus[51]
    formatex(cus, 50, "[uS][Military] Ranga: %s Fragi: %i/%i",CLASSES[PlayerLevel[id]],PlayerXP[id],LEVELS[PlayerLevel[id]]) 

    message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, id)
    write_byte(0)
    write_string(cus)
    message_end()
}



Pozdrawiam ;)
Odpowiedz

  • +
  • -
Salamon - zdjęcie Salamon 12.05.2008

by najpierw byly fragi a pozniej ranga uzyj tego
public ShowHud(id)
{
    new cus[51]
    formatex(cus, 50, "[uS][Military] Fragi %i/%i Ranga: %s ",PlayerXP[id],LEVELS[PlayerLevel[id]],CLASSES[PlayerLevel[id]])

    message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, id)
    write_byte(0)
    write_string(cus)
    message_end()
}

co do tego ze pokazuje mowiac /rank lub po smierci, tak jest w pluginie standardowo, zeby to zmienic za bardzo obciazylbym kod, tzn zrobilbym tak ze zaczeloby zrec wiecej cp
Odpowiedz

PEREF - zdjęcie PEREF 12.05.2008

Salomon ten kod co dałeś zadziałał. Jednak wolałbym żeby ten pasek był wyświetlany przez cały czas, nawet kosztem tego PC.

Daje ci kod który może ułatwi Ci to. Jest to zawartość pliku hud.inl pluginu bf2rank mod. Pewnie jest tu gdzieś wzmianka o tym ;)

//Bf2 Rank Mod HUD File
//Contains all the HUD functions.


#if defined bf2_hud_included
  #endinput
#endif
#define bf2_hud_included

//Show an announcement display

public Announcement(id)
{
	if (!get_pcvar_num(g_bf2_active))
		return;	
	
	client_print(id, print_chat, "[BF2]This server is running Battlefield 2 Rank mod. Say /bf2menu for more Info")
}

//Prepares Information for the hud to be shown

public ShowHUD(id) 
{ 
	if (!get_pcvar_num(g_bf2_active) || !is_user_alive(id))
		return;	

	new rank=g_PlayerRank[id];

	switch (rank)
	{
		case 16,19,20: rank=15;
		case 17: rank=7;
		case 18: rank=8;
	}

	nextrank[id]=floatround(float(RANKXP[(rank+1)])*get_pcvar_float(g_<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/tongue2.gif' class='bbc_emoticon' alt='xP' />_multiplier))

	DisplayHUD(id)
		
	return;
}

//Displays the HUD to the user

public DisplayHUD(id)
{
	if (!is_user_alive(id) || is_user_bot(id))
		return;

	new HUD[64]
	
	if (!get_pcvar_num(g_badges_active))
	{
		format(HUD, 63, "[BF2]Points: %d/%d Rank: %s ",totalkills[id],nextrank[id],RANKS[g_PlayerRank[id]])
		message_begin(MSG_ONE_UNRELIABLE, gmsgStatusText, {0,0,0}, id) 
		write_byte(0) 
		write_string(HUD)
		message_end()
	}
	else
	{	
		format(HUD, 63, "[BF2]Points: %d/%d Badges: %d Rank: %s ",totalkills[id],nextrank[id],numofbadges[id],RANKS[g_PlayerRank[id]])
		message_begin(MSG_ONE_UNRELIABLE, gmsgStatusText, {0,0,0}, id) 
		write_byte(0) 
		write_string(HUD)
		message_end()
	}


}

Pozdrawiam.
Odpowiedz
Zablokowany