Raised This Month: $ Target: $400
 0% 

working xp mod tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 08-29-2008 , 12:02   working xp mod tutorial
Reply With Quote #1

EDIT:

Ignore what I said before I have a better idea.

Can somebody make a tutorial explaining how to perhaps give each gun a level or something? For example you kill somebody with an m4, and you get an "m4 point" and so on. Each time you get enough points for a certain gun, you level up and get upgrades for the gun.

Good idea but. . is it possible? how?

Last edited by PvtSmithFSSF; 08-29-2008 at 13:29.
PvtSmithFSSF is offline
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 08-29-2008 , 13:22   Re: working xp mod tutorial
Reply With Quote #2

Quote:
Originally Posted by PvtSmithFSSF View Post
I've tried both, but they both have errors and aren't really supported anymore.. Can't someone be nice and create one? I need to have a background of this stuff.
Preferably, it should include details on how to:
- Save/Load exp on disconnect/connect
- Make classes to choose from
- Have levels for each class
- Have various skills to put points into, like wc3ft where each class gets different skill options to place points into.
- Get bonus XP if you get a headshot, and also a knife kill.

Thanks a lot, and +karma, if somebody could pleasee do this.
-Smith
I don't know why its so hard... :/

These:
- Get bonus XP if you get a headshot, and also a knife kill.
- Make classes to choose from
- Have levels for each class
- Save/Load exp on disconnect/connect

Are already in: http://forums.alliedmods.net/showthread.php?t=66497



[X]-RayCat is offline
Old 08-29-2008, 13:25
padilha007
This message has been deleted by padilha007. Reason: [X]-RayCat
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 08-29-2008 , 13:27   Re: working xp mod tutorial
Reply With Quote #3

Quote:
Originally Posted by [X]-RayCat View Post
I don't know why its so hard... :/

These:
- Get bonus XP if you get a headshot, and also a knife kill.
- Make classes to choose from
- Have levels for each class
- Save/Load exp on disconnect/connect

Are already in: http://forums.alliedmods.net/showthread.php?t=66497
I know they are already there but they don't work, the whole thing together will not compile for me





big post edit above

Last edited by PvtSmithFSSF; 08-29-2008 at 13:29.
PvtSmithFSSF is offline
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 08-29-2008 , 13:56   Re: working xp mod tutorial
Reply With Quote #4

Well you could do it like this:

PHP Code:
 
new m4xp[33];
 
public 
plugin_init()
{
    
register_event("DeathMsg""eDeath""a");


public 
eDeath()
{
    new 
killer read_data(1);
 
    new 
weapon get_user_weapon(killer);
 

    if(
weapon == CSW_M4A1)
        
m4xp[killer] += 10;

    
//and then save data


Last edited by [X]-RayCat; 08-29-2008 at 14:00.
[X]-RayCat is offline
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 08-29-2008 , 14:00   Re: working xp mod tutorial
Reply With Quote #5

i edit the tutorial code fast just to fix the errors sense the tutorial maker doesn't maintain it.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define MAXCLASSES 5
#define MAXLEVELS 6

new const CLASSES[MAXCLASSES][] = {
    
"None",
    
"Dog",
    
"Cat",
    
"Horse",
    
"Cow"
}
new const 
LEVELS[MAXLEVELS] = {
    
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"
    
    
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(1)
    new 
headshot read_data(3)
    new 
weapon get_user_weapon(attacker)
    
    
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"[Animal Mod] 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 ,"Cow""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);
        return
    }
    
item++
    if(
PlayerClass[id] != item)
    {
        
PlayerClass[id] = item
        client_print
(id,print_chat,"You are now a %s",CLASSES[item])
    }
    else 
client_print(id,print_chat,"You are alredy a %s",CLASSES[item])
    
    
menu_destroy(menu);
}
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]
    
formatex(vaultkey,63,"%s-Mod",AuthID)
    
formatex(vaultdata,255,"%i %i",PlayerXP[id],PlayerLevel[id])
    
nvault_set(g_vault,vaultkey,vaultdata)
}
public 
LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
formatex(vaultkey,63,"%s-Mod",AuthID)
    
formatex(vaultdata,255,"%i %i ",PlayerXP[id],PlayerLevel[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
    
    new 
playerxp[32], playerlevel[32]
    
parse(vaultdataplayerxp31playerlevel31)
    
    
PlayerXP[id] = str_to_num(playerxp)
    
PlayerLevel[id] = str_to_num(playerlevel)
    

Didnt have time to test it but it should work.
__________________
If one of my plugins become broken, contact me by mail. [email protected]

Last edited by fxfighter; 08-29-2008 at 14:06.
fxfighter is offline
Send a message via MSN to fxfighter
padilha007
Senior Member
Join Date: Jul 2008
Old 08-29-2008 , 14:33   Re: working xp mod tutorial
Reply With Quote #6

fxfighter you can make to salve xp with name?
padilha007 is offline
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 08-29-2008 , 14:43   Re: working xp mod tutorial
Reply With Quote #7

shoud just need to replace the
PHP Code:
get_user_authid(id,AuthID,34)
whit
get_user_name
(id,AuthID,34

do it in both save and load function
__________________
If one of my plugins become broken, contact me by mail. [email protected]

Last edited by fxfighter; 08-29-2008 at 14:45.
fxfighter is offline
Send a message via MSN to fxfighter
padilha007
Senior Member
Join Date: Jul 2008
Old 08-29-2008 , 16:33   Re: working xp mod tutorial
Reply With Quote #8

tnx man, need .dat?
padilha007 is offline
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 08-29-2008 , 16:51   Re: working xp mod tutorial
Reply With Quote #9

hey fxfighter your code works flawlessly

ps: nooby question here, but can you show me how to:
- hook round start function and do a check for roundstart to 1) check their class and that class's exp? Because I want to give them bonuses every round start if they are high enough level in the right class.
Thanks
PvtSmithFSSF is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 08-29-2008 , 17:04   Re: working xp mod tutorial
Reply With Quote #10

for roundstart you could use HLTV , but you can also use hamsandwich to hook the spawn
__________________
I am out of order!
grimvh2 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 03:16.


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