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

New XP Mod tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
HexD
Member
Join Date: Nov 2005
Location: England
Old 03-31-2008 , 00:33   Re: New XP Mod tutorial
Reply With Quote #41

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 but it didn't work and also killed the rest of the script until I removed the
Code:
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
Code:
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.
Attached Files
File Type: sma Get Plugin or Get Source (Ninjamod.sma - 712 views - 6.4 KB)
HexD is offline
Send a message via MSN to HexD
Merko
Member
Join Date: Mar 2008
Old 03-31-2008 , 03:20   Re: New XP Mod tutorial
Reply With Quote #42

Hello.

I made this event in the plugin_init()
Code:
register_event("ResetHUD","on_spawn","be"); // When the player spawns

And then made a function:
Code:
// 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.
Code:
    //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.."
Attached Files
File Type: sma Get Plugin or Get Source (ninjamodtest.sma - 752 views - 6.9 KB)

Last edited by Merko; 03-31-2008 at 03:38.
Merko is offline
HexD
Member
Join Date: Nov 2005
Location: England
Old 03-31-2008 , 16:04   Re: New XP Mod tutorial
Reply With Quote #43

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!
HexD is offline
Send a message via MSN to HexD
Merko
Member
Join Date: Mar 2008
Old 04-01-2008 , 00:29   Re: New XP Mod tutorial
Reply With Quote #44

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
Merko is offline
HexD
Member
Join Date: Nov 2005
Location: England
Old 04-01-2008 , 23:13   Re: New XP Mod tutorial
Reply With Quote #45

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

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.
HexD is offline
Send a message via MSN to HexD
Merko
Member
Join Date: Mar 2008
Old 04-02-2008 , 04:29   Re: New XP Mod tutorial
Reply With Quote #46

In the on_spawn() event I got this:

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

Code:
public client_connect(id) {     if(get_pcvar_num(SaveXP) == 1)     {         LoadData(id)      ChangeClass(id)     } }
or..
Code:
public client_authorized(id)     {     if(get_cvar_num("SaveXP") == 1)     {                LoadData(id)         ChangeClass(id)     } }

Last edited by Merko; 04-02-2008 at 04:34. Reason: Putted another example in.
Merko is offline
HexD
Member
Join Date: Nov 2005
Location: England
Old 04-02-2008 , 11:18   Re: New XP Mod tutorial
Reply With Quote #47

Thanks, the way I was trying was not to different, but it didn't work;

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

Code:
public client_authorized(id) {     if(get_pcvar_num(SaveXP) == 1)     {         LoadData(id)     }        if(is_user_alive(id) == 1 && PlayerClass[id] == CLASS_NONE)     {         ChangeClass(id)     } }
HexD is offline
Send a message via MSN to HexD
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 04-02-2008 , 14:59   Re: New XP Mod tutorial
Reply With Quote #48

You should not expect people to be alive in client_authorized() and you should not use ResetHUD to detect spawn.
Lee is offline
HexD
Member
Join Date: Nov 2005
Location: England
Old 04-04-2008 , 22:59   Re: New XP Mod tutorial
Reply With Quote #49

Thanks, will change it to Ham_Spawn. Very useful link.
HexD is offline
Send a message via MSN to HexD
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 04-05-2008 , 05:51   Re: New XP Mod tutorial
Reply With Quote #50

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.
__________________
If one of my plugins become broken, contact me by mail. [email protected]

Last edited by fxfighter; 04-05-2008 at 05:55.
fxfighter is offline
Send a message via MSN to fxfighter
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:49.


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