Raised This Month: $ Target: $400
 0% 

menu problems with xp based plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gzus
Member
Join Date: Jan 2007
Old 02-12-2007 , 20:45   menu problems with xp based plugin
Reply With Quote #1

i started with XunTric's animal mod xp based plugin. it took awhile to get it to compile, and actually save xp, still having trouble loading x after map chnge and such, but thats not the main issue i'm having, its actually the least of my worries at the moment. the big problem is the menu, i can not get the menu to work properly, when a user picks option 2, it says u picked option 1, option 1 works, but 3, and 4 do not.

I know the code is no where near clean, i've been tryin to learn reading tutorials and code snipits, but im actually lost now. it would be nice to have input on other things aswell, but my main concern is the menu, without this working correctly, the whole thing should just be scrapped.

for: cs 1.6
Code:
      Code:      <font face="monospace"><font color="#000000">[</font>code<font color="#000000">]//------------------------------------------------------------------------------------------- // //            based on XunTric's animal omd // //         modified for MosthatedOnline Servers // //           <a href="http://clan.mosthatedonline.com" target="_blank" rel="nofollow noopener">http://clan.mosthatedonline.com</a> //------------------------------------------------------------------------------------------- #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <vault> //#include <superheromod> #include <Vexd_Utilities> #include <engine> #define PLUGIN "mho_mod" #define VERSION "1.12" #define AUTHOR "Gzus" #define CLASS_NOTHING 0 #define CLASS_MUTANT 1 #define CLASS_ALIEN 2 #define CLASS_PREDATOR 3 #define CLASS_MACHINE 4 #define MAXCLASSES 5 //------------------------------------------------------------------------------------------- //new g_nightCrawlerTimer[33] new PlayerClass[33] new PlayerXP[33] new PlayerLevel[33] //------------------------------------------------------------------------------------------- new const CLASSES[MAXCLASSES][] = {     "Mutant",     "Alien",     "Predator",     "Machine",     "None" } //------------------------------------------------------------------------------------------- new msgtext //------------------------------------------------------------------------------------------- new const LEVELS[6] = {     100,     200,     400,     800,     1600,     3200 } //------------------------------------------------------------------------------------------- public plugin_init()     {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_cvar("SaveXP", "1")     register_cvar("sv_mhomod", "1")         register_event("DeathMsg", "DeathMsg", "ae")         register_cvar("XP_per_kill", "20")         register_menucmd(register_menuid("menu_ChooseRace"),(1<<0|1<<1|1<<2|1<<3|1<<4|1<<5),"DoChooseRace");         register_event("ResetHUD", "hook_hud", "b")         msgtext = get_user_msgid("StatusText")         register_clcmd("say changerace", "DoChooseRace")     register_clcmd("say_team changerace", "DoChooseRace")     register_clcmd("mosthatedonline", "MHO_Skill")     //register_concmd("mho_givexp", "mho_xp", ADMIN_SLAY, "<target> ")     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1"); } //------------------------------------------------------------------------------------------- public Event_CurWeapon(id)     {     new Float:Speed = 300.0+(PlayerLevel[id]*50)     set_user_maxspeed(id, Float:Speed) } //------------------------------------------------------------------------------------------- public SaveXP(id)     {     new authid[32];     get_user_authid(id,authid,31);     new vaultkey[64], vaultdata[64];         format(vaultkey,63,"RACE-%s-class",authid);     format(vaultdata,63,"%d",PlayerClass[id]);     set_vaultdata(vaultkey,vaultdata);         format(vaultkey,63,"RACE-%s-xp",authid);     format(vaultdata,63,"%d",PlayerXP[id]);     set_vaultdata(vaultkey,vaultdata);         format(vaultkey,63,"RACE-%s-level",authid);     format(vaultdata,63,"%d",PlayerLevel[id]);     set_vaultdata(vaultkey,vaultdata);         server_print("--MHO MOD-- SAVED XP",0.01) } //------------------------------------------------------------------------------------------- public LoadXP(id)     {     new authid[32];     get_user_authid(id,authid,31);         new vaultkey[64], vaultdata[64];         format(vaultkey,63,"RACE-%s-class",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerClass[id] = str_to_num(vaultdata);         format(vaultkey,63,"RACE-%s-xp",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerXP[id] = str_to_num(vaultdata);           format(vaultkey,63,"RACE-%s-level",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerLevel[id] = str_to_num(vaultdata);       server_print("--MHO MOD-- LOADED XP",0.01) } //------------------------------------------------------------------------------------------- public client_connect(id)     {     //if(get_cvar_num("SaveXP") == 1) {         //        LoadXP(id)         //        client_print(id, print_chat, "[MHO Mod] XP Loaded!")     //        client_print(id, print_chat, "[MHO Mod] You are a %s with level %s and %s XP", PlayerClass[id], PlayerLevel[id], PlayerXP[id])     //} } //------------------------------------------------------------------------------------------- public client_authorized(id)     {     if(get_cvar_num("SaveXP") == 1) {                 LoadXP(id)                 client_print(id, print_chat, "[MHO Mod] XP Loaded!")         client_print(id, print_chat, "[MHO Mod] You are a %s with level %s and %s XP", PlayerClass[id], PlayerLevel[id], PlayerXP[id])     } } //------------------------------------------------------------------------------------------- public MHO_Skill(id)     {     //new i     //new sum     //for (i=1; i<=10; i++)     //{     //   sum += i     //}     if(PlayerClass[id] == CLASS_MUTANT) {         //invisible     }     if(PlayerClass[id] == CLASS_ALIEN) {         //lazer/acid spit     }     if(PlayerClass[id] == CLASS_PREDATOR) {         //knifespeed     }     if(PlayerClass[id] == CLASS_MACHINE && is_user_alive(id) ) {         //if ( g_nightCrawlerTimer[id] > 0 ) {         //    set_user_godmode(id, 0)         //    new message[128]         //    format(message, 127, "%d seconds left of GOD Mode^n", g_nightCrawlerTimer[id] )         //    set_hudmessage(255,0,0,-1.0,0.3,0,1.0,1.2,0.0,0.0,87)         //    show_hudmessage( id, message)         //    g_nightCrawlerTimer[id]--         //}         //else if ( g_nightCrawlerTimer[id] == 0 ) {         //    g_nightCrawlerTimer[id]--         //    set_user_godmode(id)         //}             }     //client_print(id, print_chat, "[MHO Mod] %s skill level %s used by %s ", PlayerClass[id], PlayerLevel[id], PlayerXP[id]) } //------------------------------------------------------------------------------------------- public client_disconnect(id)     {     if(get_cvar_num("SaveXP") == 1) {                 SaveXP(id)     } } //------------------------------------------------------------------------------------------- stock ChooseRace(id)     {     new menu[192];     new keys //= MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4     //format(menu, 191, "MHO Mod: Choose Race^n^n1. Mutant^n2. Alien^n3. Predator^n4. Machine^n^n0. Exit")     new nLen = format( menu, 191, "MHO Mod: Choose Race:^n" )         nLen += format( menu[nLen], 191-nLen, "^n\w1. Mutant" )     nLen += format( menu[nLen], 191-nLen, "^n\w2. Alien" )     nLen += format( menu[nLen], 191-nLen, "^n\w3. Predator" )     nLen += format( menu[nLen], 191-nLen, "^n\w4. Machine" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w5. Fifth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w6. Sixth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w7. Seventh Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w8. Eighth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w9. Ninth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit" )     keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5)       //keys = (1<<0)|(1<<1|(2<<1|(3<<1|(4<<1)     show_menu(id, keys, menu, -1, "menu_ChooseRace")     return PLUGIN_CONTINUE } //------------------------------------------------------------------------------------------- public DoChooseRace(id, key)     {     if(key == 0) {         //if(PlayerClass[id] == CLASS_NOTHING) {         //    client_print(id, print_chat, "[MHO Mod] Race was already set to NOTHING! [display chooseRace]")         //    ChooseRace(id)         //    return PLUGIN_HANDLED         //}                 PlayerClass[id] = CLASS_NOTHING         //server_print("--MHO MOD-- KEY 0 SELECTED - No Race to Set",0.01)         client_print(id, print_chat, "[MHO Mod] KEY:0 Select a Race! [DEBUG NOTHING SELECTED]")         ChooseRace(id)         } else if(key == 1) {                 //if(PlayerClass[id] == CLASS_MUTANT) {         //    client_print(id, print_chat, "[MHO Mod] You are allready a Mutant! Choose something else!")         //    ChooseRace(id)                   //    return PLUGIN_HANDLED         //}             PlayerClass[id] = CLASS_MUTANT                 client_print(id, print_chat, "[MHO Mod] You are now a Mutant!")         server_print("--MHO MOD-- KEY 1 SELECTED - Mutant",0.01)         } else if(key == 2) {                 //if(PlayerClass[id] == CLASS_ALIEN) {         //    client_print(id, print_chat, "[MHO Mod] You are allready a Alien! Choose something else!")         //    ChooseRace(id)         //    return PLUGIN_HANDLED         //}         PlayerClass[id] = CLASS_ALIEN         client_print(id, print_chat, "[MHO Mod] You are now a Alien!")         server_print("--MHO MOD-- KEY 2 SELECTED - Alien",0.01)         } else if(key == 3) {         //if(PlayerClass[id] == CLASS_PREDATOR) {         //    client_print(id, print_chat, "[MHO Mod] You are allready a Predator! Choose something else!")         //    ChooseRace(id)         //    return PLUGIN_HANDLED         //}         PlayerClass[id] = CLASS_PREDATOR         client_print(id, print_chat, "[MHO Mod] You are now a Predator!")         server_print("--MHO MOD-- KEY 3 SELECTED - Predator",0.01)         } else if(key == 4) {         //if(PlayerClass[id] == CLASS_MACHINE) {         //    client_print(id, print_chat, "[MHO Mod] You are allready a Machine! Choose something else!")         //    ChooseRace(id)         //    return PLUGIN_HANDLED         //}         PlayerClass[id] = CLASS_MACHINE         client_print(id, print_chat, "[MHO Mod] You are now a Machine!")         server_print("--MHO MOD-- KEY 4 SELECTED - Machine",0.01)     }         ShowHUD(id)         return PLUGIN_HANDLED } //------------------------------------------------------------------------------------------- public hook_hud(id)     {     if(PlayerClass[id] == CLASS_NOTHING) {                 set_user_gravity(id, 1.03)         set_user_health(id, 100)         set_user_footsteps(id, 0)         set_user_maxspeed(id, 0.0)         setInvisibility(id, 250)         ChooseRace(id)         return PLUGIN_HANDLED     }     if(PlayerClass[id] == CLASS_MUTANT) {         //mutant powers         if (PlayerLevel[id] == 1){             set_user_gravity(id, 0.9)             set_user_health(id, 110)             } else if (PlayerLevel[id] == 2){             set_user_gravity(id, 0.8)             set_user_health(id, 115)             }else if (PlayerLevel[id] == 3){             set_user_gravity(id, 0.7)             set_user_health(id, 120)             }else if (PlayerLevel[id] == 4){             set_user_gravity(id, 0.6)             set_user_health(id, 130)         }     }     if(PlayerClass[id] == CLASS_ALIEN) {         //alien powers         if (PlayerLevel[id] == 1){             set_user_gravity(id, 0.9)             set_user_health(id, 110)             } else if (PlayerLevel[id] == 2){             set_user_gravity(id, 0.8)             set_user_health(id, 135)             }else if (PlayerLevel[id] == 3){             set_user_gravity(id, 0.7)             set_user_health(id, 150)             }else if (PlayerLevel[id] == 4){             set_user_gravity(id, 0.6)             set_user_health(id, 160)         }     }     if(PlayerClass[id] == CLASS_PREDATOR) {         //predator powers         if (PlayerLevel[id] == 1){             setInvisibility(id, 210)             set_user_gravity(id, 0.9)             set_user_health(id, 110)             set_user_footsteps(id, 1)             } else if (PlayerLevel[id] == 2){             setInvisibility(id, 190)             set_user_gravity(id, 0.8)             set_user_health(id, 135)             set_user_footsteps(id, 1)             }else if (PlayerLevel[id] == 3){             setInvisibility(id, 150)             set_user_gravity(id, 0.7)             set_user_health(id, 150)             set_user_footsteps(id, 1)             }else if (PlayerLevel[id] == 4){             setInvisibility(id, 100)             set_user_gravity(id, 0.6)             set_user_health(id, 160)             set_user_footsteps(id, 1)         }     }     if(PlayerClass[id] == CLASS_MACHINE) {         //machine powers         if (PlayerLevel[id] == 1){             set_user_gravity(id, 0.9)             set_user_health(id, 110)             set_user_maxspeed(id, 1.0)             cs_set_user_armor(id, 150, CS_ARMOR_VESTHELM)             } else if (PlayerLevel[id] == 2){             set_user_gravity(id, 0.69)             set_user_health(id, 135)             set_user_maxspeed(id, 1.5)             cs_set_user_armor(id, 175, CS_ARMOR_VESTHELM)             }else if (PlayerLevel[id] == 3){             set_user_gravity(id, 0.6)             set_user_health(id, 150)             set_user_maxspeed(id, 2.0)             cs_set_user_armor(id, 200, CS_ARMOR_VESTHELM)             }else if (PlayerLevel[id] == 4){             set_user_gravity(id, 0.5)             set_user_health(id, 160)             set_user_maxspeed(id, 4.0)             cs_set_user_armor(id, 250, CS_ARMOR_VESTHELM)         }     }         //client_print(id, print_chat, "[MHO Mod] XP Loaded!")     //client_print(id, print_chat, "[MHO Mod] You are a %s with level %s and %s XP", PlayerClass[id], PlayerLevel[id], PlayerXP[id])     server_print("--MHO MOD-- Setting Player Stats [hooking hud]",0.01)     return PLUGIN_HANDLED } //------------------------------------------------------------------------------------------- public DeathMsg()     {     if(get_cvar_num("sv_mhomod") == 0) {         return PLUGIN_HANDLED     }         new attacker = read_data(1)         if(PlayerClass[attacker] == CLASS_NOTHING) {         return PLUGIN_HANDLED     }         if(PlayerLevel[attacker] == 6) {         return PLUGIN_HANDLED     }         PlayerXP[attacker] += get_cvar_num("XP_per_kill")         if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {                 PlayerLevel[attacker] += 1                 client_print(attacker, print_chat, "[MHO Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])                 if(get_cvar_num("SaveXP") == 1) {                         SaveXP(attacker)         }                 ShowHUD(attacker)     }           ShowHUD(attacker)         return PLUGIN_CONTINUE } //------------------------------------------------------------------------------------------- public ShowHUD(id)         {     new HUD[51]     format(HUD, 50, "[%s] Level: %i XP: %i", CLASSES[PlayerClass[id]], PlayerLevel[id], PlayerXP[id])         message_begin(MSG_ONE, msgtext, {0,0,0}, id)     write_byte(0)     write_string(HUD)     message_end()     server_print("--MHO MOD-- HOOK HUD COMPLETE",0.05)     return } //------------------------------------------------------------------------------------------- public setInvisibility(id, alpha)     {     if (alpha < 125) {         set_user_rendering(id,kRenderFxGlowShell,8,8,8,kRenderTransAlpha,alpha)     }     else {         set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,alpha)     }         server_print("--MHO MOD-- Set Invisibility",0.01) } //------------------------------------------------------------------------------------------- public server_changeleve(map[], id)     {     server_print("--MHO MOD-- CHANGE LEVEL",0.01)     SaveXP(id) } </font> <font color="#000000">[</font>/code<font color="#000000">]</font></font>
