Raised This Month: $ Target: $400
 0% 

Menu help.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ianglowz
Senior Member
Join Date: Nov 2008
Old 12-28-2008 , 09:10   Menu help.
Reply With Quote #1

Can anyone edit this code so the menu will show after the player connect?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fun>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
    
"None",
    
"Dog",
    
"Cat",
    
"Horse",
    
"Tiger"
}
new const 
LEVELS[6] = {
    
100
    
200
    
400
    
800,
    
1600,
    
3200
}
new 
PlayerXP[33],PlayerLevel[33],PlayerClass[33]
new 
XP_Kill,XP_Knife,XP_Hs,SaveXP,g_vault
public plugin_init()
{
    
register_plugin("XpMod""1.0""fxfighter")
 
    
register_event("DeathMsg""eDeath""a"
    
register_event("ResetHUD","on_spawn","be"
    
    
SaveXP register_cvar("SaveXP","1")
    
XP_Kill=register_cvar("XP_per_kill""20")
    
XP_Hs=register_cvar("XP_hs_bonus","20")
    
XP_Knife=register_cvar("XP_knife_bonus","20")
    
g_vault nvault_open("animod")
 
    
register_clcmd("say /class""ChangeClass")
    
register_clcmd("say_team /class""ChangeClass")
    
register_clcmd("say /xp""ShowHud")
    
register_clcmd("say_team /xp""ShowHud")
}
public 
eDeath(  ) 
{
    new 
attacker read_data)
    new 
headshot read_data)
    new 
clipammoweapon get_user_weapon(attacker,clip,ammo);
 
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
 
    if(
headshot)
    
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
 
    if(
weapon == CSW_KNIFE)
    
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
 
 
    while(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
    {
    
client_print(attackerprint_chat"[XpMod] Congratulations! You are a level %i %s!",PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
    
PlayerLevel[attacker] += 1
    
}

    
ShowHud(attacker)
    
SaveData(attacker)
}

public 
ShowHud(id)
{
    
set_hudmessage(255000.750.0106.015.0)
    
show_hudmessage(id"Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
}
public 
ChangeClass(id)
{
    new 
menu menu_create("Class Menu" "Class_Handle");
    
menu_additem(menu ,"Dog""1" 0);
    
menu_additem(menu ,"Cat""2" 0);
    
menu_additem(menu ,"Horse""3" 0);
    
menu_additem(menu ,"Tiger""4" 0);
 
    
menu_setprop(menu MPROP_EXIT MEXIT_ALL);
 
    
menu_display(id menu 0);
 
    return 
PLUGIN_CONTINUE;
}
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 szName 63 callback);
 
    new 
str_to_num(szCommand)
    if(
PlayerClass[id] != i)
    {
        
PlayerClass[id] = i
        client_print
(id,print_chat,"You are now a %s",CLASSES[i])
    }
    else
    {
        
client_print(id,print_chat,"You are alredy a %s",CLASSES[i])
    }
 
    
menu_destroy(menu);
    return 
PLUGIN_CONTINUE
}
public 
client_connect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
LoadData(id)
    }
}
public 
client_disconnect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
SaveData(id)
    }
    
PlayerXP[id] = 0
    PlayerLevel
[id] = 0
    PlayerClass
[id] = 0
}
public 
SaveData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
 
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[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-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
 
    
replace_all(vaultdata255"#"" ")
 
    new 
playerxp[32], playerlevel[32]
 
    
parse(vaultdataplayerxp31playerlevel31)
 
    
PlayerXP[id] = str_to_num(playerxp)
    
PlayerLevel[id] = str_to_num(playerlevel)
 
    return 
PLUGIN_CONTINUE
}
public 
on_spawn(id)
{
    if (
PlayerLevel[id] <= 2
    {               
//
    
set_user_health(id135);  
    }
    
    if (
PlayerLevel[id] == 4
    {               
//
    
set_user_health(id185);  
    }
    
    if (
PlayerLevel[id] >= 6
    {               
//
    
set_user_health(id255);  
    }

Have present who helping me.
Attached Files
File Type: sma Get Plugin or Get Source (test_xpmod.sma - 559 views - 4.4 KB)
__________________
~ +karma to me and leave your name. ~
~ If you -karma to me,please leave your name so I know you are pro scripter. ~
~ Helping anytime ~


ianglowz is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 12-28-2008 , 09:17   Re: Menu help.
Reply With Quote #2

public client_putinserver(id)
set_task(5.0, "ChangeClass", id)
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Old 12-28-2008, 09:21
SnoW
This message has been deleted by SnoW. Reason: Hate when someone is faster than me...
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 12-28-2008 , 09:22   Re: Menu help.
Reply With Quote #3

Cleint dont is in server in client_connect. They call then the player do the first connection to the server.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
ianglowz
Senior Member
Join Date: Nov 2008
Old 12-28-2008 , 09:22   Re: Menu help.
Reply With Quote #4

Can you edit my code?I don't know where to put that code.
__________________
~ +karma to me and leave your name. ~
~ If you -karma to me,please leave your name so I know you are pro scripter. ~
~ Helping anytime ~


ianglowz is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-28-2008 , 09:23   Re: Menu help.
Reply With Quote #5

Hmmm, still... I don't know about that, that 5sec is pretty weak, you could use TeamInfo so you get the menu when you pick CT or T, also it would be better cause if you go spec you shouldn't be able to decide class.

Edit:
"Cleint dont is in server in client_connect. They call then the player do the first connection to the server. "
You didn't read my whole post, I said that's what you want, but you can't call it there. After that I gave the right way.
SnoW is offline
Send a message via MSN to SnoW
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 12-28-2008 , 09:24   Re: Menu help.
Reply With Quote #6

Quote:
Originally Posted by ianglowz View Post
Can you edit my code?I don't know where to put that code.
PHP Code:
public client_connect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
LoadData(id)
    }
}
 
public 
client_putinserver(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
        
set_task(5.0"ChangeClass"id)
    }

__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
ianglowz
Senior Member
Join Date: Nov 2008
Old 12-28-2008 , 09:25   Re: Menu help.
Reply With Quote #7

SnoW,just put your code.I think your code more good.Because I want the menu out when client join the team.

@AntiBots
Thx for that code.
__________________
~ +karma to me and leave your name. ~
~ If you -karma to me,please leave your name so I know you are pro scripter. ~
~ Helping anytime ~


ianglowz is offline
ianglowz
Senior Member
Join Date: Nov 2008
Old 12-28-2008 , 09:26   Re: Menu help.
Reply With Quote #8

@AntiBots
Testing.
__________________
~ +karma to me and leave your name. ~
~ If you -karma to me,please leave your name so I know you are pro scripter. ~
~ Helping anytime ~


ianglowz is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 12-28-2008 , 09:26   Re: Menu help.
Reply With Quote #9

That's still bad way, also you should do it always, the
Code:
if(get_pcvar_num(SaveXP) == 1)
shouldn't be there, classes can be used is the save xp on or not.
SnoW is offline
Send a message via MSN to SnoW
ianglowz
Senior Member
Join Date: Nov 2008
Old 12-28-2008 , 09:28   Re: Menu help.
Reply With Quote #10

SnoW,I give you to edit my code.Hope it working.

@AntiBots.
Thx,but now no people entering my server because my server is lagging now.
__________________
~ +karma to me and leave your name. ~
~ If you -karma to me,please leave your name so I know you are pro scripter. ~
~ Helping anytime ~


ianglowz 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 14:50.


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