PDA

View Full Version : New XP Mod tutorial


Pages : [1] 2

flyeni6
02-01-2008, 17:16
First of all, full credit goes to fxfighter, he revised it. All im doing is releasing this so that people wont go to the other xp mod tutorial (which doesnt work). And i added a little bit of extras so that it would be better. Anyways, on to the tutorial :) ...


Im going to show you have to make an XP mod.
Before starting, you should have basic scripting Knowledge.


Inculde all the important modules


#include <amxmodx>
#include <amxmisc>
#include <nvault>
Define the maximum classes.
Here there is 5, but if you want to add 2 more animals, like a bird and a fish, then you can put 7. But we are dealing with 5
#define MAXCLASSES 5We create the variable that is going to hold your class, xp , and level
new PlayerXP[33],PlayerLevel[33],PlayerClass[33]
//these are for special kills
new XP_Kill,XP_Knife,XP_Hs,SaveXP
//this is for Nvault. so that We can save XP
new g_vault
This is the "maxclasses" variable we were talking about. You'll see these in the game.
Code:
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
} Note that there are 5 classes. Thats why we defined maxclasses to 5


Now we create the levels, and how many xp you ned to gain a level.
There is 7 levels

Code:
new const LEVELS[7] = {
0,
100,//this means you need 100 xp
200,//this means you need 200 xp
400,//this means you need 400 xp
800,//so on
1600,//so on
3200 //so on
}Now we create the plugin_init()
public plugin_init()
{
register_plugin("XpMod", "1.0", "Fxfighter")

//we need this to check your level after you kill some one
register_event("DeathMsg", "eDeath", "a")
//is saving on?
SaveXP = register_cvar("SaveXP","1")
//how many xp are u gonna get per kill?
XP_Kill=register_cvar("XP_per_kill", "20")
//if you get a hs you get bonus xp
XP_Hs=register_cvar("XP_hs_bonus","20")
//if you make a knife kill you get bounus xp
XP_Knife=register_cvar("XP_knife_bonus","20")
//we just opened a new connection NVAULT connection
// we will call it animod
g_vault = nvault_open("animod")
// register a say command to change class
register_clcmd("say /class", "ChangeClass")
register_clcmd("say_team /class", "ChangeClass")
//show how much xp you have
register_clcmd("say /xp", "ShowHud")
register_clcmd("say_team /xp", "ShowHud")
}We are gonna create the Death function. Rember we called it "eDeath" in plugin_init()? It will keep track of your xp and if you ganined a level
Code:
public eDeath( ) //function name
{
// If the player's Class is nothing, then dont bother to do any of the below
if(PlayerClass[attacker] == 0)
return PLUGIN_CONTINUE

// Create a variable to store the attacker's id
new attacker = read_data( 1 )
// We create the victim variable, so that this function can check
// if a player was killed
new iVictim = read_data( 2 )
// If a player was killed by a HeadShot, this will be used for the cvar Xp_Hs
new headshot = read_data( 3 )

//which weapon was used
new clip, ammo, weapon = get_user_weapon(attacker,clip,ammo);
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
// used for the xp_hs cvar
// it checks if the victim was killed by a headshot
if(headshot)
// give him/her bonus xp
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
// checks if the victim was killed by a knife
if(weapon == CSW_KNIFE)
//give him/her bonus xp
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
// this checks if the player has enough xp to advance to a new level

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{ // this will create the Congratulations message.
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!", PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
// Add his/her level
PlayerLevel[attacker] += 1
}
// shows his level on a hud message
ShowHud(attacker)

}This is the showhud function. It shows the your Class, your level, and XP
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0)
show_hudmessage(id, "Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
} Note: ^n means new line


Here is the menu selector. It will give you the options to select your animal. It uses the new menu system. I dont feel like going into detail with the new menu system, here is the original tutorial on that (http://forums.alliedmods.net/showthread.php?t=46364)
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);
}
new szCommand[6] , szName[64]; new access , callback;
menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);
new i = 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
}
This this is the client connect function. All these things happend when the player is connecting to the server
public client_connect(id)
{
// Only does it if xp saving is on
if(get_pcvar_num(SaveXP) == 1)
{
// load your player data
LoadData(id)
}
}This is the client disconect funtion. These only happen when the player has disconnected from the server
public client_disconnect(id)
{
// Only does it if xp saving is on
if(get_pcvar_num(SaveXP) == 1)
{
// lets save the data
SaveData(id)
}
}Now we create the save data function
public SaveData(id)
{
// get the players steam id. We need this because we are saving by steam id
new AuthID[35] get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
// format wat is going to be in the animal mod vault file
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
// save the data
nvault_set(g_vault,vaultkey,vaultdata)
return PLUGIN_CONTINUE
}now we create the load data function
public LoadData(id)
{
new AuthID[35] get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
// search
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
// load the data
nvault_get(g_vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new playerxp[32], playerlevel[32]
parse(vaultdata, playerxp, 31, playerlevel, 31)
PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)
return PLUGIN_CONTINUE
}
OK now everything with out comments

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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 iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = 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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}
Any errors or anything please feel free to reply

Exolent[jNr]
02-01-2008, 19:29
i read a little part, and your knife and hs pcvars are swapped :S

flyeni6
02-01-2008, 20:00
everything fixed :P thanks