Attached Files
File Type: sma Get Plugin or Get Source (mho_mod.sma - 431 views - 13.6 KB)

Last edited by gzus; 02-13-2007 at 09:29.
gzus is offline
raa
Senior Member
Join Date: Oct 2005
Old 02-13-2007 , 03:06   Re: menu problems with xp based plugin
Reply With Quote #2

I noob but thought I would post cuz I had same problem

for your function here
Code:
stock ChooseRace(id)     {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4             format(menu, 191, "MHO Mod: Choose Race^n^n1. Mutant^n2. Alien^n3. Predator^n4. Machine^n^n0. Exit")     show_menu(id, keys, menu, -1, "menu_ChooseRace")         return PLUGIN_CONTINUE }

replace with

Code:
stock ChooseRace(id)     {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4             format(menu, 191, "MHO Mod: Choose Race^n^n1. Mutant^n2. Alien^n3. Predator^n4. Machine^n^n0. Exit")     keys = (1<<0)|(1<<1|(2<<1|(3<<1|(4<<1)         show_menu(id, keys, menu, -1, "menu_ChooseRace")         return PLUGIN_CONTINUE }

if that doesn't work

use
Code:
keys = (1<<0)|(1<<1|(1<<2|(1<<3|(1<<4)

If that does'nt get you going post back and I'll look into it further. Or someone who is way more experienced then me will correct me I'm sure.
__________________
raa is offline
gzus
Member
Join Date: Jan 2007
Old 02-13-2007 , 08:04   Re: menu problems with xp based plugin
Reply With Quote #3

oh ok sweet, im going to check it out now, thanks!

____________________
edited:

still no go with chosing 3, or 4, 2 works, but it displays the print_chat, "[MHO Mod] You are now a Mutant!")
which i dont understand, if if/then statements should sort this out, i press 2 and it displays part key1's code, but
PlayerClass[id] = CLASS_ALIEN is run, since the show hud displays that u are an alien, along with ur XP and LVL, i honestly dont get this, ive spent a few days here n there on it, but i cant get anywhere, the more i poke at the code the more crappy it looks/runs.
__________________
71.200.20.142:27017 - testing mho mod
if you need any files visit clan.mosthatedonline.com

Last edited by gzus; 02-13-2007 at 08:32. Reason: updated status
gzus is offline
gzus
Member
Join Date: Jan 2007
Old 02-13-2007 , 09:32   Re: menu problems with xp based plugin
Reply With Quote #4

[bump]
i've edited the src and the code in the first post so show what i have now. i used the menu tut over at http://djeyl.net/forum/index.php?showtopic=27288 and got the menu working so-what good, it atleast allows you to choose races, all races do work, but how every, it sets the correct race, but says the wrong race. idk wtf the deal is with this. oh yea, the load xp doesnt seem to work wortha d*mn either. i exited the server, then opened the vault, set myself at lvl 6, race 4, with a bunch of xp, and it doesnt load.

any input on this would be +karma!
__________________
71.200.20.142:27017 - testing mho mod
if you need any files visit clan.mosthatedonline.com
gzus is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-13-2007 , 15:30   Re: menu problems with xp based plugin
Reply With Quote #5

Code:
new menu[192], keys new nLen = format( menu, 191, "MHO Mod: Choose Race:^n" ) for ( new i ; i < MAXCLASSES-1 ; i++ ) {     nLen += format( menu[nLen], 191-nLen, "^n\w%d. %s", i+1, CLASSES[i])     keys |= (1<<i) }
replaces
Code:
    new menu[192];     new keys //= MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4     //format(menu, 191, "MHO Mod: Choose Race^n^n1. Mutant^n2. Alien^n3. Predator^n4. Machine^n^n0. Exit")     new nLen = format( menu, 191, "MHO Mod: Choose Race:^n" )         nLen += format( menu[nLen], 191-nLen, "^n\w1. Mutant" )     nLen += format( menu[nLen], 191-nLen, "^n\w2. Alien" )     nLen += format( menu[nLen], 191-nLen, "^n\w3. Predator" )     nLen += format( menu[nLen], 191-nLen, "^n\w4. Machine" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w5. Fifth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w6. Sixth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w7. Seventh Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w8. Eighth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n\w9. Ninth Option" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit" )     keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5)       //keys = (1<<0)|(1<<1|(2<<1|(3<<1|(4<<1)


Code:
public DoChooseRace(id, key) {     switch(key) {         case 0: // User presses button 1(!) on keyboard.         case 1: // User presses button 2(!) on keyboard.         case 2: // User presses button 3(!) on keyboard.         case 3: // User presses button 4(!) on keyboard.         case 9: // User presses button 0(!) on keyboard.     } }

Last edited by [ --<-@ ] Black Rose; 02-13-2007 at 15:41.
[ --<-@ ] Black Rose is offline
raa
Senior Member
Join Date: Oct 2005
Old 02-13-2007 , 15:39   Re: menu problems with xp based plugin
Reply With Quote #6

I got your menu working. Also you can try to use what blackrose posted as well.

Code:
//------------------------------------------------------------------------------------------- // //            based on XunTric's animal omd // //         modified for MosthatedOnline Servers // //           <a href="http://clan.mosthatedonline.com" target="_blank" rel="nofollow noopener">http://clan.mosthatedonline.com</a> //------------------------------------------------------------------------------------------- #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <vault> //#include <superheromod> #include <Vexd_Utilities> #include <engine> #define PLUGIN "mho_mod" #define VERSION "1.12" #define AUTHOR "Gzus" #define CLASS_NOTHING 0 #define CLASS_MUTANT 1 #define CLASS_ALIEN 2 #define CLASS_PREDATOR 3 #define CLASS_MACHINE 4 #define MAXCLASSES 5 //------------------------------------------------------------------------------------------- //new g_nightCrawlerTimer[33] new PlayerClass[33] new PlayerXP[33] new PlayerLevel[33] //------------------------------------------------------------------------------------------- new const CLASSES[MAXCLASSES][] = {     "None",     "Mutant",     "Alien",     "Predator",     "Machine" } //------------------------------------------------------------------------------------------- new msgtext //------------------------------------------------------------------------------------------- new const LEVELS[6] = {     100,     200,     400,     800,     1600,     3200 } //------------------------------------------------------------------------------------------- public plugin_init()     {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_cvar("SaveXP", "1")     register_cvar("sv_mhomod", "1")         register_event("DeathMsg", "DeathMsg", "ae")         register_cvar("XP_per_kill", "20")         register_menucmd(register_menuid("menu_ChooseRace"),(1<<0|1<<1|1<<2|1<<3|1<<4|1<<5),"DoChooseRace");         register_event("ResetHUD", "hook_hud", "b")         msgtext = get_user_msgid("StatusText")         register_clcmd("say changerace", "ChooseRace")     register_clcmd("say_team changerace", "ChooseRace")     register_clcmd("mosthatedonline", "MHO_Skill")     //register_concmd("mho_givexp", "mho_xp", ADMIN_SLAY, "<target> ")     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1"); } //------------------------------------------------------------------------------------------- public Event_CurWeapon(id)     {     new Float:Speed = 300.0+(PlayerLevel[id]*50)     set_user_maxspeed(id, Float:Speed) } //------------------------------------------------------------------------------------------- public SaveXP(id)     {     new authid[32];     get_user_authid(id,authid,31);     new vaultkey[64], vaultdata[64];         format(vaultkey,63,"RACE-%s-class",authid);     format(vaultdata,63,"%d",PlayerClass[id]);     set_vaultdata(vaultkey,vaultdata);         format(vaultkey,63,"RACE-%s-xp",authid);     format(vaultdata,63,"%d",PlayerXP[id]);     set_vaultdata(vaultkey,vaultdata);         format(vaultkey,63,"RACE-%s-level",authid);     format(vaultdata,63,"%d",PlayerLevel[id]);     set_vaultdata(vaultkey,vaultdata);         server_print("--MHO MOD-- SAVED XP",0.01) } //------------------------------------------------------------------------------------------- public LoadXP(id)     {     new authid[32];     get_user_authid(id,authid,31);         new vaultkey[64], vaultdata[64];         format(vaultkey,63,"RACE-%s-class",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerClass[id] = str_to_num(vaultdata);         format(vaultkey,63,"RACE-%s-xp",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerXP[id] = str_to_num(vaultdata);           format(vaultkey,63,"RACE-%s-level",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerLevel[id] = str_to_num(vaultdata);       server_print("--MHO MOD-- LOADED XP",0.01) } //------------------------------------------------------------------------------------------- public client_connect(id)     {     //if(get_cvar_num("SaveXP") == 1) {         //      LoadXP(id)         //      client_print(id, print_chat, "[MHO Mod] XP Loaded!")     //      client_print(id, print_chat, "[MHO Mod] You are a %s with level %s and %s XP", PlayerClass[id], PlayerLevel[id], PlayerXP[id])     //} } //------------------------------------------------------------------------------------------- public client_authorized(id)     {     if(get_cvar_num("SaveXP") == 1) {                 LoadXP(id)                 client_print(id, print_chat, "[MHO Mod] XP Loaded!")         client_print(id, print_chat, "[MHO Mod] You are a %s with level %s and %s XP", PlayerClass[id], PlayerLevel[id], PlayerXP[id])     } } //------------------------------------------------------------------------------------------- public MHO_Skill(id)     {     //new i     //new sum     //for (i=1; i<=10; i++)     //{     //   sum += i     //}     if(PlayerClass[id] == CLASS_MUTANT) {         //invisible     }     if(PlayerClass[id] == CLASS_ALIEN) {         //lazer/acid spit     }     if(PlayerClass[id] == CLASS_PREDATOR) {         //knifespeed     }     if(PlayerClass[id] == CLASS_MACHINE && is_user_alive(id) ) {         //if ( g_nightCrawlerTimer[id] > 0 ) {         //  set_user_godmode(id, 0)         //  new message[128]         //  format(message, 127, "%d seconds left of GOD Mode^n", g_nightCrawlerTimer[id] )         //  set_hudmessage(255,0,0,-1.0,0.3,0,1.0,1.2,0.0,0.0,87)         //  show_hudmessage( id, message)         //  g_nightCrawlerTimer[id]--         //}         //else if ( g_nightCrawlerTimer[id] == 0 ) {         //  g_nightCrawlerTimer[id]--         //  set_user_godmode(id)         //}             }     //client_print(id, print_chat, "[MHO Mod] %s skill level %s used by %s ", PlayerClass[id], PlayerLevel[id], PlayerXP[id]) } //------------------------------------------------------------------------------------------- public client_disconnect(id)     {     if(get_cvar_num("SaveXP") == 1) {                 SaveXP(id)     } } //------------------------------------------------------------------------------------------- public ChooseRace(id)     {     new menu[192];     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4     format(menu, 191, "MHO Mod: Choose Race^n^n1. Mutant^n2. Alien^n3. Predator^n4. Machine^n^n0. Exit")     //new nLen = format( menu, 191, "MHO Mod: Choose Race:^n" )         //nLen += format( menu[nLen], 191-nLen, "^n\w1. Mutant" )     //nLen += format( menu[nLen], 191-nLen, "^n\w2. Alien" )     //nLen += format( menu[nLen], 191-nLen, "^n\w3. Predator" )     //nLen += format( menu[nLen], 191-nLen, "^n\w4. Machine" )     //nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit" )     keys = (1<<9|1<<0|1<<1|1<<2|1<<3)       show_menu(id, keys, menu, -1, "menu_ChooseRace")     return PLUGIN_CONTINUE } //------------------------------------------------------------------------------------------- public DoChooseRace(id, key)     {     if(key == 0) {         if(PlayerClass[id] == CLASS_MUTANT) {             client_print(id, print_chat, "[MHO Mod] You are allready a Mutant! Choose something else!")             ChooseRace(id)                       return PLUGIN_HANDLED         }             PlayerClass[id] = CLASS_MUTANT                 client_print(id, print_chat, "[MHO Mod] You are now a Mutant!")         server_print("--MHO MOD-- KEY 1 SELECTED - Mutant",0.01)             }     if(key == 1) {                 if(PlayerClass[id] == CLASS_ALIEN) {             client_print(id, print_chat, "[MHO Mod] You are allready a Alien! Choose something else!")             ChooseRace(id)             return PLUGIN_HANDLED         }         PlayerClass[id] = CLASS_ALIEN         client_print(id, print_chat, "[MHO Mod] You are now a Alien!")         server_print("--MHO MOD-- KEY 2 SELECTED - Alien",0.01)             }     if(key == 2) {         if(PlayerClass[id] == CLASS_PREDATOR) {             client_print(id, print_chat, "[MHO Mod] You are allready a Predator! Choose something else!")             ChooseRace(id)             return PLUGIN_HANDLED         }         PlayerClass[id] = CLASS_PREDATOR         client_print(id, print_chat, "[MHO Mod] You are now a Predator!")         server_print("--MHO MOD-- KEY 3 SELECTED - Predator",0.01)             }     if(key == 3) {         if(PlayerClass[id] == CLASS_MACHINE) {             client_print(id, print_chat, "[MHO Mod] You are allready a Machine! Choose something else!")             ChooseRace(id)             return PLUGIN_HANDLED         }         PlayerClass[id] = CLASS_MACHINE         client_print(id, print_chat, "[MHO Mod] You are now a Machine!")         server_print("--MHO MOD-- KEY 4 SELECTED - Machine",0.01)             }     if(key == 4) {         server_print("--MHO MOD-- KEY 0 SELECTED - Exit",0.01)         return PLUGIN_HANDLED             }         ShowHUD(id)         return PLUGIN_HANDLED } //------------------------------------------------------------------------------------------- public hook_hud(id)     {     if(PlayerClass[id] == CLASS_NOTHING) {                 set_user_gravity(id, 1.03)         set_user_health(id, 100)         set_user_footsteps(id, 0)         set_user_maxspeed(id, 0.0)         setInvisibility(id, 250)         ChooseRace(id)         return PLUGIN_HANDLED     }     if(PlayerClass[id] == CLASS_MUTANT) {         //mutant powers         if (PlayerLevel[id] == 1){             set_user_gravity(id, 0.9)             set_user_health(id, 110)             } else if (PlayerLevel[id] == 2){             set_user_gravity(id, 0.8)             set_user_health(id, 115)             }else if (PlayerLevel[id] == 3){             set_user_gravity(id, 0.7)             set_user_health(id, 120)             }else if (PlayerLevel[id] == 4){             set_user_gravity(id, 0.6)             set_user_health(id, 130)         }     }     if(PlayerClass[id] == CLASS_ALIEN) {         //alien powers         if (PlayerLevel[id] == 1){             set_user_gravity(id, 0.9)             set_user_health(id, 110)             } else if (PlayerLevel[id] == 2){             set_user_gravity(id, 0.8)             set_user_health(id, 135)             }else if (PlayerLevel[id] == 3){             set_user_gravity(id, 0.7)             set_user_health(id, 150)             }else if (PlayerLevel[id] == 4){             set_user_gravity(id, 0.6)             set_user_health(id, 160)         }     }     if(PlayerClass[id] == CLASS_PREDATOR) {         //predator powers         if (PlayerLevel[id] == 1){             setInvisibility(id, 210)             set_user_gravity(id, 0.9)             set_user_health(id, 110)             set_user_footsteps(id, 1)             } else if (PlayerLevel[id] == 2){             setInvisibility(id, 190)             set_user_gravity(id, 0.8)             set_user_health(id, 135)             set_user_footsteps(id, 1)             }else if (PlayerLevel[id] == 3){             setInvisibility(id, 150)             set_user_gravity(id, 0.7)             set_user_health(id, 150)             set_user_footsteps(id, 1)             }else if (PlayerLevel[id] == 4){             setInvisibility(id, 100)             set_user_gravity(id, 0.6)             set_user_health(id, 160)             set_user_footsteps(id, 1)         }     }     if(PlayerClass[id] == CLASS_MACHINE) {         //machine powers         if (PlayerLevel[id] == 1){             set_user_gravity(id, 0.9)             set_user_health(id, 110)             set_user_maxspeed(id, 1.0)             cs_set_user_armor(id, 150, CS_ARMOR_VESTHELM)             } else if (PlayerLevel[id] == 2){             set_user_gravity(id, 0.69)             set_user_health(id, 135)             set_user_maxspeed(id, 1.5)             cs_set_user_armor(id, 175, CS_ARMOR_VESTHELM)             }else if (PlayerLevel[id] == 3){             set_user_gravity(id, 0.6)             set_user_health(id, 150)             set_user_maxspeed(id, 2.0)             cs_set_user_armor(id, 200, CS_ARMOR_VESTHELM)             }else if (PlayerLevel[id] == 4){             set_user_gravity(id, 0.5)             set_user_health(id, 160)             set_user_maxspeed(id, 4.0)             cs_set_user_armor(id, 250, CS_ARMOR_VESTHELM)         }     }         //client_print(id, print_chat, "[MHO Mod] XP Loaded!")     //client_print(id, print_chat, "[MHO Mod] You are a %s with level %s and %s XP", PlayerClass[id], PlayerLevel[id], PlayerXP[id])     server_print("--MHO MOD-- Setting Player Stats [hooking hud]",0.01)     return PLUGIN_HANDLED } //------------------------------------------------------------------------------------------- public DeathMsg()     {     if(get_cvar_num("sv_mhomod") == 0) {         return PLUGIN_HANDLED     }         new attacker = read_data(1)         if(PlayerClass[attacker] == CLASS_NOTHING) {         return PLUGIN_HANDLED     }         if(PlayerLevel[attacker] == 6) {         return PLUGIN_HANDLED     }         PlayerXP[attacker] += get_cvar_num("XP_per_kill")         if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {                 PlayerLevel[attacker] += 1                 client_print(attacker, print_chat, "[MHO Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])                 if(get_cvar_num("SaveXP") == 1) {                         SaveXP(attacker)         }                 ShowHUD(attacker)     }           ShowHUD(attacker)         return PLUGIN_CONTINUE } //------------------------------------------------------------------------------------------- public ShowHUD(id)         {     new HUD[51]     format(HUD, 50, "[%s] Level: %i XP: %i", CLASSES[PlayerClass[id]], PlayerLevel[id], PlayerXP[id])         message_begin(MSG_ONE, msgtext, {0,0,0}, id)     write_byte(0)     write_string(HUD)     message_end()     server_print("--MHO MOD-- HOOK HUD COMPLETE",0.05)     return } //------------------------------------------------------------------------------------------- public setInvisibility(id, alpha)     {     if (alpha < 125) {         set_user_rendering(id,kRenderFxGlowShell,8,8,8,kRenderTransAlpha,alpha)     }     else {         set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,alpha)     }         server_print("--MHO MOD-- Set Invisibility",0.01) } //------------------------------------------------------------------------------------------- public server_changeleve(map[], id)     {     server_print("--MHO MOD-- CHANGE LEVEL",0.01)     SaveXP(id) }

The reason the classes were'nt being assigned correctly what cuz of;
I changed
Code:
new const CLASSES[MAXCLASSES][] = {     "Mutant",     "Alien",     "Predator",     "Machine",     "None" }
To:
Code:
new const CLASSES[MAXCLASSES][] = {     "None",     "Mutant",     "Alien",     "Predator",     "Machine" }
__________________

Last edited by raa; 02-13-2007 at 15:44.
raa is offline
gzus
Member
Join Date: Jan 2007
Old 02-13-2007 , 16:47   Re: menu problems with xp based plugin
Reply With Quote #7

thanks! im not sure about the switching cases, last time i tried that it said u could only have one line of code for each case, so i kinda shy'd from the cases. if i cant get this going i'll attempt that.

the menu seems to be working pretty swell at the moment, im going to have a few ppl test it in a bit, thanks a ton for the responses guys!
__________________
71.200.20.142:27017 - testing mho mod
if you need any files visit clan.mosthatedonline.com
gzus is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-13-2007 , 17:08   Re: menu problems with xp based plugin
Reply With Quote #8

Code:
case 0: {     // line 1     // line 2 } case 1: {     // line 1     // line 2 }
Works like a charm.
[ --<-@ ] Black Rose is offline
gzus
Member
Join Date: Jan 2007
Old 02-13-2007 , 17:19   Re: menu problems with xp based plugin
Reply With Quote #9

i'll have to try that out in a few, prolly for a shopmenu type idea..

im not sure if i should start a new topic, but since its the same plugin im workin on, can anyone point me to a help topic on timers, or the for looping commands, i'm tryin to get up a type of either godmode for like 5 second, or invisiblity, but i honestly dont know where to start, i tried formatting a for loop for the time period, then disabling god mode when the loops were done, but i dont know how to set a time limit on each loop, to make it wait say 1 second then send a hud msg or something saying theres X seconds left.
__________________
71.200.20.142:27017 - testing mho mod
if you need any files visit clan.mosthatedonline.com
gzus is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode