Raised This Month: $51 Target: $400
 12% 

Updated Flyen's EXP Tutorial (Fixed Errors)


Post New Thread Reply   
 
Thread Tools Display Modes
liinuus
Senior Member
Join Date: Apr 2010
Old 01-04-2011 , 05:52   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #11

@qlail why are u giving them hp if theyre level 5 or lower instead of 5 or higher?

@Erox902 try this for message
Code:
client_print(attacker, print_chat, "[Hxp Mod] Congratulation you have finnally reached level %i!", UserLevel[attacker]);
for the grenade part just copy the check for if the attacker had knife but make it check for grenade instead if( weapon == CSW_the weapon u wanna check for)
code for extra xp

Last edited by liinuus; 01-04-2011 at 06:02.
liinuus is offline
Blunr552
Member
Join Date: May 2008
Old 01-04-2011 , 09:08   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #12

@ qlail, how about you test ur code urself before calling it working.

So lets begin to fix your mistakes:
In you full code which you said should work without any errors, there you simply forgot to write:

PHP Code:
#define MAXCLASSES 5 
Then you made these mistakes:

PHP Code:
 new PlayerXP,PlayerLevel,PlayerClass[33]
//These are for your special kills
new XP_Kill,XP_Knife,XP_Hs
//This is for the vault, so your EXP saves to the server
new g_vault 
Here you forgot to add:
PHP Code:
new SaveXP 
and you shouldnt write this:
PHP Code:
new PlayerXP,PlayerLevel,PlayerClass[33
Else you would get an error.

This should be right:
PHP Code:
new PlayerXP[33],PlayerLevel[33],PlayerClass[33

Next Error:
PHP Code:
new const CLASSES[MAXCLASSES][] {
             
"None",
             
"Rifle Specialist",
             
"Sniper Specialist",
             
"Pistol Specialist",
             
"Machine Gun Specialist"

Should be

PHP Code:
new const CLASSES[MAXCLASSES][] = {
             
"None",
             
"Rifle Specialist",
             
"Sniper Specialist",
             
"Pistol Specialist",
             
"Machine Gun Specialist"

Dont forget the "=" :/


This is wrong again:
PHP Code:
new const LEVELS[10] = {
             
"100",
             
"200",
             
"400",
             
"800",
             
"1600",
             
"3200",
             
"6400",
             
"12800",
             
"25600",
             
"51200"

Change it to:

PHP Code:
new const LEVELS[10] = {
             
100,
             
200,
             
400,
             
800,
             
1600,
             
3200,
             
6400,
             
12800,
             
25600,
             
51200

At last, go to your Class_Handle. There you can find this:

PHP Code:
client_print(id,print_chat"[XP Mod] You are already a %s",CLASSES[i
please dont forget to add the ")" at the end....

like this:

PHP Code:
client_print(id,print_chat"[XP Mod] You are already a %s",CLASSES[i]) 


Here is the real non error Code.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define MAXCLASSES 5 

new PlayerXP[33],PlayerLevel[33],PlayerClass[33]
//These are for your special kills
new XP_Kill,XP_Knife,XP_Hs
//This is for the vault, so your EXP saves to the server
new g_vault
//This is for the SaveXP command
new SaveXP

new const CLASSES[MAXCLASSES][] = {
    
"None",
    
"Rifle Specialist",
    
"Sniper Specialist",
    
"Pistol Specialist",
    
"Machine Gun Specialist"
}

new const 
LEVELS[10] = {
    
100,
    
200,
    
400,
    
800,
    
1600,
    
3200,
    
6400,
    
12800,
    
25600,
    
51200
}

public 
plugin_init()
{
    
register_plugin("Simple EXP Mod""1.0""Thelius"// Registers the Plugin to the ModName, Version, and Creator
    
register_event("DeathMsg""eDeath""a"// This is the death event
    
SaveXP register_cvar("SaveXP""1"// This is to make sure that Saving XP is enabled
    
XP_Kill register_cvar("XP_per_kill""40"// This defines the amount of EXP you gain per kill
    
XP_Hs register_cvar("XP_hs_bonus""50"// This defines the amount of exp gained per headshot
    
XP_Knife register_cvar("XP_knife_bonus""20"// This defines the amount of Exp gained per Knife Kill
    
g_vault nvault_open("XPMod"// This opens the nvault so it can save the exp
    
    
register_clcmd("say /class""ChangeClass"// Saying /class will open the class menu
    
register_clcmd("say_team /class""ChangeClass"// Team saying /class will open the class menu
    
register_clcmd("say /xp""ShowHud"// Saying /xp will show your EXP
    
register_clcmd("say_team /xp""ShowHud"// Team Saying /xp will show your EXP
}

public 
eDeath( )
{
    new 
headshot,attacker read_data)
    new 
weapon get_user_weapon(attacker,headshot,headshot)
    
headshot read_data)
    
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
    
    if(
PlayerClass[attacker] == 0)
        
    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"[XP Mod] Congratulations you are now level %i %s!"PlayerLevel[attacker], CLASSES[PlayerClass[attacker]]);
        
PlayerLevel[attacker] += 1
    
}
    
ShowHud(attacker)
    
SaveData(attacker)
}

public 
ShowHud(id)
{
    
set_hudmessage(025500.280.8806.012.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 ,"Rifle Specialist""1" 0);
    
menu_additem(menu ,"Sniper Specialist""2" 0);
    
menu_additem(menu ,"Pistol Specialist""3" 0);
    
menu_additem(menu ,"Machine Gun Specialist""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"[XP Mod] You are now a %s"CLASSES[i])
    }
    else
    {
        
client_print(id,print_chat"[XP Mod] You are already 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


So please do us newbies the favor and check if your code works or not We get confused and dont know what to do when it doesnt work ^^

Last edited by Blunr552; 01-04-2011 at 14:30.
Blunr552 is offline
liinuus
Senior Member
Join Date: Apr 2010
Old 01-04-2011 , 11:00   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #13

blunr dont u have to specify the %i and %s?
this
Code:
client_print(attacker, print_chat, "[XP Mod] Congratulations you are now level %i %s!");
to this?
Code:
client_print(attacker, print_chat, "[XP Mod] Congratulations you are now level %i %s!", PlayerLevel[attacker], CLASSES[PlayerClass[attacker]]);

Last edited by liinuus; 01-04-2011 at 11:02.
liinuus is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 01-04-2011 , 12:18   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #14

Copy & paste ? Exactly the same code for loading and saving XP etc .. : http://forums.alliedmods.net/showthr...highlight=surf
.... If you do a tutorials, never copy and past other plugins .
__________________
bboygrun is offline
Blunr552
Member
Join Date: May 2008
Old 01-04-2011 , 14:06   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #15

Quote:
Originally Posted by bboygrun View Post
Copy & paste ? Exactly the same code for loading and saving XP etc .. : http://forums.alliedmods.net/showthr...highlight=surf
.... If you do a tutorials, never copy and past other plugins .

Its from the old XP tutorial. Accually he just renewved the code. I fixed the errors i could find and that was all about it ^^


@ linuss, didnt see sowy D:
Blunr552 is offline
Blunr552
Member
Join Date: May 2008
Old 01-04-2011 , 14:25   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #16

delete plz,

monsterlag...

Last edited by Blunr552; 01-04-2011 at 14:38.
Blunr552 is offline
Blunr552
Member
Join Date: May 2008
Old 01-04-2011 , 14:30   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #17

delete plz,

monsterlag...

Last edited by Blunr552; 01-04-2011 at 14:38.
Blunr552 is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 01-04-2011 , 15:16   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #18

Pfiou, sorry, i tought he did what i said.
__________________
bboygrun is offline
Blunr552
Member
Join Date: May 2008
Old 01-04-2011 , 15:17   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #19

Quote:
Originally Posted by bboygrun View Post
Pfiou, sorry, i tought he did what i said.
NP
Blunr552 is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 01-10-2011 , 14:58   Re: Updated Flyen's EXP Tutorial (Fixed Errors)
Reply With Quote #20

Quote:
Originally Posted by liinuus View Post
@qlail why are u giving them hp if theyre level 5 or lower instead of 5 or higher?

@Erox902 try this for message
Code:
client_print(attacker, print_chat, "[Hxp Mod] Congratulation you have finnally reached level %i!", UserLevel[attacker]);
for the grenade part just copy the check for if the attacker had knife but make it check for grenade instead if( weapon == CSW_the weapon u wanna check for)
code for extra xp
Thx man the messege wasn't really what i asked for but noticed that it was wrong ....

@qlail:
you said you were working on giving them some more hp every 5th level...
crist dude it's easily done the same way you did the more hp for thoose below level 5
Code:
public on_spawn {     if ( is_user_alive( id ) && !is_user_bot( id )     {            switch( PlayerLevel[id] )         {             case 5 .. 9: set_user_health( id, 105 )             case 10 .. 14: set_user_health(id, 110)             //and so on         }
(if you want bots to be able to get more hp too then just remove that check)

and i know it's old but
PHP Code:
register_event("ResetHUD""on_spawn""be"
is not the right way to detect a players spawn
include hamsandwich is the easiest way
PHP Code:
#include <hamsandwich>

public plugin_init()
{
     
RegisterHam(Ham_Spawn"player""on_spawn"1)


Last edited by Erox902; 06-30-2011 at 20:08.
Erox902 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 09:15.


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