[kirk]./musick`
02-01-2008, 20:41
Looks good, thanks a lot. The other one didn't work, so many people complained :roll:

flyeni6
02-01-2008, 21:10
Yeh many people were complaining so i was like "damn ill just make a New one" :D

Drak
02-02-2008, 00:52
You might want to change "client_connect" to "client_authorized".
Just to be safe.

fxfighter
02-02-2008, 05:10
think you shuld add this to the death event so you cant get xp whit class none.

if(PlayerClass[attacker] == 0)
return PLUGIN_CONTINUE
And plz remove my old mistake^^

public client_connect(id)
{
// cant print he is not in yet
client_print(id, print_chat, "[AnimalMod] XP Loaded!")
}


small future i wuld like to see^^ but it might get buged on max lv.

show_hudmessage(id, "Level: %i^nXP: %i/%i^nClass: %s",PlayerLevel[id],PlayerXP[id],LEVELS[PlayerLevel[id]],CLASSES[PlayerClass[id]])


if you get to much xp then you will have a bug that you lv up once instead of twice this will solve it.

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
PlayerLevel[attacker] += 1

flyeni6
02-02-2008, 05:51
think you shuld add this to the death event so you cant get xp whit class none.

if(PlayerClass[attacker] == 0)
return PLUGIN_CONTINUEAnd plz remove my old mistake^^

public client_connect(id)
{
// cant print he is not in yet
client_print(id, print_chat, "[AnimalMod] XP Loaded!")
}
small future i wuld like to see^^ but it might get buged on max lv.

show_hudmessage(id, "Level: %i^nXP: %i/%i^nClass: %s",PlayerLevel[id],PlayerXP[id],LEVELS[PlayerLevel[id]],CLASSES[PlayerClass[id]])
if you get to much xp then you will have a bug that you lv up once instead of twice this will solve it.

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
PlayerLevel[attacker] += 1



I did everything but the 3rd part because im very sleepy :P and i have to do other things. And u said it might bug, so yea.

Arkshine
02-02-2008, 06:00
@flyen16

Can you tell me why are you using get_user_attacker() ?


public eDeath( )
{
new iVictim = read_data( 2 )

new weapon, hitplace, attacker = get_user_attacker(iVictim,weapon,hitplace)

if(hitplace == HIT_HEAD)


Using DeathMsg event, the killer is provided in the first argument ( read_data(1) ) and to know if it's a headshot, it's provided in the third argument ( read_data(3 ) ). And to know the weapon, see the fourth argument.

flyeni6
02-02-2008, 06:15
@flyen16

Can you tell me why are you using get_user_attacker() ?

Code:
public eDeath( ) { new iVictim = read_data( 2 ) new weapon, hitplace, attacker = get_user_attacker(iVictim,weapon,hitplace) if(hitplace == HIT_HEAD)


Using DeathMsg event, the killer is provided in the first argument ( read_data(1) ) and to know if it's a headshot, it's provided in the third argument ( read_data(3 ) ). And to know the weapon, see the fourth argument.

oh crap, lol i wasnt paying attention lol.
ill fix it, thx for telling me

Arkshine
02-02-2008, 06:18
http://wiki.alliedmods.net/Half-Life_1_Game_Events#DeathMsg

flyeni6
02-02-2008, 06:22
fixed

Arkshine
02-02-2008, 06:41
You have omitted the weapon.

flyeni6
02-02-2008, 14:59
fixed that problem

linkosc
02-05-2008, 16:48
Is this for SQL or can It be used with a text file to save xp? Im working on a mod with these features but I dont know anything about SQL Databases. Thanks
LINKosc

TheNewt
02-13-2008, 15:19
This isn't for sql, for sql view some of the sql tutorials, documentation, or plugin examples. I wrote an example last year using the older version of sql access, Hawk wrote information on how to use the newer SQL data access.

SQL Information, Code Examples, and Tutorials By:
BAILOPAN (http://forums.alliedmods.net/showthread.php?t=2632)
Hawk552 (http://forums.alliedmods.net/showthread.php?t=46779)
TheNewt (http://forums.alliedmods.net/showthread.php?t=40737)

I recommend learning SQLx from Hawk's thread there. Mine's is the older version, and BAIL's there is an update to the API, not really a tutorial.

Hunter-Digital
02-15-2008, 23:52
my god... please someone just fix this tutorial !

There is NO "attacker" variable in the death func, and some other problems that occured upon compile...

Please fix both the long and comented sections and the uncommented full code... :roll:

SwiFtStRiDeR
03-14-2008, 18:15
Could you please post one without the classes and just leveling up with chosen names for each rank?:)

jasonf20
03-15-2008, 14:00
u forgot the attacker verible man use read_data (1)
and u used an id which is undeffined aswell

fxfighter
03-15-2008, 15:53
i did use read_Data(1) read the code

new headshot,attacker = read_data( 1 )

jasonf20
03-15-2008, 16:05
i did use read_Data(1) read the code

not u in the final code thats in the main message in eDeath its missing the attacker variable

fxfighter
03-15-2008, 16:09
Y thats why i fixed it.

Checkmarks
03-15-2008, 18:38
Always wanted to make exp mod but never really knew how. Last tutorial didn't work. Thanks for making this.
I'd give you lots of respect and a +karma if you could add something though. This is nice and all, but it's pointless leveling up. Could you show everyone how to give people rewards at the certain levels? That way people actually WANT to level up and come back to the server :)

Rolnaaba
03-16-2008, 15:20
simple, say you want to give them more damage on level 3 on damage event, check their level then if high enough level just add some damage.

fxfighter
03-16-2008, 15:27
you can hook roundstart or spawn to give at start like extra hp or ar.
You can check thare level after level up in the death msg to.

Rolnaaba
03-16-2008, 18:31
basically you can do anything, just check if their level is high enough first, or if you have them choose skills to train that you have varriables to keep track of that:
psuedo:
if(playerLevel[index] >= 10)
{
give_hp(index, 500);
uber(index);
} get what we mean?

Checkmarks
03-17-2008, 15:41
yes, so i just put in

[code]
if(playerLevel[index] >= 10)
{
whatever i want to give them

}

and where do i put this?

atomen
03-17-2008, 15:49
you can hook roundstart or spawn to give at start like extra hp or ar.
You can check thare level after level up in the death msg to.

Merko
03-26-2008, 23:39
Uh. Hi.

I'm new too amxx scripting so I was just wondring if there is somthing wrong with the code, or maybe I compile it wrong? :p

I tried to compile it but I get the error:

/home/groups/amxmodx/tmp3/phpXo7cEB.sma(43) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(45) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(48) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(51) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(54) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(56) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(56 -- 57) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(59) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpXo7cEB.sma(60) : error 017: undefined symbol "attacker"

9 Errors.
Could not locate output file /home/groups/amxmodx/public_html/websc3/phpXo7cEB.amx (compile failed).
An ideas? ;)

Edit: Got everything to work :]

Lee
03-27-2008, 03:56
There's an error in the code. You can either wait for a reply in the relevant topic or you can post the code that you're trying to compile in Scripting Help.

Merko
03-27-2008, 18:39
This code doesnt save xp right? When I change map ect I have my same XP. but if I reconnect on client I loose it..

fxfighter
03-29-2008, 05:19
it saves xp in nvault by steamid and i posted a small fix on page 2 in this thread.

Merko
03-30-2008, 07:02
Oh right ;).

Well I fixed it myself too hehe. :)

HexD
03-30-2008, 11:26
How would I make it give different things for different classes at different levels?

grimvh2
03-30-2008, 11:30
it think the threath stater should update his xp mod tutorial ,
I have seen many topics last time all because of a bad tutorial ,
It is also very annoying for the newbies like me cause they think there going out the good way untill they see all the errors but they cant do a thing about it .

Merko
03-30-2008, 12:33
Well I started AMXX Scripting two days ago and this was my second tutorial. I got most of it to work.

HexD:
If you wanna give yourself somthing for each level and class you can do something like this:

if(PlayerLevel[id] == 2) // Checks level.
{
give_item(id,"weapon_awp"); // Give yourself AWP at level 2
}
If you wanna give something for a class only you can do..


if (PlayerClass[id] == CLASS_COW) // Checks if he's an cow or not
{
set_user_health(id, 250); // gives him 250 health if he's a Cow
}
If you wanna give an item to a class on a X level you could do somthing like this..


if (PlayerClass[id] == CLASS_COW || PlayerLevel[id] == 5) // Checks Class and Level.
{
set_user_health(id, 250); // gives him 250 health if he's a Cow on level 5
give_item(id,"weapon_awp"); //
}
Edit: You also might want to add this on the top.

enum {
PLAYERLEVEL_1,
PLAYERLEVEL_2,
PLAYERLEVEL_3, // How many Levels
PLAYERLEVEL_4,
PLAYERLEVEL_5,
PLAYERLEVEL_6
}
enum {
CLASS_NONE = 0,
CLASS_COW,
CLASS_HORSE, // Add your Classes there..
CLASS_CAT,
CLASS_DOG
}

grimvh2
03-30-2008, 14:39
Nice , your learning fast

Lee
03-30-2008, 17:19
Except '||' signifies 'logical or' and not 'logical and' - you were looking for '&&'.

HexD
03-30-2008, 20:31
Thanks for the reply, I've been trying all day to get it to work but I do not know how or where to add your changes.

Could you explain it a bit more please?

The other thing I was wondering is:
if(PlayerLevel[id] >= 16) // Checks level.
{
set_user_health(id, 120);
}
if(PlayerLevel[id] >= 31) // Checks level.
{
set_user_health(id, 140);
}
if(PlayerLevel[id] >= 46) // Checks level.
{
set_user_health(id, 160);
}
if(PlayerLevel[id] >= 61) // Checks level.
{
set_user_health(id, 180);
}
if(PlayerLevel[id] >= 76) // Checks level.
{
set_user_health(id, 200);
}
if(PlayerLevel[id] == 90) // Checks level.
{
set_user_health(id, 255);
}

Will the above add the specified health for all levels above the one it checks for? I mean will it stack the health like at lvl 16 player will get 120 health, then at lvl 31 they will get 140, will the script give them both health bonuses? If it will how do I make it not?

Merko
03-30-2008, 23:25
Hello.

As for your second Question no, they wont get their bonus for each level if they are like level 90+

However, if you wanna do that one time (lets say they can buy an item that adds 25 health)

Heres quick example.

Code:
if(PlayerLevel[id] <= 5) // If there user is level 1-5 or exactly 5.
{
new health = get_user_health(id); // Setting the user's health in a variabel
set_user_health(id, health+25); // Set the users health to the 'old' health + gives him 25 extra health bonus.
}

To your first question.. give me some mins and I can see if Ican try explain it better : )

Edit: HexD What exactly are you trying to make that does not work? the code above should work.

HexD
03-31-2008, 00:33
Hey again,

I "was" trying to figure out exactly where to put the "if" statements to give the bonuses you suggested. I used the give health to certain levels as it seems pretty straight forward, but I couldn't get it to compile, I realised after reading up on set_user_health that I needed to include the fun module which got it compiling.

I tried to hook an event so when the player spawns the bonus health is added, but I can't find any useful doc's on HL/CS events so I don't know which event to hook or how else to give the health bonuses. I made an event called OnHealth and tried hooking it to a HL event from here (http://wiki.amxmodx.org/Half-Life_1_Game_Events#Health) but it didn't work and also killed the rest of the script until I removed the register_event("Health", "OnHealth", "a")
I really don't understand how to make it work :(
Also I can't find and infomation about these event like for when a player connects for CS, only for NS, how did you learn?

At the moment the script compiles but is giving me a runtime error L 03/31/2008 - 04:52:12: [AMXX] Displaying debug trace (plugin "Ninjamod.amxx")
L 03/31/2008 - 04:52:12: [AMXX] Run time error 4: index out of bounds
L 03/31/2008 - 04:52:12: [AMXX] [0] phpwDxHcH.sma::eDeath (line 174)
It doesn't give the health for my level and is giving an an error that has nothing to do with the health bonuses, it's not even in the same function so I have no idea what's wrong there.

I attached my .sma so you can see my what I've done and maybe better understand what I'm trying to do. Which is for now, players pick a class (element) level up and at certain levels they get more health, so f.i a level 90 player gets max health (255) every round.

Merko
03-31-2008, 03:20
Hello.

I made this event in the plugin_init()

register_event("ResetHUD","on_spawn","be"); // When the player spawns


And then made a function:

// Example
public on_spawn(id)
{
if (PlayerLevel[id] <= 10) // IF user is somewhere between level 1 and 10 Then
{ //
set_user_health(id, 135); // We give him 135 Health
}

if (PlayerLevel[id] == 50) // IF user is exactly level 50 Then
{ //
set_user_health(id, 185); // We give him 185 Health
}

if (PlayerLevel[id] >= 90) // IF user is level 90 OR more Then
{ //
set_user_health(id, 255); // We give him 255 Health
}
}


Hope this helps a litlebit. Ask if there is somthing else, or if you still didnt understand it correctly. : )

Also attached the .sma file with the edits I did.

(Like the mod btw, will be cool when its done im sure ;)

Edit: I saw a small 'bug' in your script wich I forgot to edit. Here it is.

//Lv up if he have enugh xp
while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
client_print(attacker, print_chat, "[Kage] Congratulations! You are a level %i %s!",PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
PlayerLevel[attacker] += 1
}
{


First you send a message to the client, Then you level up. You should put "PlayerLevel[attacker] += 1 over the client so the user see the correct level that he got :)
Otherwise if he's level 3, then level up it says "Congratulations! You are level 3.."

HexD
03-31-2008, 16:04
Ah brilliant! I was wondering why my first level was 0 :S

Woo!! All the errors are gone as far as I know and everything is working as it should! I can't thank you enough, really appreciate it.

Thought I'd add you seem like a nice person and that if you're looking for a project to work on then me and a friend are building up this script/mod (NinjaMod) and you'd be welcome to join us. We have most of it planned but are open to ideas and obviously I could use support with coding it all. PM if you like the sound of joining us, if not, no matter, just thought I'd throw the offer out there :)

Thanks again for your help +Karma!

Merko
04-01-2008, 00:29
Hehe.

Thanks for the offer, but I gotta say no :( same as you, im beginner and I started my own "project" just for practice. Atleast we can help each other ;)

Would also recommand taking backup from your project now and then. I got some errors that took a while to find hehe. :p

HexD
04-01-2008, 23:13
Lol, I'm at the stage where, if I changed something, anything no matter how small I will save and compile just to make sure it worked :D

Trying to make my script open a menu when the player first joins the game so they can pick a class, like it does in Warcraft plugins. Anyway, best of luck to you and your project. 8)

Merko
04-02-2008, 04:29
In the on_spawn() event I got this:


if (PlayerClass[id] == CLASS_NONE) // IF the class is NONE THEN..
{
ChangeClass(id) // ..Open the ChangeClass Menu.
}


Edit: Oh by the way, this might work aswell:


public client_connect(id)
{
if(get_pcvar_num(SaveXP) == 1)
{
LoadData(id)
ChangeClass(id)
}
}

or..

public client_authorized(id)
{
if(get_cvar_num("SaveXP") == 1)
{
LoadData(id)
ChangeClass(id)
}
}

HexD
04-02-2008, 11:18
Thanks, the way I was trying was not to different, but it didn't work;

public client_authorized(id)
{
new menu = ChangeClass(id);
if(is_user_alive(id) == 1)
{
menu_display(id, menu, 0)
}
if(get_pcvar_num(SaveXP) == 1)
{
LoadData(id)
}
}

Although I think I will use this way;

public client_authorized(id)
{
if(get_pcvar_num(SaveXP) == 1)
{
LoadData(id)
}
if(is_user_alive(id) == 1 && PlayerClass[id] == CLASS_NONE)
{
ChangeClass(id)
}
}

Lee
04-02-2008, 14:59
You should not expect people to be alive in client_authorized() and you should not use ResetHUD (http://forums.alliedmods.net/showthread.php?t=42159) to detect spawn.

HexD
04-04-2008, 22:59
Thanks, will change it to Ham_Spawn. Very useful link.

fxfighter
04-05-2008, 05:51
Guys if you need help with your script post in scripting help instead.
I know its becase you used the tutorial you posted heer but if everyone dose it gonna be a mass spam heer abut help.

Merko
04-05-2008, 09:50
Nah, he asked for some help regarding the tutorial, and got answer here. Good with everything on one place too incase more people use this tutorial they got some usefull answers :)

AAleaderNik
05-19-2008, 00:11
i know you said dont post here but i was just wondering

where would you put the code to check how many players are on server before the xp starts to save....

my guess would be at the beginning of eDeath function
but i just wanted confirmation and also what code would you put there

edit:

also...you get xp for killing yourself on round switch and for some reason my doesnt want to save :-/

ClanReaper
05-27-2008, 23:38
What Program do you use to make this plugin?




Your AMX Mod X User,
ClanReaper:twisted:

Alka
05-28-2008, 07:17
What Program do you use to make this plugin?




Your AMX Mod X User,
ClanReaper:twisted:
Pawn Studio, AmxModX Studio, Notepad++

ClanReaper
05-28-2008, 20:16
Can you post links to these programs, Pawn Studio, AmxModX Studio, and Notepad++? If you can please make it look like this

Pawn Studio: <LINK>
AmxModX Studio: www.amxmodx.org (http://www.amxmodx.org)
Notepad++: <LINK>


Your AMX Mod X User,
ClanReaper

YamiKaitou
05-28-2008, 20:20
Pawn Studio: Here (http://forums.alliedmods.net/search.php)
AmxModX Studio: www.amxmodx.org (http://www.amxmodx.org)
Notepad++: Here (http://google.com)

ClanReaper
05-29-2008, 02:50
Wow lol thanks for the advice but I found them, and I wanted to know if somone could help me learn about making a kick plugin or so.


Thank You,
ClanReaper

YamiKaitou
05-29-2008, 09:38
Maybe if you start posing in the correct forum now, you might get better responses

Lee
05-29-2008, 20:17
Why not read the default admincmd.sma (http://svn.alliedmods.net/viewvc.cgi/amxmodx/win32/base/addons/amxmodx/scripting/admincmd.sma?revision=1346&root=Packages&view=markup) which contains the source to amx_kick?

Fry!
05-30-2008, 16:02
Wow , great tutorial for my first xp mod . Well I have a question with this TuT I can create mod like war3 , or not because I want create with classes . If not then please give me link to that TuT .

Thanks .

DarkGod
06-09-2008, 01:22
How do you add a set or add/take experience command?

Lee
06-09-2008, 11:32
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
Please fix this so the people in Scripting Help don't have to maintain it.

Have you learnt about when return values are needed since you wrote this tutorial?

fxfighter
06-10-2008, 04:20
Think you should read the code agin lee this example works just fine.


public LoadData(id)
{
.......
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])

nvault_get(g_vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")//I think you know what this does
.........
}

Lee
06-10-2008, 05:56
Nobody said it didn't work, but I see how I gave you that impression. How about saving integers as integers?

Why would you pad those integers with hashes (#), only to replace them with spaces? Wouldn't it be more sensible to.. pad them with spaces? (Not that you should be using encoding at all).

You ignored my other question.

Have you learnt about when to make a function public since you wrote this tutorial?

You should have been using formatex() throughout your plugin.

Does this "work just fine"?

PlayerClass[id] = i client_print(id,print_chat,"You are now a %s",CLASSES[i])

Convention dictates that uppercase identifiers are defined by the preprocessor.

iVictim is never used and iHeadShot is only ever set/read once - what's the purpose of it being a variable?

MAXCLASSES is completely unnecessary, but one could argue that's a matter of style.

Maybe I'm being overcritical (about the encoding issue anyway), but all the stupid ideas in this topic (http://forums.alliedmods.net/showthread.php?t=72201) originate from this tutorial. You're passing on your bad habits to other people. I call them bad habits, but they seem to stem from your understanding lacking depth.

Lee
06-10-2008, 08:08
Yes, and? He doesn't use that "type of call".

tobstr
06-20-2008, 09:33
Ohh, sorry, missed a post, this thing should not be posted here. I´m sorry!

LostSkill
06-28-2008, 11:17
And what need do if i whana that write not Level: 1 or Level: 2 but write somethink like this Level: Turbo Man and somethink like Level: Pro its posible do this?

and whats wrong at here?

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fun>
#define MAXCLASSES 4
new PlayerXP[33],PlayerLevel[33],PlayerClass[33]
new XP_Kill,XP_Knife,XP_Hs,SaveXP
new g_vault
new const CLASSES[MAXCLASSES][] = {
"None",
"Sausumos Pajegu Karys",
"Oro Pajegu Karys",
"Juru Pajegu Karys"
}
new const LEVELS[19] = {
0,
50,
125,
200,
325,
450,
580,
780,
980,
1300,
1600,
2000,
2400,
2900,
3500,
4000,
4700,
5400,
6500,
8000
}
public plugin_init()
{
register_plugin("ArmyMod", "0.1", "Dunno")
register_event("DeathMsg", "eDeath", "a")
register_event("ResetHUD","on_spawn","be");
SaveXP = register_cvar("SaveXP","1")
XP_Kill=register_cvar("XP_per_kill", "1")
XP_Hs=register_cvar("XP_hs_bonus","2")
XP_Knife=register_cvar("XP_knife_bonus","2")
g_vault = nvault_open("ArmyMod")
register_clcmd("say /karys", "ChangeClass")
register_clcmd("say_team /karys", "ChangeClass")
register_clcmd("say /frag", "ShowHud")
register_clcmd("say_team /frag", "ShowHud")
}
public eDeath( )
{
if(PlayerClass[attacker] == 0)
return PLUGIN_CONTINUE
new iVictim = read_data( 2 )
new headshot = read_data( 3 )

new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_center, "[Army Mod] Congratulations! You are a level %i %s!", PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0)
show_hudmessage(id, "Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
}
public ChangeClass(id)
{
new menu = menu_create("Soldiers Menu" , "Class_Handle");
menu_additem(menu ,"Sausumos Pajegu Karys", "1" , 0);
menu_additem(menu ,"Oro Pajegu Karys", "2" , 0);
menu_additem(menu ,"Juru Pajegu Karys", "3" , 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 , 5 , szName , 63 , callback);
new i = 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)
}
}
public SaveData(id)
{
// get the players steam id. We need this because we are saving by steam id
new AuthID[35] get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
// format wat is going to be in the animal mod vault file
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
// save the data
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]
// search
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
// load the data
nvault_get(g_vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new playerxp[32], playerlevel[32]
parse(vaultdata, playerxp, 31, playerlevel, 31)
PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)
return PLUGIN_CONTINUE
}
public on_spawn(id)
{
if (PlayerLevel[id] == 1)
{
set_user_health(id, 105);
set_user_armor(id, 105);
}
if (PlayerLevel[id] == 2)
{
set_user_health(id, 110);
set_user_gravity(id, 0.9);
set_user_armor(id, 105);
}
if (PlayerLevel[id] == 3)
{
set_user_health(id, 120);
set_user_maxspeed(id, -0.9);
set_user_gravity(id, 0.9);
set_user_armor(id, 105);
}
if (PlayerLevel[id] == 4)
{
set_user_health(id, 120);
set_user_maxspeed(id, -0.8);
set_user_gravity(id, 0.9);
set_user_armor(id, 105);
}
if (PlayerLevel[id] == 5)
{
set_user_health(id, 120);
set_user_maxspeed(id, -0.75);
set_user_gravity(id, 0.8);
set_user_armor(id, 110);
}
if (PlayerLevel[id] == 6)
{
set_user_health(id, 130);
set_user_maxspeed(id, -0.75);
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
}
if (PlayerLevel[id] == 7)
{
set_user_health(id, 135);
set_user_maxspeed(id, -0.70);
set_user_gravity(id, 0.75);
set_user_armor(id, 115);
}
if (PlayerLevel[id] == 8)
{
set_user_health(id, 135);
set_user_maxspeed(id, -0.70);
set_user_gravity(id, 0.75);
set_user_armor(id, 115);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
}
if (PlayerLevel[id] == 9)
{
set_user_health(id, 145);
set_user_maxspeed(id, -0.70);
set_user_gravity(id, 0.75);
set_user_armor(id, 115);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 10)
{
set_user_health(id, 145);
set_user_maxspeed(id, -0.7);
set_user_gravity(id, 0.7);
set_user_armor(id, 120);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 11)
{
set_user_health(id, 155);
set_user_maxspeed(id, -0.7);
set_user_gravity(id, 0.7);
set_user_armor(id, 125);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 12)
{
set_user_health(id, 155);
set_user_maxspeed(id, -0.7);
set_user_gravity(id, 0.65);
set_user_armor(id, 135);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 13)
{
set_user_health(id, 160);
set_user_maxspeed(id, -0.65);
set_user_gravity(id, 0.65);
set_user_armor(id, 135);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 14)
{
set_user_health(id, 170);
set_user_maxspeed(id, -0.65);
set_user_gravity(id, 0.65);
set_user_armor(id, 140);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 15)
{
set_user_health(id, 170);
set_user_maxspeed(id, -0.65);
set_user_gravity(id, 0.6);
set_user_armor(id, 145);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 16)
{
set_user_health(id, 180);
set_user_maxspeed(id, -0.6);
set_user_gravity(id, 0.6);
set_user_armor(id, 150);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 17)
{
set_user_health(id, 180);
set_user_maxspeed(id, -0.6);
set_user_gravity(id, 0.55);
set_user_armor(id, 155);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
}
if (PlayerLevel[id] == 18)
{
set_user_health(id, 200);
set_user_maxspeed(id, -0.6);
set_user_gravity(id, 0.5);
set_user_armor(id, 160);
give_item(id, "weapon_deagle");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id,"ammo_50ae");
give_item(id, "weapon_hegrenade");
give_item(id, "weapon_flashbang");
give_item(id, "weapon_flashbang");
}
}

THe NiNJa
08-10-2008, 05:52
I get 9 errors...
Anyone?

Atspulgs
08-13-2008, 19:19
@ Lee - Could you please write tutorial on coding then? You could even teach me proper english :D Im getting kind of annoyed that all tutorials are well not exactly precise -_-

Lee
08-14-2008, 10:04
I'll think about it. All the tutorials I've read on this forum aimed at beginners are horrible. Some of the content on the AMWiki (http://wiki.amxmodx.org/Category:Scripting_(AMX_Mod_X)) isn't so bad, but I think I could do better and there are certainly huge areas completely missing.

Atspulgs
08-19-2008, 13:37
thank you for considering it.

Desktop00
08-26-2008, 01:54
I get 9 errors...
Anyone?

same with me

padilha007
08-27-2008, 10:03
put all errors hear

Desktop00
08-27-2008, 16:41
when i compile i get the errors

/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(89) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(91) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(96) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(101) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(104) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(107) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(107) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(107) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(107 -- 108) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(112) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpKSbI5Y.sma(113) : error 017: undefined symbol "attacker"

can anyone help?

padilha007
08-27-2008, 21:20
add this in:

eDeath( )
{
new attacker = read_data(1)
new id = read_data(1)

PvtSmithFSSF
08-27-2008, 21:37
can you perhaps explain how to
1) make rewards and stuff, like wc3 ft mod
2) make terrorist-only classes and ct-only classes, so depending on which team you join, you get different class choices.

Howdy!
08-28-2008, 10:26
can you perhaps explain how to
1) make rewards and stuff, like wc3 ft mod
2) make terrorist-only classes and ct-only classes, so depending on which team you join, you get different class choices.
Rewards like? Planting bomb and stuff?

PvtSmithFSSF
08-28-2008, 19:53
no no likeee i mean.. such as wc3 has skills where when u lvl up you choose a skill to place a point into and each skill pt enhances what that skill does.
like a skill that the more pts you got in it, the more dmg u do with deagle, n random prizes n like that

PvtSmithFSSF
08-28-2008, 20:31
btw has any1 tested this and it works okay? i dont want to start a huge mod and have this be a problem

Ps: If i'm level 5 cow and change to horse will i be level 5 horse or does xp save for each class
i can't test , no server currently

[X]-RayCat
08-29-2008, 13:39
[..]

register_concmd( "amx_take_exp", "cmd_take_exp", ADMIN_KICK, "<target> <amount>" );
register_concmd( "amx_give_exp", "cmd_give_exp", ADMIN_KICK, "<target> <amount>" );

[..]

public cmd_give_exp( id, level,cid )
{
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv(2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] += expnum;

switch( get_cvar_num ( "amx_show_activity" ) )
{
case 1: client_print( 0, print_chat, "ADMIN: gave %i points for %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: gave %i points for %s.", admin_name, expnum, player_name );
}

client_print( player, "[AMXX] You received %i points. (Total: %d)", expnum, PlayerXP[player] );

SaveData( id )

return PLUGIN_CONTINUE;
}

public cmd_take_exp( id, level,cid )
{
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv( 2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] -= expnum;

switch(get_cvar_num("amx_show_activity"))
{
case 1: client_print( 0, print_chat, "ADMIN: took %i points from %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: took %i points from %s.", admin_name, expnum, player_name );
}

client_print( player, "You received %i points. (Total: %d)", expnum, PlayerXP[player] );

SaveData( id )

return PLUGIN_CONTINUE;
}

[..]




Here is give/take exp command for this tutorial. :) If you want me to add more commands or rewards.. just ask :up:

PvtSmithFSSF
08-29-2008, 13:48
thanks dude

can you perhaps explain the question i have in my thread in scripting help? i updated post

padilha007
08-31-2008, 14:33
while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{ // this will create the Congratulations message.
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!", PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
// Add his/her level
PlayerLevel[attacker] += 1
} have one error no?

because if im in last level (3200)xp:

in code if my xp(5200) >= 3200 get one more level, Infinity cycle no?

in kill/die i get one level

This code fix ?


while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
if (PlayerLevel[attacker] <= 6) {
PlayerLevel[attacker] += 1
}
}

BlackDragonBG
09-02-2008, 07:38
Does anyone mind posting a working XP mod? I'm still learning and i don't know how to fix the errors i'm getting and i wanted to see a working plugin to see what i'm missing :(

padilha007
09-02-2008, 12:22
put your error and plugin

BlackDragonBG
09-02-2008, 15:39
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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 iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}
I just copy+pasted the plugin on the first page into a .sma file to see if it works but it gives me " Undefined symbol id" and "Undefined symbol attacker" and because of that come new errors "Expression has no effect"
I'm still a total noob at scripting and i wanted to see some simple working plugins to understand how things work and i can't fix the problems myself yet :(

padilha007
09-02-2008, 16:00
@BlackDragonBG (http://forums.alliedmods.net/member.php?u=41487)

just add:


new attacker = read_data( 1 )


And:

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
PlayerLevel[attacker] += 1
}




#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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 clip, ammo, weapon = 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(attacker, print_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(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}

BlackDragonBG
09-03-2008, 13:52
Thank you :up:

point.blank
11-02-2008, 11:52
while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
PlayerLevel[attacker] += 1
}->

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
PlayerLevel[attacker] += 1
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
}

Or else it will print the level you were before, then give you the level after the message prints.

PvtSmithFSSF
11-04-2008, 15:32
Would be awesome to see first page updated with the mod to actually work, and maybe even show how to give upgrades per level/class, perhaps like WC3 or BF2.

Mirun.Frontier
11-09-2008, 01:05
Lol, I tried removing the CS related terms and changed it into Half-life, seeing if that would work.
But it gave me errors. Go figure.
Im just changing the CSW_KNIFE weapon to weapon_crowbar, and thats the only error now in compiling.

leon_devil94
11-25-2008, 04:40
Can this save XP/Level/Rank by Nick/Name but not AuthID?

SnoW
11-27-2008, 13:22
This is tutorial for saving xp, it's not a thing like: "can this do this and that?" You should learn from this, and then make your own plugins. If you read anything from the beginning, you should know that this saves the xp with AuthID. Thought that could be easily changed to save xp by name, still I can't imagine where you would need that.

leon_devil94
11-28-2008, 06:27
By the way SnoW, I got a question to ask. I'm currently hosting a stupid + laggynes zombie server with a plugin that can save ammo pack but if i'm not mistaken,it save by AuthID and it can cause a lot of people's angry because sometimes they rejoin and their ammo packs gone and have to regain but if save with a name would be better in this case. Just need a tutorial on saving <something> by name

Particlman
12-21-2008, 15:21
I am getting an error and looking around i haven't been able to solve it. (I know this has no white space but I just wanted to show that I have it exactly the way it is in the tutorial and it isn't working.) Also if anyone can tell me how to make it so it isn't straight black so it is easier to read I will change it.

public SaveData(id)
{
// get the players steam id. We need this because we are saving by steam id
new AuthID[35] get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
// format wat is going to be in the animal mod vault file
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
// save the data
nvault_set(g_vault,vaultkey,vaultdata)
return PLUGIN_CONTINUE
}

When I compile it gives me the errors

Error: Expected token: ";", but found "-identifier-" on line 191
Error: Expected token: ";", but found "-identifier-" on line 203

line 191 is
new AuthID[35] get_user_authid(id,AuthID,34)

line 203 is the exact same line in the LoadData()

I had changed a couple things and thought it was something I changed but then I went back and copy/pasted exactly what you had here and it is still giving me the error.


EDIT:


I changed both of them to this and it compiles now with no errors or warnings. Is this the correct way to do it?

new AuthID[35]
{
get_user_authid(id,AuthID,34)
}


I would also still like to know how to post so it isn't straight black the whole way.(Thanks Lee. Much easier to read when it's not black.)

Lee
12-22-2008, 16:10
new AuthID[35]
get_user_authid(id,AuthID,34)

Curly braces are usually only used to denote where a loop, conditional, or enumeration block starts and ends.

Of course, for a SteamID to be 34 characters in length, each person on this planet would have to own approximately 1⅔×1013 Steam accounts.

You can use [php] or [pawn] tags. [pawn] tags are however rather buggy.

Particlman
12-23-2008, 14:01
Didn't think I needed them but for some reason it was being difficult that night. I probably was just really tired and should have realized that fix.

Thanks for the help, and with php tags. They are, for me at least much easier on the eyes.

ianglowz
12-26-2008, 21:23
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Undefined symbol "id" on line 43
Error: Undefined symbol "attacker" on line 45
Error: Undefined symbol "attacker" on line 48
Warning: Loose indentation on line 48
Warning: Loose indentation on line 50
Error: Undefined symbol "attacker" on line 51
Error: Undefined symbol "attacker" on line 53
Error: Undefined symbol "attacker" on line 55
Warning: Expression has no effect on line 55
Warning: Expression has no effect on line 55
Error: Undefined symbol "attacker" on line 55
Error: Undefined symbol "attacker" on line 58
Error: Undefined symbol "attacker" on line 59
Error: Invalid subscript, use "[ ]" operators on major dimensions on line 64
Warning: Expression has no effect on line 64
Error: Expected token: ";", but found "]" on line 64
Error: Invalid expression, assumed zero on line 64
Error: Too many error messages on one line on line 64

Compilation aborted.
13 Errors.
Could not locate output file C:\Program Files\AMX Mod X\amxxstudio\Untitled.amx (compile failed).

Help with this error on compiling.

padilha007
12-27-2008, 14:43
read all posts and fix that

ianglowz
12-28-2008, 01:04
Can anyone make the menu is show after the people join the team?Because people that come to my server don't know that my server using mod.

Particlman
12-28-2008, 14:06
Can anyone make the menu is show after the people join the team?Because people that come to my server don't know that my server using mod.

https://forums.alliedmods.net/showthread.php?t=42159&highlight=spawn

I used the hamsandwich version to do this
public fwHamPlayerSpawnPost(id) {
if (is_user_alive(id))
{
if (PlayerClass[id] == 0)
{
ChangeClass(id)
}
}
}
That way it is not only when they join but anytime they spawn if they haven't picked one yet

ianglowz
12-28-2008, 18:48
Thx,I get already.

ianglowz
12-29-2008, 23:29
Here.I added some glow on some level/class.Add it like this.

public plugin_init()

thickness=register_cvar("color_glow","15")
Then add this at your "ResetHUD" function.
if (PlayerLevel[id] >= 6)
{ //
set_user_health(id, 255);
set_user_rendering(id, kRenderFxGlowShell, 71, 237, 231, kRenderNormal,get_pcvar_num(thickness))
}This is example for light blue color.

ianglowz
12-30-2008, 03:34
I always get error on compile this code.

if (PlayerClass[id] == CLASS_COW)
{
set_user_health(id, 250);
}
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Undefined symbol "CLASS_COW" on line 206

1 Error.
Could not locate output file C:\Documents and Settings\home\Desktop\Pejuang\server\New server\hlds\czero\addons\amxmodx\scripting\xp mod.amx (compile failed).
Why is that happen?

padilha007
12-30-2008, 13:23
put all code

ianglowz
12-30-2008, 19:42
Nvm,now i get it.Add this.

#define CLASS_COW 1

xPaw
01-06-2009, 09:45
I cleanupped code, added give/take admin commands, and added PREFIX define (i dont know what someone need it)
#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define MAXCLASSES 5
#define PREFIX "Animal Mod"

new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
};

new const LEVELS[6] = {
100,
200,
400,
800,
1600,
3200
};

new PlayerXP[33], PlayerLevel[33], PlayerClass[33];
new gCvar_Kill, gCvar_Knife, gCvar_HS, gCvar_Enable, g_Vault;

public plugin_init() {
register_plugin("XP Mod", "1.0", "fxfighter");

register_event("DeathMsg", "eDeath", "a");

gCvar_Enable = register_cvar("xp_save", "1");
gCvar_Kill = register_cvar("xp_per_kill", "20");
gCvar_HS = register_cvar("xp_hs_bonus", "20");
gCvar_Knife = register_cvar("xp_Knife_bonus", "20");
g_Vault = nvault_open("animod");

register_concmd("amx_take_exp", "cmd_take_exp", ADMIN_KICK, "<target> <amount>");
register_concmd("amx_give_exp", "cmd_give_exp", ADMIN_KICK, "<target> <amount>");

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 clip, ammo, weapon = get_user_weapon(attacker, clip, ammo);

PlayerXP[attacker] += get_pcvar_num(gCvar_Kill);

if(headshot)
PlayerXP[attacker] += get_pcvar_num(gCvar_HS);

if(weapon == CSW_KNIFE)
PlayerXP[attacker] += get_pcvar_num(gCvar_Knife);

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {
client_print(attacker, print_chat, "[%s] Congratulations! You are a level %i %s!", PREFIX, PlayerLevel[attacker], CLASSES[PlayerClass[attacker]]);
PlayerLevel[attacker] += 1;
}

ShowHud(attacker);
SaveData(attacker);
}

public ShowHud(id) {
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = str_to_num(szCommand);
if(PlayerClass[id] != i) {
PlayerClass[id] = i;
client_print(id,print_chat,"[%s] You are now a %s", PREFIX, CLASSES[i]);
} else
client_print(id,print_chat,"[%s] You are already a %s", PREFIX, CLASSES[i]);

menu_destroy(menu);
return PLUGIN_CONTINUE;
}

public client_connect(id)
if(get_pcvar_num(gCvar_Enable) == 1)
LoadData(id);

public client_disconnect(id) {
if(get_pcvar_num(gCvar_Enable) == 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(vaultdata, 255, "#", " ");

new playerxp[32], playerlevel[32];

parse(vaultdata, playerxp, 31, playerlevel, 31);

PlayerXP[id] = str_to_num(playerxp);
PlayerLevel[id] = str_to_num(playerlevel);

return PLUGIN_CONTINUE;
}

// Give/Take XP addaon by [X]-RayCat
public cmd_give_exp( id, level,cid ) {
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv(2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] += expnum;

switch( get_cvar_num ( "amx_show_activity" ) ) {
case 1: client_print( 0, print_chat, "ADMIN: gave %i points for %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: gave %i points for %s.", admin_name, expnum, player_name );
}

client_print( player, print_chat, "[%s] You received %i points. (Total: %d)", PREFIX, expnum, PlayerXP[player] );
SaveData( id );

return PLUGIN_CONTINUE;
}

public cmd_take_exp( id, level,cid ) {
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv( 2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] -= expnum;

switch(get_cvar_num("amx_show_activity")){
case 1: client_print( 0, print_chat, "ADMIN: took %i points from %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: took %i points from %s.", admin_name, expnum, player_name );
}

client_print( player, print_chat, "[%s] You lost %i points. (Total: %d)", PREFIX, expnum, PlayerXP[player] );
SaveData( id );

return PLUGIN_CONTINUE;
}

bhuangco07
01-15-2009, 19:00
How do I make it so the xp stays on that class also how can I make skills that show up for that one class whenever they level!

TrueType
01-27-2009, 15:51
Your plugin failed to compile! Read the errors below:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/home/groups/amxmodx/tmp3/texticL7S3.sma(43) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/texticL7S3.sma(45) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/texticL7S3.sma(48) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/texticL7S3.sma(51) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/texticL7S3.sma(54) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/texticL7S3.sma(56) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/texticL7S3.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/texticL7S3.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/texticL7S3.sma(56 -- 57) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/texticL7S3.sma(59) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/texticL7S3.sma(60) : error 017: undefined symbol "attacker"

9 Errors.
Could not locate output file /home/groups/amxmodx/public_html/websc3/texticL7S3.amx (compile failed).I did just paste yours to see if there were som errors and yes.
"Any errors or anything please feel free to reply"
But xPaw's works fine.

ianglowz
01-28-2009, 07:13
Give full code if want fix..

JoeShmoe
01-29-2009, 20:37
keep getting this error when compiling
\addons\amxmodx\scripting\xptest1.sma(237) : error 010: invalid function or declaration

I've read the entire post and I just can't seem to find any solution to it. I may have overlooked something so sorry in advance. I'll attach the .sma at the bottom. Also, is there any way to use another plugin in tandem with this one?
Let's say you want to give someone access to a certain plugin command at a certain level. Would that be possible? Like giving someone access to amx_slap for example.

ianglowz
01-30-2009, 02:18
Here.Fixed

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fun>

#define MAXCLASSES 5
#define PREFIX "Animal Mod"

enum {
PLAYERLEVEL_1,
PLAYERLEVEL_2,
PLAYERLEVEL_3, // How many Levels
PLAYERLEVEL_4,
PLAYERLEVEL_5,
PLAYERLEVEL_6
}
enum {
CLASS_NONE = 0,
CLASS_COW,
CLASS_HORSE, // Add your Classes there..
CLASS_CAT,
CLASS_DOG
}
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
};

new const LEVELS[6] = {
100,
200,
400,
800,
1600,
3200
};

new PlayerXP[33], PlayerLevel[33], PlayerClass[33];
new gCvar_Kill, gCvar_Knife, gCvar_HS, gCvar_Enable, g_Vault;

public plugin_init() {
register_plugin("XP Mod", "1.0", "fxfighter");

register_event("DeathMsg", "eDeath", "a");
register_event("ResetHUD", "skill", "be");

gCvar_Enable = register_cvar("xp_save", "1");
gCvar_Kill = register_cvar("xp_per_kill", "20");
gCvar_HS = register_cvar("xp_hs_bonus", "20");
gCvar_Knife = register_cvar("xp_Knife_bonus", "20");
g_Vault = nvault_open("animod");

register_concmd("amx_take_exp", "cmd_take_exp", ADMIN_KICK, "<target> <amount>");
register_concmd("amx_give_exp", "cmd_give_exp", ADMIN_KICK, "<target> <amount>");

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 clip, ammo, weapon = get_user_weapon(attacker, clip, ammo);

PlayerXP[attacker] += get_pcvar_num(gCvar_Kill);

if(headshot)
PlayerXP[attacker] += get_pcvar_num(gCvar_HS);

if(weapon == CSW_KNIFE)
PlayerXP[attacker] += get_pcvar_num(gCvar_Knife);

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {
client_print(attacker, print_chat, "[%s] Congratulations! You are a level %i %s!", PREFIX, PlayerLevel[attacker], CLASSES[PlayerClass[attacker]]);
PlayerLevel[attacker] += 1;
}

ShowHud(attacker);
SaveData(attacker);
}

public ShowHud(id) {
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = str_to_num(szCommand);
if(PlayerClass[id] != i) {
PlayerClass[id] = i;
client_print(id,print_chat,"[%s] You are now a %s", PREFIX, CLASSES[i]);
} else
client_print(id,print_chat,"[%s] You are already a %s", PREFIX, CLASSES[i]);

menu_destroy(menu);
return PLUGIN_CONTINUE;
}

public client_connect(id)
if(get_pcvar_num(gCvar_Enable) == 1)
LoadData(id);

public client_disconnect(id) {
if(get_pcvar_num(gCvar_Enable) == 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(vaultdata, 255, "#", " ");

new playerxp[32], playerlevel[32];

parse(vaultdata, playerxp, 31, playerlevel, 31);

PlayerXP[id] = str_to_num(playerxp);
PlayerLevel[id] = str_to_num(playerlevel);

return PLUGIN_CONTINUE;
}

// Give/Take XP addaon by [X]-RayCat
public cmd_give_exp( id, level,cid ) {
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv(2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] += expnum;

switch( get_cvar_num ( "amx_show_activity" ) ) {
case 1: client_print( 0, print_chat, "ADMIN: gave %i points for %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: gave %i points for %s.", admin_name, expnum, player_name );
}

client_print( player, print_chat, "[%s] You received %i points. (Total: %d)", PREFIX, expnum, PlayerXP[player] );
SaveData( id );

return PLUGIN_CONTINUE;
}

public cmd_take_exp( id, level,cid ) {
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv( 2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] -= expnum;

switch(get_cvar_num("amx_show_activity")){
case 1: client_print( 0, print_chat, "ADMIN: took %i points from %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: took %i points from %s.", admin_name, expnum, player_name );
}

client_print( player, print_chat, "[%s] You lost %i points. (Total: %d)", PREFIX, expnum, PlayerXP[player] );
SaveData( id );

return PLUGIN_CONTINUE;
}
public skill(id)
{
if (PlayerClass[id] == CLASS_COW)
{
set_user_health(id, 250); // gives him 250 health if he's a Cow
}
}

Frogstomp
02-08-2009, 02:53
is there anyway to set what the levels give you, say at level 7 you get leap?

MIk3
02-21-2009, 11:48
Can someone make Top15 for this plugin too?:)

water
03-02-2009, 05:50
why we need to say/xp to see level?
can the level place on the left bottom?

~Ice*shOt
03-02-2009, 12:08
First of all, full credit goes to fxfighter, he revised it. All im doing is releasing this so that people wont go to the other xp mod tutorial (which doesnt work). And i added a little bit of extras so that it would be better. Anyways, on to the tutorial :) ...


Im going to show you have to make an XP mod.
Before starting, you should have basic scripting Knowledge.


Inculde all the important modules


#include <amxmodx>
#include <amxmisc>
#include <nvault>
Define the maximum classes.
Here there is 5, but if you want to add 2 more animals, like a bird and a fish, then you can put 7. But we are dealing with 5
#define MAXCLASSES 5We create the variable that is going to hold your class, xp , and level
new PlayerXP[33],PlayerLevel[33],PlayerClass[33]
//these are for special kills
new XP_Kill,XP_Knife,XP_Hs,SaveXP
//this is for Nvault. so that We can save XP
new g_vault
This is the "maxclasses" variable we were talking about. You'll see these in the game.
Code:
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
} Note that there are 5 classes. Thats why we defined maxclasses to 5


Now we create the levels, and how many xp you ned to gain a level.
There is 7 levels

Code:
new const LEVELS[7] = {
0,
100,//this means you need 100 xp
200,//this means you need 200 xp
400,//this means you need 400 xp
800,//so on
1600,//so on
3200 //so on
}Now we create the plugin_init()
public plugin_init()
{
register_plugin("XpMod", "1.0", "Fxfighter")

//we need this to check your level after you kill some one
register_event("DeathMsg", "eDeath", "a")
//is saving on?
SaveXP = register_cvar("SaveXP","1")
//how many xp are u gonna get per kill?
XP_Kill=register_cvar("XP_per_kill", "20")
//if you get a hs you get bonus xp
XP_Hs=register_cvar("XP_hs_bonus","20")
//if you make a knife kill you get bounus xp
XP_Knife=register_cvar("XP_knife_bonus","20")
//we just opened a new connection NVAULT connection
// we will call it animod
g_vault = nvault_open("animod")
// register a say command to change class
register_clcmd("say /class", "ChangeClass")
register_clcmd("say_team /class", "ChangeClass")
//show how much xp you have
register_clcmd("say /xp", "ShowHud")
register_clcmd("say_team /xp", "ShowHud")
}We are gonna create the Death function. Rember we called it "eDeath" in plugin_init()? It will keep track of your xp and if you ganined a level
Code:
public eDeath( ) //function name
{
// If the player's Class is nothing, then dont bother to do any of the below
if(PlayerClass[attacker] == 0)
return PLUGIN_CONTINUE

// We create the victim variable, so that this function can check
// if a player was killed
new iVictim = read_data( 2 )
// If a player was killed by a HeadShot, this will be used for the cvar Xp_Hs
new headshot = read_data( 3 )

//which weapon was used
new clip, ammo, weapon = get_user_weapon(id,clip,ammo);
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
// used for the xp_hs cvar
// it checks if the victim was killed by a headshot
if(headshot)
// give him/her bonus xp
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
// checks if the victim was killed by a knife
if(weapon == CSW_KNIFE)
//give him/her bonus xp
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
// this checks if the player has enough xp to advance to a new level

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{ // this will create the Congratulations message.
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!", PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
// Add his/her level
PlayerLevel[attacker] += 1
}
// shows his level on a hud message
ShowHud(attacker)

}This is the showhud function. It shows the your Class, your level, and XP
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0)
show_hudmessage(id, "Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
} Note: ^n means new line


Here is the menu selector. It will give you the options to select your animal. It uses the new menu system. I dont feel like going into detail with the new menu system, here is the original tutorial on that (http://forums.alliedmods.net/showthread.php?t=46364)
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);
}
new szCommand[6] , szName[64]; new access , callback;
menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);
new i = 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
}
This this is the client connect function. All these things happend when the player is connecting to the server
public client_connect(id)
{
// Only does it if xp saving is on
if(get_pcvar_num(SaveXP) == 1)
{
// load your player data
LoadData(id)
}
}This is the client disconect funtion. These only happen when the player has disconnected from the server
public client_disconnect(id)
{
// Only does it if xp saving is on
if(get_pcvar_num(SaveXP) == 1)
{
// lets save the data
SaveData(id)
}
}Now we create the save data function
public SaveData(id)
{
// get the players steam id. We need this because we are saving by steam id
new AuthID[35] get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
// format wat is going to be in the animal mod vault file
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
// save the data
nvault_set(g_vault,vaultkey,vaultdata)
return PLUGIN_CONTINUE
}now we create the load data function
public LoadData(id)
{
new AuthID[35] get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
// search
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
// load the data
nvault_get(g_vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new playerxp[32], playerlevel[32]
parse(vaultdata, playerxp, 31, playerlevel, 31)
PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)
return PLUGIN_CONTINUE
}
OK now everything with out comments

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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 iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}
Any errors or anything please feel free to reply

Help me plz that errors: undefined symbol "id", undefine symbol "attacker" and no effect plz help! :(

iNspiratioN
03-02-2009, 13:33
Add lines:

new id = read_data(1)
new attacker = read_data(1)public eDeath( )
{
new id = read_data(1)
new attacker = read_data (1)
new iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}

iNspiratioN
03-03-2009, 07:28
error.....can not change amxx

What? Give more INFO about your error.

water
04-02-2009, 14:05
if i want to get exp when i hit the enemy
please help me=.=

el.nino
04-09-2009, 23:51
Good tutorial but if you take all the xp of some1 you can't get more xp anymore. It doesn't stop at 0 if you know what I mean.

Edit: This is just a comment, I really enjoy the tutorial and it helped me a lot. Don't - karma me for this wow.

TitANious
06-28-2009, 05:45
if i want to get exp when i hit the enemy
please help me=.=
Use Ham_TakeDamage

Hmm, this one needs some fixes

@iNspiratioN
iAttacker = read_data( 1 )
iVictim = read_data( 2 )
iHeadshot = read_data( 3 )

drekes
09-02-2009, 16:42
I've tried to change the players models by class, so class 1 is model 1;
class 2 is model to;...
But if i add the code i get lots of errors and if i remove it again it compiles without even a warning.
Is there a particular space to add the modelchange code.
Greets

Ps: how to give karma?

scr
09-03-2009, 08:30
Ok. I all did. But how make the powers? like sh_mario or something?

williamjems
09-04-2009, 07:24
Hi Flyeni6..

It looks good. But the other one didn't work, so many people complained about it.
Hope you made the new module.
Good luck.

scr
09-04-2009, 11:15
Ok. I all did. But how make the powers? like sh_mario or something?

Fraancooo-.
09-07-2009, 16:00
Everyone wants the zombie plague, so good is?
ami I do not like anything
ON: Excellent tutorial

drekes
09-07-2009, 16:32
I've tried to change the players models by class, so class 1 is model 1;
class 2 is model to;...
But if i add the code i get lots of errors and if i remove it again it compiles without even a warning.
Is there a particular space to add the modelchange code.
Greets

Ps: how to give karma?

Help please?

scr
09-09-2009, 08:00
Ok. I all did. But how make the powers? like sh_mario or something?

OneMoreLevel
09-15-2009, 19:29
Thanks alot for this, it helped me alot.

BOYSplayCS
09-15-2009, 19:34
OneMoreLevel, this post is highly outdated. For a newer, more clean version PM me.

rikards1
09-18-2009, 11:34
... i get pretty many errors when i compile.....

rikards1
09-18-2009, 11:36
can some1 plz compile it and send the amxx to me? or put up a download link

OneMoreLevel
09-19-2009, 11:34
1. This is out of date.

2. Why dont you make it yourself.. Its a tutorial.

grimvh2
09-23-2009, 15:29
Yeah , this should be removed because theres no support.
There even mistakes in the tutorial itself

Alka
09-23-2009, 16:09
I will remake this tutorial when i will have some free time.

Features:


More readable.
Modules changes.
Dynamic custom menus.
MySQL save support.
Custom rewards.

ot_207
09-24-2009, 05:58
I will remake this tutorial when i will have some free time.

Features:


More readable.
Modules changes.
Dynamic custom menus.
MySQL save support.
Custom rewards.


Good, that would be useful for the people that don't know how to use MySQL properly.

One
09-24-2009, 06:00
yay i'm waiting for this. i want to begin with one piece mode & need a good tut for xp

drekes
09-24-2009, 13:01
thanks alka i can't wait till the new version is up.

Zpoke
10-12-2009, 15:39
nice, add a XP shop so you can buy something ? just an idea :)

Csdeath
10-29-2009, 06:28
Can some one please tell me how to create a command which resets all players xp? Something like:


amx_reset_xp-If admin types it all players xp resets to 0.

Waiting :)

Trinity
10-29-2009, 11:56
Perfect("clear")code without any bugs:

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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(id ,attacker)
{
new iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!"),
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}

Xellath
10-29-2009, 16:54
That will not even work.

Trinity
10-30-2009, 12:47
:mrgreen: say /class for example)

Akatsuki
10-30-2009, 13:04
Question how to make that it would be like when i am a 5lvl cow and when i change to horse my lvl change to 1 and when i change to cow my lvl would be again 5?
I realy need it thx!

Howdy!
10-30-2009, 13:57
Question how to make that it would be like when i am a 5lvl cow and when i change to horse my lvl change to 1 and when i change to cow my lvl would be again 5?
I realy need it thx!

Save it to nvault. :wink:

Driving To Heaven
10-31-2009, 12:11
how add effects or skills? like sh_mario or something?

Akatsuki
11-10-2009, 14:24
How to make that i get xp by damage have done?

grimvh2
11-11-2009, 06:01
How to make that i get xp by damage have done?
since this tutorial aint supported anymore + get some bad errors in it.
I should suggest starting a treath.

You can just hook damage event with hamsandwich
Get attacker , Get damage , if damage is more then x , then you give him xp.

Akatsuki
11-16-2009, 13:24
me again i know that this tutorial aint supported anymore but still help me

how can i make that hp each level would be bigger like 10%

P.S thx grimvh2 (http://forums.alliedmods.net/member.php?u=32300)

K.K.Lv
11-19-2009, 23:43
PHP Code:
public eDeath( ) //function name
{
// If the player's Class is nothing, then dont bother to do any of the below
if(PlayerClass[attacker] == 0)
return PLUGIN_CONTINUE

// We create the victim variable, so that this function can check
// if a player was killed
new iVictim = read_data( 2 )
// If a player was killed by a HeadShot, this will be used for the cvar Xp_Hs
new headshot = read_data( 3 )

//which weapon was used
new clip, ammo, weapon = get_user_weapon(id,clip,ammo);
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
// used for the xp_hs cvar
// it checks if the victim was killed by a headshot
if(headshot)
// give him/her bonus xp
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
// checks if the victim was killed by a knife
if(weapon == CSW_KNIFE)
//give him/her bonus xp
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
// this checks if the player has enough xp to advance to a new level

while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{ // this will create the Congratulations message.
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!", PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
// Add his/her level
PlayerLevel[attacker] += 1
}
// shows his level on a hud message
ShowHud(attacker)

}


Hey guy !!
fix your error, in DeathMsg, you must write like this:

public plugin_init()
{
register_event("DeathMsg", "eDeath", "a");
//...
}

public eDeath()
{
new iKiller = read_data(1) //get the killer index
new iVictim = read_data(2) //get the victim index
new headshot = read_data(3) get the headshot
new weapon_name[24]
read_data(4, weapon_name, 23) //get the weapon
//your code
}

grimvh2
11-24-2009, 15:32
how can i make that hp each level would be bigger like 10%


Save the xp for the first level,
Then when your function is called to give a player xp, you check if the player his xp is more then: level 1 xp x (current level + 1) x 10%

example : if level one is 1000xp
level 2 : 1000xp x 2 x 10%, meaning you would need 2020xp to get level 2.

Akatsuki
11-24-2009, 15:40
i didnt understand sorry but would ir work like this
if(PlayerLevel[id] <= 5)
{
new health = get_user_health(id);
set_user_health(id, health*0.1);
}

lazarev
11-25-2009, 00:29
new givehp;
givehp = register_cvar("amx_givehp", "5");

if(PlayerLevel[id] <= 5)
{
new hp = get_user_hp(id);
set_user_health(id, hp + get_pcvar_num(givehp))
}

Akatsuki
11-26-2009, 04:58
Could you make that there weren't any cvas becouse i won't write 15 times the same and i need that hp would be bigger x times not by + but by x

matsi
11-26-2009, 17:47
Could you make that there weren't any cvas becouse i won't write 15 times the same and i need that hp would be bigger x times not by + but by x

Part 4 - Mathematical Operators

by Exolent[jNr] (http://forums.alliedmods.net/member.php?u=25165)

Basic Usage
We all know the standard mathematical operations:

Addition
Subtraction
Multiplication
Division

These are easily used in programming.

new x = 1, y = 4;

// Addition
x = y + 1; // x now equals 5

// Subtraction
y = x - 2; // y now equals 2

// Multiplication
x = y * 2; // x now equals 4

// Division
y = 12 / x; // y now equals 3

Taken from Programming for starters (http://forums.alliedmods.net/showthread.php?t=91207)

teol
12-13-2009, 00:52
Can you just give us the most important things to be able to create differents powers for differents classes ?

Thanks, good job

Zapdos1
12-23-2009, 21:44
i was using this tutorial, but when someone kill another person, this guy doesnt win XP
(sorry for my english)

r4ndomz
01-04-2010, 15:38
Can you just give us the most important things to be able to create differents powers for differents classes ?

Thanks, good job


Yea id like how to make abilitys and skills for the classes too

matsi
01-04-2010, 16:49
I might do a test mod with classes/abilities etc later.. :)

EDIT: Should it be like in warcraft?

r4ndomz
01-08-2010, 07:04
What do you mean? Like the skills and abilities?

matsi
01-08-2010, 09:11
What do you mean? Like the skills and abilities?Yes. :grrr:

NiQu
01-09-2010, 16:28
Good tutorial, helped me alot in the begining :)

Anyways, i was able to create a whole mod with the use of this tutorial, after reading the tutorial 2-3 times acutally made a mod with abilliites and lots of stuff.

Thanks :)

KadiR
01-09-2010, 18:07
How a stupid tutorial, which has so much errors, hah! :mrgreen:

Xalus
01-10-2010, 06:18
I think ur stupid..
It works for everyone!

ehha
01-10-2010, 07:05
Yeah, it compiles & works but there are some bugs. You are the stupid one if you can't see & fix them.

KadiR
01-10-2010, 11:43
Kidding me? :mrgreen:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Undefined symbol "id" on line 43
Error: Undefined symbol "attacker" on line 45
Error: Undefined symbol "attacker" on line 48
Error: Undefined symbol "attacker" on line 51
Error: Undefined symbol "attacker" on line 54
Error: Undefined symbol "attacker" on line 56
Warning: Expression has no effect on line 56
Warning: Expression has no effect on line 56
Error: Undefined symbol "attacker" on line 56
Error: Undefined symbol "attacker" on line 59
Error: Undefined symbol "attacker" on line 60

9 Errors.
Could not locate output file C:\Dokumente und Einstellungen\xPaw\Desktop\AMX Mod X Studio\compiled\Untitled.amx (compile failed).

xPaw
01-10-2010, 11:52
How a stupid tutorial, which has so much errors, hah! :mrgreen:

Shut up, and make a better then.

matsi
01-10-2010, 12:08
Kidding me? :mrgreen:
Anyone who can code can fix those errors. But clearly you're not one of them. :grrr:

One
01-10-2010, 12:22
Shut up, and make a better then.
ok. this time is xpaw right :P

xPaw
01-10-2010, 13:05
C:\Dokumente und Einstellungen\xPaw

fanboy ? O_o"

One
01-10-2010, 13:28
C:\Dokumente und Einstellungen\xPaw

fanboy ? O_o"
:stupid: http://images.paraorkut.com/img/funnypics/images/l/lol_cat-12926.jpg

KadiR
01-10-2010, 16:06
Shut up? :)

HEHEHEHE, if you are going to post a tutorial, you should make one without any errors kid..:wink:

PS:

i knew that you read the xPaw folder XD
but I think, kid is better..

btw:

read post #147

aknp-
01-15-2010, 03:11
I have one question, namely: you get one or someone gives me this error: ED_Alloc, no free adicts
#include <amxmodx>
#include <nvault>
#include <fun>
#include <cstrike>

//Max classes
#define MAXCLASSES 8

enum {
CLASS_NONE = 0,
CLASS_SAKURA,
CLASS_HINATA,
CLASS_INNO,
CLASS_YAMATO,
CLASS_KAKASHI,
CLASS_SASUKE,
CLASS_NARUTO
}
#define MAXLEVELS 90

new const CLASSES[MAXCLASSES][] = {
"None",
"Sakura",
"Hinata",
"Inno",
"Yamato",
"Kakashi",
"Sasuke",
"Naruto"
}

//Heer you can add more levels
new const LEVELS[MAXLEVELS] = {
100,
200,
300,
400,
500,
600,
700,
800,
900,
1000,
1100,
1200,
1300,
1400,
1500,
3000,
3200,
3400,
3600,
3800,
4000,
4200,
4400,
4600,
4800,
5000,
5200,
5400,
5600,
5800,
11600,
11900,
12200,
12500,
12800,
13100,
13400,
13700,
14000,
14300,
14600,
14900,
15200,
15500,
15800,
31600,
32000,
32400,
32800,
33200,
33600,
34000,
34400,
34800,
35200,
35600,
36000,
36400,
36800,
37200,
74400,
74900,
75400,
75900,
76400,
76900,
77400,
77900,
78400,
78900,
79400,
79900,
80400,
80900,
81400,
162800,
163400,
164000,
164600,
165200,
165800,
166400,
167000,
167600,
168200,
168800,
169400,
170000,
170600,
171200
}
//Variables that store the players lv xp and class
new PlayerXP[33],PlayerLevel[33],PlayerClass[33]

//Pcvars
new XP_Kill,XP_Knife,XP_Hs,XP_Perfect,SaveXP,g_va ult

public plugin_init()
{
register_plugin("Naruto Mod", "1.0.1", "RnL")

//death event
register_event("DeathMsg", "eDeath", "a")
register_event("ResetHUD","on_spawn","be"); // When the player spawns

//cvars
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")
//XP_Defuse=register_cvar("XP_defuse","20")
XP_Perfect=register_cvar("XP_perfect","20")
//XP_Plant=register_cvar("XP_plant","20")
g_vault = nvault_open("animod")

//say cmds
register_clcmd("say /clasa", "ChangeClass")
register_clcmd("say_team /clasa", "ChangeClass")
register_clcmd("say /info", "ShowHud")
register_clcmd("say_team /info", "ShowHud")


}

// Example
public on_spawn(id)
{
if (PlayerClass[id] == CLASS_SAKURA || PlayerLevel[id] == 1) // Checks Class and Level.
{
set_user_health(id, 120); // gives him 250 health if he's a Cow on level 5
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
give_item(id,"weapon_deagle"); //
}
if (PlayerClass[id] == CLASS_HINATA || PlayerLevel[id] == 2) // Checks Class and Level.
{
set_user_health(id, 150); // gives him 250 health if he's a Cow on level 5
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
give_item(id,"weapon_m4a1"); //
}
if (PlayerClass[id] == CLASS_INNO || PlayerLevel[id] == 3) // Checks Class and Level.
{
set_user_health(id, 150); // gives him 250 health if he's a Cow on level 5
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
give_item(id,"weapon_usp"); //
}
if (PlayerClass[id] == CLASS_YAMATO || PlayerLevel[id] == 4) // Checks Class and Level.
{
set_user_health(id, 200); // gives him 250 health if he's a Cow on level 5
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
give_item(id,"weapon_deagle"); //
}
if (PlayerClass[id] == CLASS_KAKASHI || PlayerLevel[id] == 5) // Checks Class and Level.
{
set_user_health(id, 250); // gives him 250 health if he's a Cow on level 5
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
give_item(id,"weapon_awp"); //
}
if (PlayerClass[id] == CLASS_SASUKE || PlayerLevel[id] == 6) // Checks Class and Level.
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
{
set_user_health(id, 300); // gives him 250 health if he's a Cow on level 5
give_item(id,"weapon_ak47"); //
}
if (PlayerClass[id] == CLASS_KAKASHI || PlayerLevel[id] == 7) // Checks Class and Level.
{
set_user_health(id, 350); // gives him 250 health if he's a Cow on level 5
set_user_gravity(id, 0.8);
set_user_armor(id, 115);
give_item(id,"weapon_m4a1"); //
}
}

public eDeath( )
{
//Get attacker ,weapon and hs
new headshot,attacker = read_data( 1 )
new weapon = get_user_weapon(attacker,headshot,headshot)
headshot = read_data( 3 )
new health = get_user_health(attacker)

//If the killer dont have a class do nothing
if(PlayerClass[attacker] == 0)
return PLUGIN_CONTINUE

//Increase xp
PlayerXP[attacker] += get_pcvar_num(XP_Kill)

//Give bonus xp if he got hs
if(headshot)
PlayerXP[attacker] += get_pcvar_num(XP_Hs)

// Gives bonus if attacker has full hp
if(health == 100)
PlayerXP[attacker] += get_pcvar_num(XP_Perfect)

//Give bonus xp if the gun is a knife
if(weapon == CSW_KNIFE)
PlayerXP[attacker] += get_pcvar_num(XP_Knife)

//Lv up if he have enugh xp
while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
client_print(attacker, print_chat, "[%s] Felicitari! Ai ajuns la nivelul %i %s!",PlayerLevel[attacker],CLASSES[PlayerClass[attacker]])
PlayerLevel[attacker] += 1
}

//Show the hud and saves his data
ShowHud(attacker)
SaveData(attacker)
return PLUGIN_CONTINUE
}
public OnHealth(id)
{
if(PlayerLevel[id] == 90) // Checks level.
{
set_user_health(id, 255);
}
}

//Our hud message
public ShowHud(id)
{
client_print(id, print_chat, "Nivel: %i",PlayerLevel[id])
client_print(id, print_chat, "Element: %s",CLASSES[PlayerClass[id]])
client_print(id, print_chat, "Experienta: %i",PlayerXP[id])
}
//Our menu
public ChangeClass(id)
{
//Create our menu change the "Class Menu" to the name you want
new menu = menu_create("Naruto Clase" , "Class_Handle")

//Add option for each class
menu_additem(menu ,"Sakura", "1" , 0);
menu_additem(menu ,"Hinata", "2" , 0);
menu_additem(menu ,"Inno", "3" , 0);
menu_additem(menu ,"Yamato", "4" , 0);
menu_additem(menu ,"Kakashi", "5" , 0);
menu_additem(menu ,"Sasuke", "6" , 0);
menu_additem(menu ,"Naruto", "7" , 0);

//Set exit
menu_setprop(menu , MPROP_EXIT , MEXIT_ALL);

//Show menu
menu_display(id , menu , 0);

return PLUGIN_CONTINUE;

}
public Class_Handle(id , menu , item)
{
//If he choice exit then destroy the menu
if(item == MENU_EXIT)
{
menu_destroy(menu);
}

//Create some variables to store the data
new szCommand[6] , szName[64];
new access , callback;

//Get what he pressed
menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

//I is now the same number as the option he picked
new i = str_to_num(szCommand)

//Ff player dont have the class set the class to the option he picked
if(PlayerClass[id] != i)
{
PlayerClass[id] = i
client_print(id,print_chat,"[%s] Acum esti %s",CLASSES[i])
}
//Else print this message
else
{
client_print(id,print_chat,"[Kage] Esti deja %s",CLASSES[i])
}
//Destroy the menu and return
menu_destroy(menu);
return PLUGIN_CONTINUE
}

//When someone connects cheek if the xp cvar if on loadxp
public client_authorized(id)
{
if(get_pcvar_num(SaveXP) == 1)
{
LoadData(id)
}
}

//When someone leaves cheek if the xp cvar if on savexp
public client_disconnect(id)
{
if(get_pcvar_num(SaveXP) == 1)
{
SaveData(id)
}
//After we saved we sets his values to 0 so the guy
//ho joins later dont get his stuff
PlayerXP[id] = 0
PlayerLevel[id] = 0
PlayerClass[id] = 0
}

//Our save function
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
}

//Our load function
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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Lure.d
02-21-2010, 09:34
"how to fix no free edicts once and for all":
http://forums.multiplay.co.uk/half-life-sven-co-op/63261-how-fix-no-free-edicts-error-once-all

Mirun.Frontier
03-08-2010, 23:45
I get alot of unidentified symbol Attacker, ID, and some loose identations, then compile doesn't work.

wrecked_
03-08-2010, 23:53
I get alot of unidentified symbol Attacker, ID, and some loose identations, then compile doesn't work.
You need to cache the attacker data in the deathmsg.

new attacker = read_data( 1 )
// new victim = read_data( 2 )

maakera
04-28-2010, 17:50
help im getting error:
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(43) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(45) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(48) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(51) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(54) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56 -- 57) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(59) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(60) : error 017: undefined symbol "attacker"

wrecked_
04-28-2010, 18:06
help im getting error:
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(43) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(45) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(48) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(51) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(54) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(56 -- 57) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(59) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpmr8vaa.sma(60) : error 017: undefined symbol "attacker"

You need to cache the attacker data in the deathmsg.

new attacker = read_data( 1 )
// new victim = read_data( 2 )

SaM.ThE.MaN
06-01-2010, 11:53
i tried compiling this and i am getting these errors :

/groups/amxmodx/tmp3/textLUJT1R.sma(57 -- 59) : error 001: expected token: ",", but found "}"
/groups/amxmodx/tmp3/textLUJT1R.sma(62) : warning 204: symbol is assigned a value that is never used: "iVictim"

1 Error.
Could not locate output file /home/groups/amxmodx/public_html/websc3/textLUJT1R.amx (compile failed).


Code :
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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(id)
{
new headshot = read_data( 3 )
new iVictim = read_data( 2 )
new attacker = read_data( 1 )
new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}

drekes
06-01-2010, 12:35
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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(id)
{
new headshot = read_data( 3 )
new attacker = read_data( 1 )
new clip, ammo, weapon = get_user_weapon(id,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]])
{
PlayerLevel[attacker] += 1
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!", PlayerLevel[attacker], CLASSES[PlayerClass[attacker]])
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}

SaM.ThE.MaN
06-01-2010, 15:32
lol , i tried this and when i kill some one i dont get any XP nor lvl up

drekes
06-01-2010, 18:50
lol , i tried this and when i kill some one i dont get any XP nor lvl up

Got error logs? Or something else

SaM.ThE.MaN
06-02-2010, 02:38
nvm , i fixed it ...

Razvanika
06-22-2010, 02:41
need reset_xp (admin command)

linkosc
06-30-2010, 08:44
Hello I am using this tutorial I like it alot. I have a Question. How would I stop players from changing class mid round. I would like for them to wait till new round b4 it let them change to the new class. Kinda like wc3ft mod. You can select a new class but it wont change until next round. THX.

DarkGod
06-30-2010, 12:02
Make a boolean which is set to true when they select their class and false on round end / round start / player spawn.

linkosc
06-30-2010, 19:16
can i get a good example of how this would be done?

wrecked_
06-30-2010, 21:27
can i get a good example of how this would be done?
https://forums.alliedmods.net/showthread.php?t=128001&highlight=TIME_INTERVAL

#5 is where the example is. It's for respawning, but you should be able to get how it works. This actually uses the times instead of a bool, which is generally cleaner.

Kreation
07-17-2010, 15:16
public eDeath( )
{
new iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(id,clip,ammo);


:arrow:

public eDeath( )
{
new iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(iVictim,clip,ammo);


I don't know how that wasn't caught yet.

Erox902
07-26-2010, 05:28
hey i was just wondering if i wanted a class to be locked until u for example reach level 7 with the first class... and then in the next class u start the levels over again?

-------------------------------------

forget the above i'll rather get the answer of how to make only one class witch will change name when u like above reach level 7 then changes again after ***levels and so on if anyone could be nice to help me with that? :)

waluss
07-29-2010, 12:26
Hi all.

I'll be wonder if you want help me with this:

public zp_round_started(id)
{
new armor = 599;
new health = 399;
new Float:grava = 0.5;

if (PlayerLevel[id] == 6)
{
set_user_armor(id, armor)
set_user_gravity(id, grava)
set_user_health(id, health)
set_pev(id, pev_maxspeed, 299)
}


Problem is here "set_pev(id, pev_maxspeed, 299)" and why it doesnt work?

I tried with set_user_maxspeed but it doesn't work too.

Vechta
07-29-2010, 13:10
Hi all.

I'll be wonder if you want help me with this:

public zp_round_started(id)
{
new armor = 599;
new health = 399;
new Float:grava = 0.5;

if (PlayerLevel[id] == 6)
{
set_user_armor(id, armor)
set_user_gravity(id, grava)
set_user_health(id, health)
set_pev(id, pev_maxspeed, 299)
}


Problem is here "set_pev(id, pev_maxspeed, 299)" and why it doesnt work?

I tried with set_user_maxspeed but it doesn't work too.

use fm_set_user_speed..
fm_set_user_maxspeed(id, 299.0)
don't forget
#include <fakemeta>

wrecked_
07-29-2010, 20:40
use fm_set_user_speed..
fm_set_user_maxspeed(id, 299.0)
don't forget
#include <fakemeta>
No no no.

set_pev( id, pev_maxspeed, 299.0 )

Vechta
07-30-2010, 03:09
No no no.

set_pev( id, pev_maxspeed, 299.0 )

lol, just set .0 ?

waluss
07-30-2010, 04:44
Originally Posted by wrecked_
No no no.

Code:
set_pev( id, pev_maxspeed, 299.0 )

lol, just set .0 ?


Thanks for help, but i think that problem is higher, in Zombie plague plugin.

And there my speed is changing for normal when round start.

Can someone help ?

@EDIT ok i do it :P thanks all for help :)

I need to use:
- in plugin_init register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
- and something like that:
public fw_PlayerPreThink(id)
{
if(PlayerLevel[id] >= 4)
set_pev(id, pev_maxspeed, get_user_maxspeed(id)+13.0)
}

r14170
08-01-2010, 07:32
nice tut..

wrecked_
08-04-2010, 02:10
lol, just set .0 ?
Yes, to make it a float value.

t3hNox
08-04-2010, 05:28
I would appreciate if anyone could show some code examples how to make every class individual levels and experience and how to save and load all the stuff afterwards.

I guess there should be used multidimensional arrays and I have no clue how it can be done (especially saving and loading part). Maybe there is a plugin that has classes, levels and experience and doesn't have very complicated code ?

wrecked_
08-04-2010, 14:35
I would appreciate if anyone could show some code examples how to make every class individual levels and experience and how to save and load all the stuff afterwards.

I guess there should be used multidimensional arrays and I have no clue how it can be done (especially saving and loading part). Maybe there is a plugin that has classes, levels and experience and doesn't have very complicated code ?
enum Class
{
Dog,
Bear,
Cat
}

enum Data
{
Level,
EXP
}

new pInfo[33][Class][Data]

// pInfo now holds each class and the player's Level+EXP with each

// pInfo[id][Bear][Level] = Level of the player when his class is Bear
// pInfo[id][Cat][EXP] = EXP of the player when his class is Cat

To save, just save each value in a string, then store it in nVault.
Loading will just involve getting the string, parsing it, and assigning each variable (Level+EXP) to the values retrieved from nVault.

t3hNox
08-05-2010, 03:42
Thanks wrecked_ !

About that saving, did you mean this (example for one class) ?
pInfo[id][Cat][Level] = pCatLevel
pInfo[id][Cat][EXP] = pCatEXP



And a quick question. Can I set some abilities to a player according to his level in this way?
switch(pInfo[id][Cat][Level])
{
case 1: //if he has 1st level
case 2: //if 2nd
case 3: //if 3rd
default: //if 0? "default" in this case will be 0 ?
}

Devil259
08-05-2010, 04:07
In your case, default is called when his level is not 1, 2 or 3.

t3hNox
08-05-2010, 07:02
Devil259, thanks, that will do :)

I came across another problem. I don't know how to assign pInfo[33][Class][Data] Class value. Umm.. pInfo[id][Class] = Cat ?
I'm trying this:
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 , 5 , szName , 63 , callback);

new i = str_to_num(szCommand)
if(PlayerClass[id] != i)
{
PlayerClass[id] = i
client_print(id,print_chat,"You have selected %s class.",CLASSES[i])

//Look here below.
switch(i)
{
case 1: pInfo[id][Class] = Dog
case 2: pInfo[id][Class] = Bear
case 3: pInfo[id][Class] = Cat
}
}
else
{
client_print(id,print_chat,"You are alredy a %s.",CLASSES[i])
}

menu_destroy(menu);
return PLUGIN_CONTINUE
}

titanak
08-11-2010, 18:18
we can say . Mega failed TUT Topic for this.

lashsh
08-28-2010, 14:14
XP title e.g 1 kill 10 XP, and 800 XP title serious player
XP

0 XP
100 XP
200 XP
400 XP
800 XP
1600 XP
3200 XP

Tittles

0 XP lamer
100 XP Beginner
200 XP Amateur
400 XP Professional
800 XP Master
1600 XP Igrok
3200 XP Counter-Strike Pather

pleace give me this plugin or create

qlail
09-01-2010, 00:42
https://forums.alliedmods.net/showthread.php?t=42159&highlight=spawn

I used the hamsandwich version to do this
public fwHamPlayerSpawnPost(id) {
if (is_user_alive(id))
{
if (PlayerClass[id] == 0)
{
ChangeClass(id)
}
}
}That way it is not only when they join but anytime they spawn if they haven't picked one yet
You should change


//[...]
if(is_user_alive(id))
{
if(PlayerClass[id] == 0)
{
ChangeClass(id)
}
}To....

//[....]
if(is_user_alive(id))
{
if(PlayerClass[id] == CLASS_NONE)
{
ChangeClass(id)
}
}

glhf3000
09-30-2010, 13:09
Thanks for tutorial!
I've used it as base for my private Zombie XP plugin

dias
10-03-2010, 06:35
Compile Error with original Code

albert123
10-05-2010, 21:38
This is an example, try to make by yourself.

Vechta
10-06-2010, 12:31
In1ernal Error;1312148']Thanks for tutorial!
I've used it as base for my private Zombie XP plugin

This is retard example to make a XP Mod for zp..

AlgoChikitito
04-19-2011, 08:56
Hello. Someone knows because it levels up, Get xp but not enough to go up, always on level 0 with 7000 xp

Mirun.Frontier
04-25-2011, 00:05
Hello. Someone knows because it levels up, Get xp but not enough to go up, always on level 0 with 7000 xp

I don't understand your post, can you make it a bit clearer?

Neeeeeeeeeel.-
04-25-2011, 15:31
He said that when a player have enough xp to level up, the player don't up a level.
But i fixed for him.

kaiboy
05-10-2011, 01:18
If i want to up level of gun need what to make
Sorry,I not good ar Englsih

TheArmagedon
05-10-2011, 12:01
When I kill myself I gain exp .. has some way to change this?
Is to do when I kill somebody there I gain exp.

kDiosn
05-15-2011, 05:49
neeeeeeeeeeel.- , how did you fix it for him? i got the same problem :cry:

Erox902
05-15-2011, 10:33
When I kill myself I gain exp .. has some way to change this?
Is to do when I kill somebody there I gain exp.

in the deathmsg declare the victim & attacker teams and if the victim is on the same team as the attacker don't add any xp...

liinuus
05-23-2011, 01:39
in the deathmsg declare the victim & attacker teams and if the victim is on the same team as the attacker don't add any xp...
or just check if victim and attacker is the same person

Erox902
05-23-2011, 02:19
or just check if victim and attacker is the same person

yes but I would use the method I wrote cuz then it can catch if it's a teamkill aswell :mrgreen:

jc980
05-23-2011, 16:11
When I kill myself I gain exp .. has some way to change this?
Is to do when I kill somebody there I gain exp.

i loled at this, every time i fall and die, i recieve XP. lol

liinuus
05-24-2011, 09:37
yes but I would use the method I wrote cuz then it can catch if it's a teamkill aswell :mrgreen:
Have you ever heard of free for all servers? u can just add an cvar to see if it should accept teamkill

Erox902
05-24-2011, 18:47
Have you ever heard of free for all servers? u can just add an cvar to see if it should accept teamkill

not quite sure i understand you... if so you still have to declare the teams if ur gonna use it to maybe loose exp instead, right? :S

extreem
06-14-2011, 15:10
I can't to compile plugin.
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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 iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Undefined symbol "id" on line 43
Error: Undefined symbol "attacker" on line 45
Error: Undefined symbol "attacker" on line 48
Error: Undefined symbol "attacker" on line 51
Error: Undefined symbol "attacker" on line 54
Error: Undefined symbol "attacker" on line 56
Warning: Expression has no effect on line 56
Warning: Expression has no effect on line 56
Error: Undefined symbol "attacker" on line 56
Error: Undefined symbol "attacker" on line 59
Error: Undefined symbol "attacker" on line 60

9 Errors.
Could not locate output file D:\Server\cstrike\addons\amxmodx\plugins\Unti tled.amx (compile failed).

Erox902
06-14-2011, 16:59
I can't to compile plugin.


read through the whole thread the issues have been pointed out more than once i promise you -.-

Vechta
06-16-2011, 09:14
under public eDeath( )
add
new attacker = read_data(1)

Exolent[jNr]
06-16-2011, 10:02
This should be your death function:
public eDeath( )
{
new attacker = read_data( 1 )
new iVictim = read_data( 2 )

if(attacker == iVictim || !is_user_connected(attacker) || get_user_team(attacker) == get_user_team(iVictim)) return;

new headshot = read_data( 3 )

new weapon[7]
read_data( 4, weapon, charsmax( weapon ) )

PlayerXP[attacker] += get_pcvar_num(XP_Kill)

if(headshot)
PlayerXP[attacker] += get_pcvar_num(XP_Hs)

if(equal(weapon, "knife"))
PlayerXP[attacker] += get_pcvar_num(XP_Knife)


while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
client_print(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}

usaexelent
06-22-2011, 06:28
Don't you need this line new attacker = read_data( 1 )
And BTW this plugin doesn't compile

Erox902
06-22-2011, 07:07
Don't you need this line new attacker = read_data( 1 )
And BTW this plugin doesn't compile

no shit you can accually copy & paste what exolent just wrote to make it work.

RuleBreaker
06-23-2011, 13:07
Great tut thanks for sharing ;)
But how to add that players gets e.g. more HP every lvl?

RuleBreaker
08-02-2011, 06:43
After eDeath you forgot:
new attacker = read_data (1)
and you need to change
new clip, ammo, weapon = get_user_weapon(id,clip,ammo);
to
new clip, ammo, weapon = get_user_weapon(attacker,clip,ammo);

Krle
08-02-2011, 07:05
@RuleBreaker
Try something like this
if(PlayerLevel[id] > 5)
{
set_user_health
}
And so on..

P.S I'm from KGB Forum (Krle97)

@EDIT ooh i forgot... For every class levels are same? Any way to fix it?

liinuus
08-02-2011, 11:50
@RuleBreaker
Try something like this
if(PlayerLevel[id] > 5)
{
set_user_health
}
And so on..

P.S I'm from KGB Forum (Krle97)

@EDIT ooh i forgot... For every class levels are same? Any way to fix it?
save & load the levels to an class

Krle
08-02-2011, 18:51
liinuus thanks for advice. gonna try something now -.-


public SaveData ( id )
{
new AuthID[35]
get_user_authid(id, AuthID, 34)

new vaultkey[64]
new 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
}


So this is how is written, but doesn't work :\

liinuus
08-03-2011, 15:01
as i said, right now your jsut saving xp and level to an steam id, save & load it from steam id and class instead

Krle
08-03-2011, 17:36
I'm confused :S I'm just new to pawn and i don't know much :(

Can you tell me exactly what i need to do :(

If you want i can PM you with the code cause its private :)

liinuus
08-04-2011, 09:27
for ex you can change the vaultkey format and add an variable for the class aswell, (you need to add both in the save & load), and then call the load at every class change

Krle
08-04-2011, 14:02
Nevermind :D

I will try to find another XP TuT, this really suck :D

dangerlord63
09-18-2011, 04:44
i cant gain exp when i killed someone
Help Me Man :D

Erox902
09-18-2011, 05:29
Nevermind :D

I will try to find another XP TuT, this really suck :D
Dude this is one of the simplest tutorials on theese forum, only problem is that it's not that well explained

liinuus
09-19-2011, 11:15
Untested. this is a way of using different xp per class


#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <hamsandwich>


#define MAX_CLASSES 5
#define MAX_LEVELS 6

enum
{
CLASS_NONE,
CLASS_DOG,
CLASS_CAT,
CLASS_HORSE,
CLASS_COW
}

new const g_szClasses[ MAX_CLASSES ][ ] =
{
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}

new const g_iLevels[ MAX_LEVELS ] = {
100,
200,
400,
800,
1600,
3200
}

new g_iPlayerXp[ 33 ][ MAX_CLASSES ], g_iPlayerLevel[ 33 ][ MAX_CLASSES ], g_iPlayerClass[ 33 ], g_iClassNextRound[ 33 ];
new g_iKillXP, g_iKnifeBonus, g_iHSBonus, g_iSaveXP;
new g_Vault;
new const g_szVaultName[ ] = "animod";

public plugin_init()
{
register_plugin("XpMod", "1.0", "liinuus")

register_event("DeathMsg", "eDeath", "a")

register_clcmd("say /class", "ChangeClass")
register_clcmd("say_team /class", "ChangeClass")
register_clcmd("say /xp", "ShowHud")
register_clcmd("say_team /xp", "ShowHud")

RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawnPost", 1 );

g_iSaveXP = register_cvar( "SaveXP", "1" )

g_iKillXP = register_cvar( "Kill_XP", "10" )

g_iKnifeBonus = register_cvar( "KnifeBonus_XP", "10" )

g_iHSBonus = register_cvar( "HSBonus_XP", "5" )

g_Vault = nvault_open(g_szVaultName)
}


public eDeath( )
{
new attacker = read_data( 1 )
new iVictim = read_data( 2 )

if( attacker == iVictim || !is_user_connected( attacker ) || get_user_team( attacker ) == get_user_team( iVictim )) return;

new headshot = read_data( 3 )

new weapon[7]
read_data( 4, weapon, charsmax( weapon ) )

g_iPlayerXp[ attacker ][ g_iPlayerClass[ attacker ] ] += get_pcvar_num( g_iKillXP )


if( headshot )
g_iPlayerXp[ attacker ][ g_iPlayerClass[ attacker ] ] += get_pcvar_num( g_iHSBonus )

if( equal( weapon, "knife" ) )
g_iPlayerXp[ attacker ][ g_iPlayerClass[ attacker ] ] += get_pcvar_num( g_iKnifeBonus )


while( g_iPlayerXp[ attacker ][ g_iPlayerClass[ attacker ] ] >= g_iLevels[ g_iPlayerLevel[ attacker ][ g_iPlayerClass[ attacker ] ] ])
{
client_print( attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!", g_iPlayerLevel[ attacker ][ g_iPlayerClass[ attacker ] ], g_szClasses[ g_iPlayerClass[ attacker ] ] )
g_iPlayerLevel[ attacker ][ g_iPlayerClass[ attacker ] ] += 1
}

ShowHud( attacker )
SaveData( attacker )
}
public ShowHud( iPlayer )
{
set_hudmessage( 255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0 )
show_hudmessage( iPlayer, "Level: %i^nXP: %i^nClass: %s",g_iPlayerLevel[ iPlayer ][ g_iPlayerClass[ iPlayer ] ],g_iPlayerXp[ iPlayer ][ g_iPlayerClass[ iPlayer ] ],g_szClasses[ g_iPlayerClass[ iPlayer ] ] )
}
public ChangeClass( iPlayer )
{
new menu = menu_create("Class Menu" , "Class_Handle");

new szNum[ 3 ];

for( new i; i < MAX_CLASSES; i++ )
{
num_to_str( i, szNum, 3 )

menu_additem( menu, g_szClasses[ i ], szNum )
}

menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );

menu_display( iPlayer, menu, 0 );

return PLUGIN_CONTINUE;
}
public Class_Handle(iPlayer , menu , item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}

new szCommand[ 6 ] , szName[ 64 ];
new access, callback;

menu_item_getinfo( menu , item , access , szCommand , 5 , szName , 63 , callback );

new i = str_to_num( szCommand )

if( g_iPlayerClass[ iPlayer ] != i )
{
g_iClassNextRound[ iPlayer ] = i

client_print( iPlayer, print_chat, "Your class will be changed to %s when you spawn", g_szClasses[ i ] )

}
else
client_print( iPlayer, print_chat, "You are alredy a %s", g_szClasses[ i ] )

menu_destroy( menu );
return PLUGIN_CONTINUE
}
public FwdPlayerSpawnPost( iPlayer )
{
if( is_user_alive( iPlayer ) )
{
if( g_iClassNextRound[ iPlayer ] )
{
g_iPlayerClass[ iPlayer ] = g_iClassNextRound[ iPlayer ]
g_iClassNextRound[ iPlayer ] = 0
ShowHud( iPlayer )
}
}
}

public client_connect( iPlayer )
{
if( get_pcvar_num( g_iSaveXP ) != 0 )
LoadData( iPlayer )
}
public client_disconnect( iPlayer )
{
if(get_pcvar_num( g_iSaveXP ) != 0)
SaveData( iPlayer )

ResetAll( iPlayer )
}
public SaveData( iPlayer )
{
new vaultdata[ 256 ], vaultkey[ 64 ], Authid[ 35 ]

get_user_authid( iPlayer,Authid,34 )

for( new i; i < MAX_CLASSES; i++ )
{
format( vaultkey, 63,"%s-Mod-%i", Authid, i )
format( vaultdata, 63,"%i#%i#", g_iPlayerXp[ iPlayer ][ i ], g_iPlayerLevel[ iPlayer ][ i ] )
nvault_set( g_Vault,vaultkey,vaultdata )
}

return PLUGIN_CONTINUE;
}

public LoadData( iPlayer )
{
new Authid[ 35 ]

get_user_authid( iPlayer,Authid,34 )

new vaultdata[ 256 ], vaultkey[ 64 ]
new playerxp[ 32 ], playerlevel[ 32 ]

for( new i; i < MAX_CLASSES; i++ )
{
format( vaultkey,63,"%s-Mod-%i",Authid, i )
nvault_get( g_Vault,vaultkey,vaultdata,255 )

replace_all(vaultdata, 255, "#", " ")



parse( vaultdata, playerxp, 31, playerlevel, 31 )

g_iPlayerXp[ iPlayer ][ i ] = str_to_num( playerxp )

g_iPlayerLevel[ iPlayer ][ i ] = str_to_num( playerlevel )

}

return PLUGIN_CONTINUE
}
public ResetAll( iPlayer )
{
g_iClassNextRound[ iPlayer ] = 0
g_iPlayerClass[ iPlayer ] = 0

for( new i; i < MAX_CLASSES; i++ )
{
g_iPlayerXp[ iPlayer ][ i ] = 0
g_iPlayerLevel[ iPlayer ][ i ] = 0
}
}
public plugin_end( )
{
nvault_close( g_Vault )
}

leonard19941
10-30-2011, 15:07
This class will serve for the zp4.3?

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
"None",
"Dog",
"Cat",
"Horse",
"Cow"
}
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")

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 iVictim = read_data( 2 )
new headshot = read_data( 3 )
new clip, ammo, weapon = get_user_weapon(id,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(attacker, print_chat, "[Animal Mod] Congratulations! You are a level %i %s!",
PlayerLevel[attacker] += 1
}
ShowHud(attacker)
SaveData(attacker)
}
public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.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);

}

new szCommand[6] , szName[64];
new access , callback;

menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}

plowed
10-31-2011, 09:23
huh? this has absolutely nothing to do with zp.

leonard19941
10-31-2011, 10:54
yes, I know but I mean that this tutorial could also make human classes for zombie

leonard19941
11-25-2011, 22:53
What problem there, do not get this all right?

Haseeb
11-26-2011, 13:09
Please, someone could help me with the SMA that has leonard19941 but this fine, thanks.

padilha007
11-26-2011, 13:50
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fun>

#define MAXCLASSES 19

enum {
PLAYERLEVEL_1,
PLAYERLEVEL_2,
PLAYERLEVEL_3, // How many Levels
PLAYERLEVEL_4,
PLAYERLEVEL_5,
PLAYERLEVEL_6,
PLAYERLEVEL_7,
PLAYERLEVEL_8,
PLAYERLEVEL_9,
PLAYERLEVEL_10,
PLAYERLEVEL_11,
PLAYERLEVEL_12,
PLAYERLEVEL_13,
PLAYERLEVEL_14,
PLAYERLEVEL_15,
PLAYERLEVEL_16,
PLAYERLEVEL_17,
PLAYERLEVEL_18
}

enum {
CLASS_NONE = 0,
CLASS_CIUDADANO,
CLASS_RECLUTA, // Add your Classes there..
CLASS_CADETE,
CLASS_SOLDADO,
CLASS_CABO,
CLASS_SARGENTO,
CLASS_BRIGADA,
CLASS_SUBTENIENTE,
CLASS_TENIENTE,
CLASS_SUBOFICIAL,
CLASS_OFICIAL,
CLASS_STARS,
CLASS_MERCENARIO,
CLASS_BIOSOLDIER,
CLASS_HIBRIDO,
CLASS_SUPERSOLDADO,
CLASS_DESTRUCTOR,
CLASS_DEMOLEDOR
}

new const CLASSES[MAXCLASSES][] = {
"None",
"Ciudadano",
"Recluta",
"Cadete",
"Soldado",
"Cabo",
"Sargento",
"Brigada",
"SubTeniente",
"Teniente",
"SubOficial",
"Oficial",
"Stars",
"Mercenario",
"Biosoldier",
"Hibrido",
"SuperSoldado",
"Destructor",
"Demoledor"
}

new const LEVELS[19] = {
0,
100,
300,
900,
2700,
8100,
24300,
72900,
218700,
656100,
1968300,
5904900,
17714700,
53144100,
159432300,
478296900,
1434890700,
4304672100,
12914016300
};

new PlayerXP[33],PlayerLevel[33],PlayerClass[33];
new XP_Kill,XP_Knife,XP_Hs,SaveXP,g_vault

public plugin_init()
{
register_plugin("MoD XP", "1.0", "LeOnArD")

register_event("ResetHUD","skill","be"); // When the player spawns
register_event("DeathMsg", "eDeath", "a")

SaveXP = register_cvar("SaveXP","1")
XP_Kill = register_cvar("XP_per_kill", "60")
XP_Hs = register_cvar("XP_hs_bonus","90")
XP_Knife = register_cvar("XP_knife_bonus","60")
g_vault = nvault_open("animod")

register_concmd( "amx_takexp", "cmd_take_exp", ADMIN_KICK, "<target> <amount>" );
register_concmd( "amx_givexp", "cmd_give_exp", ADMIN_KICK, "<target> <amount>" );

register_clcmd("say /class", "ChangeClass")
register_clcmd("say /xp", "ShowHud")
}

public skill(id)
{
if (PlayerClass[id] == CLASS_CIUDADANO || PlayerLevel[id] == 1) // Checks Class and Level.
{
set_user_health(id, 100); // gives him 100 health if he's a Cow on level 1
give_item(id,"weapon_deagle");
}

if (PlayerClass[id] == CLASS_RECLUTA || PlayerLevel[id] == 2) // Checks Class and Level.
{
set_user_health(id, 115); // gives him 115 health if he's a Cow on level 2
give_item(id,"weapon_tmp");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_CADETE || PlayerLevel[id] == 3) // Checks Class and Level.
{
set_user_health(id, 130); // gives him 130 health if he's a Cow on level 3
give_item(id,"weapon_mp5");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_SOLDADO || PlayerLevel[id] == 4) // Checks Class and Level.
{
set_user_health(id, 150); // gives him 150 health if he's a Cow on level 4
give_item(id,"weapon_m4a1");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_CABO || PlayerLevel[id] == 5) // Checks Class and Level.
{
set_user_health(id, 175); // gives him 175 health if he's a Cow on level 5
give_item(id,"weapon_mp5");
give_item(id,"weapon_tmp");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_SARGENTO || PlayerLevel[id] == 6) // Checks Class and Level.
{
set_user_health(id, 250); // gives him 250 health if he's a Cow on level 6
give_item(id,"weapon_m4a1");
give_item(id,"weapon_mp5");
give_item(id,"weapon_deagle");
}

if (PlayerClass[id] == CLASS_BRIGADA || PlayerLevel[id] == 7) // Checks Class and Level.
{
set_user_health(id, 350); // gives him 350 health if he's a Cow on level 7
give_item(id,"weapon_ak47");
give_item(id,"weapon_m4a1");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_SUBTENIENTE || PlayerLevel[id] == 8) // Checks Class and Level.
{
set_user_health(id, 400); // gives him 400 health if he's a Cow on level 8
give_item(id,"weapon_m249");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_TENIENTE || PlayerLevel[id] == 9) // Checks Class and Level.
{
set_user_health(id, 450); // gives him 450 health if he's a Cow on level 9
give_item(id,"weapon_famas");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_SUBOFICIAL || PlayerLevel[id] == 10) // Checks Class and Level.
{
set_user_health(id, 510); // gives him 510 health if he's a Cow on level 10
give_item(id,"weapon_galil");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_OFICIAL || PlayerLevel[id] == 11) // Checks Class and Level.
{
set_user_health(id, 260); // gives him 260 health if he's a Cow on level 11
give_item(id,"weapon_famas");
give_item(id,"weapon_galil");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_STARS || PlayerLevel[id] == 12) // Checks Class and Level.
{
set_user_health(id, 600); // gives him 600 health if he's a Cow on level 12
give_item(id,"weapon_g3sg1");
give_item(id,"weapon_sg550");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_MERCENARIO || PlayerLevel[id] == 13) // Checks Class and Level.
{
set_user_health(id, 650); // gives him 650 health if he's a Cow on level 13
give_item(id,"weapon_ak47");
give_item(id,"weapon_m249");
give_item(id,"weapon_sg552");
give_item(id,"weapon_m3");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_BIOSOLDIER || PlayerLevel[id] == 14) // Checks Class and Level.
{
set_user_health(id, 675); // gives him 675 health if he's a Cow on level 14
give_item(id,"weapon_ak47");
give_item(id,"weapon_g3sg1");
give_item(id,"weapon_sg550");
give_item(id,"weapon_aug");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_HIBRIDO || PlayerLevel[id] == 15) // Checks Class and Level.
{
set_user_health(id, 725); // gives him 725 health if he's a Cow on level 15
give_item(id,"weapon_knife");
}

if (PlayerClass[id] == CLASS_SUPERSOLDADO || PlayerLevel[id] == 16) // Checks Class and Level.
{
set_user_health(id, 750); // gives him 750 health if he's a Cow on level 16
give_item(id,"weapon_ak47");
give_item(id,"weapon_g3sg1");
give_item(id,"weapon_sg550");
give_item(id,"weapon_aug");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_DESTRUCTOR || PlayerLevel[id] == 17) // Checks Class and Level.
{
set_user_health(id, 775); // gives him 775 health if he's a Cow on level 17
give_item(id,"weapon_ak47");
give_item(id,"weapon_g3sg1");
give_item(id,"weapon_sg550");
give_item(id,"weapon_aug");
give_item(id,"weapon_m3");
give_item(id,"weapon_deagle");
give_item(id,"weapon_usp");
}

if (PlayerClass[id] == CLASS_DEMOLEDOR || PlayerLevel[id] == 18) // Checks Class and Level.
{
set_user_health(id, 800); // gives him 800 health if he's a Cow on level 18
give_item(id,"weapon_ak47");
give_item(id,"weapon_g3sg1");
give_item(id,"weapon_sg550");
give_item(id,"weapon_aug");
give_item(id,"weapon_p90");
give_item(id,"weapon_m3");
give_item(id,"weapon_elite");
give_item(id,"weapon_deagle");
}
}

public eDeath( )
{
new attacker = read_data( 1 )
new iVictim = read_data( 2 )

if(attacker == iVictim || !is_user_connected(attacker) || get_user_team(attacker) == get_user_team(iVictim)) return;

new headshot = read_data( 3 )

new weapon[7]
read_data( 4, weapon, charsmax( weapon ) )

PlayerXP[attacker] += get_pcvar_num(XP_Kill)

if(headshot)
PlayerXP[attacker] += get_pcvar_num(XP_Hs)

if(equal(weapon, "knife"))
PlayerXP[attacker] += get_pcvar_num(XP_Knife)


while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
{
PlayerLevel[attacker] += 1
client_print(attacker, print_chat, "[MoD XP] Congratulations! You are a level %i class %s!", PlayerLevel[attacker], CLASSES[PlayerClass[attacker]]);
}
ShowHud(attacker)
SaveData(attacker)
}

public ShowHud(id)
{
set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0)
show_hudmessage(id, "Nivel: %i^nXP: %i^nClase: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
}

public cmd_give_exp( id, level,cid )
{
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv(2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] += expnum;

switch( get_cvar_num ( "amx_show_activity" ) )
{
case 1: client_print( 0, print_chat, "ADMIN: gave %i points for %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: gave %i points for %s.", admin_name, expnum, player_name );
}

client_print(player, print_chat, "[AMXX] You received %i points. (Total: %d)", expnum, PlayerXP[player] );

SaveData( id )

return PLUGIN_CONTINUE;
}

public cmd_take_exp( id, level,cid )
{
if( ! cmd_access ( id, level, cid, 3 ) )
return PLUGIN_HANDLED;

new target[32], amount[21], reason[21];

read_argv( 1, target, 31 );
read_argv( 2, amount, 20 );
read_argv( 3, reason, 20 );

new player = cmd_target( id, target, 8 );

if( ! player )
return PLUGIN_HANDLED;

new admin_name[32], player_name[32];
get_user_name( id, admin_name, 31 );
get_user_name( player, player_name, 31 );

new expnum = str_to_num( amount );

PlayerXP[player] -= expnum;

switch(get_cvar_num("amx_show_activity"))
{
case 1: client_print( 0, print_chat, "ADMIN: took %i points from %s.", expnum, player_name );
case 2: client_print( 0, print_chat, "ADMIN %s: took %i points from %s.", admin_name, expnum, player_name );
}

client_print(player, print_chat,"You received %i points. (Total: %d)", expnum, PlayerXP[player] );

SaveData( id )

return PLUGIN_CONTINUE;
}

public ChangeClass(id)
{
new menu = menu_create("Class Menu" , "Class_Handle");
menu_additem(menu ,"Ciudadano", "1" , 0);
menu_additem(menu ,"Recluta", "2" , 0);
menu_additem(menu ,"Cadete", "3" , 0);
menu_additem(menu ,"Soldado", "4" , 0);
menu_additem(menu ,"Cabo", "5" , 0);
menu_additem(menu ,"Sargento", "6" , 0);
menu_additem(menu ,"Brigada", "7" , 0);
menu_additem(menu ,"SubTeniente", "8" , 0);
menu_additem(menu ,"Teniente", "9" , 0);
menu_additem(menu ,"SubOficial", "10" , 0);
menu_additem(menu ,"Oficial", "11" , 0);
menu_additem(menu ,"Stars", "12" , 0);
menu_additem(menu ,"Mercenario", "13" , 0);
menu_additem(menu ,"Biosoldier", "14" , 0);
menu_additem(menu ,"Hibrido", "15" , 0);
menu_additem(menu ,"SuperSoldado", "16" , 0);
menu_additem(menu ,"Destructor", "17" , 0);
menu_additem(menu ,"Demoledor", "18" , 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 , 5 , szName , 63 , callback);

new i = 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(vaultdata, 255, "#", " ")

new playerxp[32], playerlevel[32]

parse(vaultdata, playerxp, 31, playerlevel, 31)

PlayerXP[id] = str_to_num(playerxp)
PlayerLevel[id] = str_to_num(playerlevel)

return PLUGIN_CONTINUE
}

leonard19941
11-26-2011, 14:14
Thanks padilha007 (http://forums.alliedmods.net/member.php?u=39546).

satelitegames
12-02-2011, 22:53
Ola padilha007 , este codigo que você mandou esta compilando correto, mais quando sobe de level da este erro aqui:" ED_Alloc " Como arruma este erro?

satelitegames
12-14-2011, 14:47
To com mesmo problema tambem :(

Haseeb
12-15-2011, 17:30
english is required, please

kramesa
12-17-2011, 01:04
Wow, It look nice!

JoKeR LauGh
12-26-2011, 04:35
Sorry for reviving but this new iVictim = read_data( 2 )
should be
new attacker = read_data( 2 )

If i'm wrong , I am so sorry but after I changed that in my code then the 12 errors gone .