Senior Member
|
02-11-2008
, 10:20
Re: USM Mod
|
#13
|
If i change the PlayerXP array into a 2d array, wont PlayerLevel need to change to a 2d array too?
Ok, I think I got this, could someone plz check over the load and save data functions? Im not that familar with nVault, or saving anything really.
PHP Code:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Credits: * * Most credit goes to the guy that helped me the * * most, fxfighter. Thank you so much =D. * * I also give credit to Black Rose for helping me * * out with the 3-D array, thanks ;) * * * * I hope you all enjoy this mod as much as I had * * fun making it. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <amxmodx> #include <amxmisc> #include <nvault> #define MAXRANKS 27 new PlayerClass[33] new PlayerXP[3][33] new PlayerLevel[3][33] new XP_Kill, g_vault, SaveXP, ModOn new const CLASSES[] = {"None", "US Army", "US Marines", "US Navy"} new const RANKS[][][] = { { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "Private", "Private 1st Class", "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]", "Chief Warrant Officer[4]", "2nd Lieutenant", "1st Lieutenant", "Captian", "Major", "Lieutenant Colonel", "Colonel", "Brigadier General", "Major General", "Lieutenant General", "General", "General of the Army" }, { "Private 1st Class", "Lance Corporal", "Corporal", "Sergeant", "Staff Sergeant", "Gunnery Sergeant", "Master Sergeant", "1st Sergeant", "Sergeant Major", "Master Gunnery Sergeant", "Sergeant Major of the Marine Corps", "Warrant Officer", "Chief Warrant Officer[1]", "Chief Warrant Officer[2]", "Chief Warrant Officer[3]", "Chief Warrant Officer[4]", "2nd Lieutenant", "First Lieutenant", "Captain", "Major", "Lieutenant Colonel", "Colonel", "Brigadier General", "Major General", "Lieutenant General", "General", "" }, { "Seaman Apprentice", "Seaman", "Petty Officer 3rd Class", "Petty Officer 2nd Class", "Petty Officer 1st Class", "Chief Petty Officer", "Senior Chief Petty Officer", "Master Chief Petty Officer", "Command Master Chief Petty Officer", "Master Chief Petty Officer of the Navy", "USN Warrant Officer", "USN Chief Warrant Officer[1]", "USN Chief Warrant Officer[2]", "USN Chief Warrant Officer[3]", "USN Chief Warrant Officer[4]", "Ensign", "Lieutenant Junior Grade", "Lieutenant", "Lieutenant Commander", "Commander", "Captain", "Rear Admiral Lower Half", "Rear Admiral Upper Half", "Vice Admiral", "Admiral", "Fleet Admiral", "" } } new const LEVELS[] = { 25, 50, 75, 100, 150, 200, 250, 300, 400, 500, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2500, 3000, 3500, 4000, 5500, 6000, 8000, 10000 } public plugin_init() { register_plugin("US Military Mod", "1.00", "Robert aKa D]i[P Wicked") //CVAR line, adds a cvar command to the plugin (on/off) ModOn = register_cvar("usm_mod", "1") register_event("DeathMsg", "eDeath", "a") register_clcmd( "military_menu","ChooseClass") SaveXP = register_cvar("SaveXP","1") XP_Kill=register_cvar("XP_per_kill", "1") g_vault = nvault_open("VAULT") register_logevent("Round_start", 2, "1=Round_Start") register_event("ResetHUD", "HudReset", "b") } public HudReset(id) { ShowHud(id) } public Round_start() { new i for ( i = 0 ; i < 33 ; i ++ ) { if(is_user_connected(i) && PlayerClass[i] == 0) { ChooseClass(i) } } } public ChooseClass(id) { new menu = menu_create("\rChoose a Class!:", "menu_handler") menu_additem(menu, "\wUS Army", "1", 0) menu_additem(menu, "\wUS Marines", "2", 0) menu_additem(menu, "\wUS Navy", "3", 0) menu_setprop(menu, MPROP_EXIT, MEXIT_ALL) menu_display(id, menu, 0) } public menu_handler(id, menu, item) { if (item == MENU_EXIT) { menu_destroy(menu) } new data[6], iName[64] new access, callback menu_item_getinfo(menu, item, access, data,5, iName, 63, callback) new key = str_to_num(data) PlayerClass[id] = key client_print(id, print_chat, "Welcome to the %s maggot! Get out there and rank up!",CLASSES[PlayerClass[id]]) menu_destroy(menu) } public SaveData(id) { if(get_pcvar_num(ModOn) == 0) { return PLUGIN_HANDLED } new AuthID[35] get_user_authid(id,AuthID,34) new vaultkey[64],vaultdata[256] format(vaultkey,63,"%s-US Military Mod",AuthID) format(vaultdata,255,"%i#%i#%i#",PlayerClass[id],PlayerXP[PlayerClass[id]][id],PlayerLevel[PlayerClass[id]][id]) nvault_set(g_vault,vaultkey,vaultdata) return PLUGIN_CONTINUE } public LoadData(id) { if(get_pcvar_num(ModOn) == 0) { return PLUGIN_HANDLED } new authid[35] get_user_authid(id,authid,34) new vaultkey[64],vaultdata[256]; format(vaultkey,63,"%s-US Military Mod",authid) format(vaultdata,255,"%i#%i#%i#",PlayerClass[id],PlayerXP[PlayerClass[id]][id],PlayerLevel[PlayerClass[id]][id]) nvault_get(g_vault,vaultkey,vaultdata,255) replace_all(vaultdata, 255, "#", " ") new playerclass[32], playerxp[3][32], playerlevel[3][32] parse(vaultdata, playerclass, 31, playerxp, 2, 31, playerlevel, 2, 31) PlayerClass[id] = str_to_num(playerclass) PlayerXP[PlayerClass[id]][id] = str_to_num(playerxp[PlayerClass[id]]) PlayerLevel[PlayerClass[id]][id] = str_to_num(playerlevel[PlayerClass[id]]) return PLUGIN_CONTINUE } //Loads Class, Level, and XP connect public client_connect(id) { if(get_pcvar_num(SaveXP) == 1) { LoadData(id) } } //Saves XP on disconnect public client_disconnect(id) { if(get_pcvar_num(SaveXP) == 1) { SaveData(id) } new row, col for(row = 0; row < 3; row++) { for(col = 0; col < 33; col++) { PlayerXP[row][col] = 0 PlayerLevel[row][col] = 0 } } PlayerClass[id] = 0 } public eDeath( ) { new attacker = read_data( 1 ) if(PlayerClass[attacker] != 0) { PlayerXP[PlayerClass[attacker]][attacker] += get_pcvar_num(XP_Kill) client_print(attacker, print_chat, "+1 Kill", XP_Kill) if(PlayerXP[PlayerClass[attacker]][attacker] >= LEVELS[PlayerLevel[PlayerClass[attacker]][attacker]]) { PlayerLevel[PlayerClass[attacker]][attacker] += 1 client_print(attacker, print_chat, "You have just been promoted! You are now a %s", RANKS[PlayerClass[attacker]][PlayerLevel[PlayerClass[attacker]][attacker]]) } } ShowHud(attacker) SaveData(attacker) } public ShowHud(id) { set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0); show_hudmessage(id, "Class: %s^nRank: %s^nKills: %i/%i^n", CLASSES[PlayerClass[id]], RANKS[PlayerClass[id]][PlayerLevel[PlayerClass[id]][id]], PlayerXP[PlayerClass[id]][id], LEVELS[PlayerLevel[PlayerClass[id]][id]]); }
__________________
#Team !иکдиІтy
Last edited by >)SL(< | Wicked; 02-11-2008 at 12:16.
|
|