davidto1995
|
分享:
▼
x0
|
[1.6] 求救!!!
進能幫我修理..不知道要什麼問題/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <nvault> #define MAXCLASSES 100 #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" new PlayerXP[33],PlayerLevel[33],PlayerClass[33] //these are for special kills new XP_Kill,XP_Knife,XP_Hs,SaveXP //this is for Nvault. so that We can save XP new g_vault new const CLASSES[MAXCLASSES][] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99" } new const LEVELS[99] = { 0, 50,//this means you need 100 xp 100,//this means you need 200 xp 150,//this means you need 400 xp 200,//so on 250,//so on 300,//so on 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000,//21 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000,//31 2150, 2300, 2450, 2600, 2750, 2900, 3050,//38 3250, 3450, 3650, 3850, 4050,//43 4300, 4550, 4800, 5050, 5350, 5650, 5950, 6250,//51,300 6600,//350 6950, 7300,//54,400 7700, 8100, 8100,//450 8550, 9000, 9500, 10000,//550 10550, 11000,//600 11600, 12200,//650 12850, 13500,//700 14200, 14950,//750 15700,//800 16500,//850 17350, 18250,//950 19200,//1000,74,Up100 19300,//Up200 19500, 19800,//300 20100, 20500, 21000, 21600, 22300, 23100, 24000, 25000,//85,x000+x00 26100, 27300, 28600, 30000, 31500, 33100,//91,Up1700 34800, 36600, 38500, 40500,//95,Up2100 42600, 44800, 47100, 49500 } public plugin_init() { register_plugin("level system","v1.0","Esai<David>") //we need this to check your level after you kill some one register_event("DeathMsg", "eDeath", "a") //is saving on? SaveXP = register_cvar("SaveXP","1") //how many xp are u gonna get per kill? XP_Kill=register_cvar("XP_per_kill", "1") //if you get a hs you get bonus xp XP_Hs=register_cvar("XP_hs_bonus","1") //if you make a knife kill you get bounus xp XP_Knife=register_cvar("XP_knife_bonus","5") //we just opened a new connection NVAULT connection // we will call it animod g_vault = nvault_open("lvmod") // register a say command to change class register_clcmd("say /level", "ChangeClass") register_clcmd("say_team /level", "ChangeClass") //show how much xp you have register_clcmd("say /xp", "ShowHud") register_clcmd("say_team /xp", "ShowHud") } public eDeath( ) //function name { // If the player's Class is nothing, then dont bother to do any of the below if(PlayerClass[attacker] == 0) return PLUGIN_CONTINUE // We create the victim variable, so that this function can check // if a player was killed new iVictim = read_data( 2 ) // If a player was killed by a HeadShot, this will be used for the cvar Xp_Hs new headshot = read_data( 3 ) //which weapon was used new clip, ammo, weapon = get_user_weapon(id,clip,ammo); PlayerXP[attacker] += get_pcvar_num(XP_Kill) // used for the xp_hs cvar // it checks if the victim was killed by a headshot if(headshot) // give him/her bonus xp PlayerXP[attacker] += get_pcvar_num(XP_Hs) // checks if the victim was killed by a knife if(weapon == CSW_KNIFE) //give him/her bonus xp PlayerXP[attacker] += get_pcvar_num(XP_Knife) // this checks if the player has enough xp to advance to a new level while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) { // this will create the Congratulations message. client_print(attacker, print_chat, "[Esai<David> LevelSystem] Your level: %i %s!",PlayerLevel[attacker],CLASSES[PlayerClass[attacker]]) // Add his/her level PlayerLevel[attacker] += 1 } // shows his level on a hud message ShowHud(attacker) } public ShowHud(id) { set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0) show_hudmessage(id, "Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]]) } public Class_Handle(id , menu , item) { if(item == MENU_EXIT) { menu_destroy(menu); } new szCommand[6] , szName[64]; new access , callback; menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback); new i = str_to_num(szCommand) if(PlayerClass[id] != i) { PlayerClass[id] = i client_print(id,print_chat,"You are now a %s",CLASSES ) } else { client_print(id,print_chat,"You are alredy a %s",CLASSES) } menu_destroy(menu); return PLUGIN_CONTINUE }
public client_connect(id) { // Only does it if xp saving is on if(get_pcvar_num(SaveXP) == 1) { // load your player data LoadData(id) } }
public client_disconnect(id) { // Only does it if xp saving is on if(get_pcvar_num(SaveXP) == 1) { // lets save the data SaveData(id) } }
public SaveData(id) { // get the players steam id. We need this because we are saving by steam id new AuthID[35] get_user_authid(id,AuthID,34) new vaultkey[64],vaultdata[256] // format wat is going to be in the level mod vault file format(vaultkey,63,"%s-Mod",AuthID) format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]) // save the data 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] // search format(vaultkey,63,"%s-Mod",AuthID) format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]) // load the data nvault_get(g_vault,vaultkey,vaultdata,255) replace_all(vaultdata, 255, "#", " ") new playerxp[32], playerlevel[32] parse(vaultdata, playerxp, 31, playerlevel, 31) PlayerXP[id] = str_to_num(playerxp) PlayerLevel[id] = str_to_num(playerlevel) return PLUGIN_CONTINUE }
|