AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   working xp mod tutorial (https://forums.alliedmods.net/showthread.php?t=76731)

PvtSmithFSSF 08-29-2008 12:02

working xp mod tutorial
 
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?

[X]-RayCat 08-29-2008 13:22

Re: working xp mod tutorial
 
Quote:

Originally Posted by PvtSmithFSSF (Post 677929)
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




PvtSmithFSSF 08-29-2008 13:27

Re: working xp mod tutorial
 
Quote:

Originally Posted by [X]-RayCat (Post 677971)
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

[X]-RayCat 08-29-2008 13:56

Re: working xp mod tutorial
 
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



fxfighter 08-29-2008 14:00

Re: working xp mod tutorial
 
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.

padilha007 08-29-2008 14:33

Re: working xp mod tutorial
 
fxfighter you can make to salve xp with name?

fxfighter 08-29-2008 14:43

Re: working xp mod tutorial
 
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

padilha007 08-29-2008 16:33

Re: working xp mod tutorial
 
tnx man, need .dat?

PvtSmithFSSF 08-29-2008 16:51

Re: working xp mod tutorial
 
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 :)

grimvh2 08-29-2008 17:04

Re: working xp mod tutorial
 
for roundstart you could use HLTV , but you can also use hamsandwich to hook the spawn


All times are GMT -4. The time now is 03:16.

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