AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   New XP Mod tutorial (https://forums.alliedmods.net/showthread.php?t=66497)

flyeni6 02-01-2008 17:16

New XP Mod tutorial
 
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

PHP Code:

#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
PHP Code:

#define MAXCLASSES 5 

We create the variable that is going to hold your class, xp , and level
PHP Code:

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:
PHP 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:
PHP 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()
PHP Code:

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:
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

    
// Create a variable to store the attacker's id
    
new attacker read_data)
    
// We create the victim variable, so that this function can check 
    // if a player was killed 
    
new iVictim read_data)
    
// If a player was killed by a HeadShot, this will be used for the cvar Xp_Hs
    
new headshot read_data)
 
    
//which weapon was used
    
new clipammoweapon 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(attackerprint_chat"[Animal Mod] Congratulations! You are a level %i %s!"PlayerLevel[attacker],CLASSES[PlayerClass[attacker]]) 
        
// Add his/her level 
        
PlayerLevel[attacker] += 
    

    
// shows his level on a hud message 
    
ShowHud(attacker)
 


This is the showhud function. It shows the your Class, your level, and XP
PHP Code:

public ShowHud(id

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


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
PHP Code:

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 szName 63 callback); 
    new 
str_to_num(szCommand
    if(
PlayerClass[id] != i
    { 
        
PlayerClass[id] = i client_print(id,print_chat,"You are now a %s",CLASSES[i]) 
    }
    else 
    { 
        
client_print(id,print_chat,"You are alredy a %s",CLASSES[i]) 
    } 
    
menu_destroy(menu); 
    return 
PLUGIN_CONTINUE 


This this is the client connect function. All these things happend when the player is connecting to the server
PHP Code:

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
PHP Code:

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
PHP Code:

public SaveData(id

    
// get the players steam id. We need this because we are saving by steam id 
    
new AuthID[35get_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
PHP Code:

public LoadData(id

    new 
AuthID[35get_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(vaultdata255"#"" "
    new 
playerxp[32], playerlevel[32
    
parse(vaultdataplayerxp31playerlevel31
    
PlayerXP[id] = str_to_num(playerxp
    
PlayerLevel[id] = str_to_num(playerlevel
    return 
PLUGIN_CONTINUE 


OK now everything with out comments
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(  )
{
    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

Re: New XP Mod tutorial
 
i read a little part, and your knife and hs pcvars are swapped :S

flyeni6 02-01-2008 20:00

Re: New XP Mod tutorial
 
everything fixed :P thanks

[kirk]./musick` 02-01-2008 20:41

Re: New XP Mod tutorial
 
Looks good, thanks a lot. The other one didn't work, so many people complained :roll:

flyeni6 02-01-2008 21:10

Re: New XP Mod tutorial
 
Yeh many people were complaining so i was like "damn ill just make a New one" :D

Drak 02-02-2008 00:52

Re: New XP Mod tutorial
 
You might want to change "client_connect" to "client_authorized".
Just to be safe.

fxfighter 02-02-2008 05:10

Re: New XP Mod tutorial
 
think you shuld add this to the death event so you cant get xp whit class none.
PHP Code:

if(PlayerClass[attacker] == 0)
  return 
PLUGIN_CONTINUE 

And plz remove my old mistake^^
PHP Code:

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


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

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.
PHP Code:

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


flyeni6 02-02-2008 05:51

Re: New XP Mod tutorial
 
Quote:

Originally Posted by fxfighter (Post 580780)
think you shuld add this to the death event so you cant get xp whit class none.
PHP Code:

if(PlayerClass[attacker] == 0)
  return 
PLUGIN_CONTINUE 

And plz remove my old mistake^^
PHP Code:

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


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

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.
PHP Code:

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



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

Re: New XP Mod tutorial
 
@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.

flyeni6 02-02-2008 06:15

Re: New XP Mod tutorial
 
Quote:

Originally Posted by arkshine (Post 580789)
@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

Re: New XP Mod tutorial
 
http://wiki.alliedmods.net/Half-Life...vents#DeathMsg

flyeni6 02-02-2008 06:22

Re: New XP Mod tutorial
 
fixed

Arkshine 02-02-2008 06:41

Re: New XP Mod tutorial
 
You have omitted the weapon.

flyeni6 02-02-2008 14:59

Re: New XP Mod tutorial
 
fixed that problem

linkosc 02-05-2008 16:48

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
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
Hawk552
TheNewt

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

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
Could you please post one without the classes and just leveling up with chosen names for each rank?:)

jasonf20 03-15-2008 14:00

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
i did use read_Data(1) read the code
Quote:

new headshot,attacker = read_data( 1 )

jasonf20 03-15-2008 16:05

Re: New XP Mod tutorial
 
Quote:

Originally Posted by fxfighter (Post 597204)
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

Re: New XP Mod tutorial
 
Y thats why i fixed it.

Checkmarks 03-15-2008 18:38

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
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:
Code:
if(playerLevel[index] >= 10) {      give_hp(index, 500);      uber(index); }
get what we mean?

Checkmarks 03-17-2008 15:41

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
Quote:

Originally Posted by fxfighter (Post 597646)
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

Re: New XP Mod tutorial
 
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:

Code:

/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

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
Oh right ;).

Well I fixed it myself too hehe. :)

HexD 03-30-2008 11:26

Re: New XP Mod tutorial
 
How would I make it give different things for different classes at different levels?

grimvh2 03-30-2008 11:30

Re: New XP Mod tutorial
 
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

Re: New XP Mod tutorial
 
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:
PHP Code:

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..

PHP Code:

if (PlayerClass[id] == CLASS_COW// Checks if he's an cow or not
{
set_user_health(id250); // 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..

PHP Code:

if (PlayerClass[id] == CLASS_COW || PlayerLevel[id] == 5// Checks Class and Level.
{
set_user_health(id250); // 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

Re: New XP Mod tutorial
 
Nice , your learning fast

Lee 03-30-2008 17:19

Re: New XP Mod tutorial
 
Except '||' signifies 'logical or' and not 'logical and' - you were looking for '&&'.

HexD 03-30-2008 20:31

Re: New XP Mod tutorial
 
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:
Code:
    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

Re: New XP Mod tutorial
 
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.


All times are GMT -4. The time now is 01:42.

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