AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Class help (https://forums.alliedmods.net/showthread.php?t=25369)

Werewolf 03-12-2006 16:49

Class help
 
Hello.
This doesn't work. Can you help me please?
Code:
#if defined _myth_skills_included #endinput #endif #define _myth_skills_included new g_PlayerClass[33]; new g_PlayerXP[33]; new g_PlayerLevel[33]; new g_SkillUsed[33]; #define CLASS_NOTHING 0 #define CLASS_DEMON 1 #define CLASS_ANGEL 2 #define CLASS_SHAPESHIFTER 3 #define CLASS_PHOENIX 4 #define CLASS_WEREWOLF 5 #define CLASS_VAMPYRE 6 #define NUMCLASSES 7 new const CLASSES[NUMCLASSES][] = {     "None",     "Demon",     "Angel",     "Shapeshifter",     "Phoenix",     "Werewolf",     "Vampyre" } public classpowers(id) {     new level = g_PlayerLevel[id]     if(level == 0) return 1;     if(g_PlayerLevel[id] == 1)     {     set_user_health(id, 110)     }     if(g_PlayerLevel[id] == 2)     {     set_user_health(id, 120)     }     if(g_PlayerLevel[id] == 3)     {     set_user_health(id, 130)     }     if(g_PlayerLevel[id] == 4)     {     set_user_health(id, 140)     }     if(g_PlayerLevel[id] == 5)     {     set_user_health(id, 150)     }     if(g_PlayerLevel[id] == 6)     {     set_user_health(id, 160)     }     if(g_PlayerLevel[id] == 7)     {     set_user_health(id, 170)     }     if(g_PlayerLevel[id] == 8)     {     set_user_health(id, 180)     }     if(g_PlayerLevel[id] == 9)     {     set_user_health(id, 190)     }     if(g_PlayerLevel[id] == 10)     {     set_user_health(id, 200)     }     return PLUGIN_CONTINUE }
And if you wonder. I call this every round :wink:

And problem 2.
When I set that to 1 class it still gives to ALL classes in my mod.
What should I do?

Problem 3.
When I set xp, then if I set to example 10000000 xp then you don't raise any levels until you kill someone. Example. You are on level 0. I set xp to 100000 which is more than level 10's xp. You are still on level 0 but you raise levels for each kill instead.
Here is the code i set for the levels/xp
Code:
if(g_PlayerXP[id] == 100) g_PlayerLevel[id] = 1 if(g_PlayerXP[id] == 200) g_PlayerLevel[id] = 2 etc.

Twilight Suzuka 03-12-2006 16:55

When I finish OOP module, it will greatly aid people like you...

[ --<-@ ] Black Rose 03-12-2006 18:54

1. dunno but this is the same thing but easier:
Code:
public classpowers(id) {     set_user_health(id, 100 + ( g_PlayerLevel[id] * 10 ) ) }

2.
Code:
if ( g_PlayerClass[id] == 1 ) // If user is Demon     classpowers(id)

3. you probably have the level thing in DeathMsh event.

Werewolf 03-13-2006 10:43

Thank you, but the levels wont work, and it is still untested. Will test it later though. IP if you want to test 194.16.250.55:27015 (Dedicated Server and CZ :P )
And I got this from my server debug
Code:

L 03/13/2006 - 16:52:39: [AMXX] Run time error 10: native error (native "set_user_health")
but it still works :?
How can I solve it and why does it show? I've included fun.inc
Check this. It is my DeathMsg.
Code:
public DeathMsg() {     if(!get_cvar_num("sv_mythmod"))         return;           new attacker = read_data(1)     if(g_PlayerClass[attacker] == 0)         return;           if(g_PlayerLevel[attacker] == NUMLEVELS)         return;                   g_PlayerXP[attacker] += get_cvar_num("MM_xp_per_kill")       if(g_PlayerXP[attacker] >= LEVELS[g_PlayerLevel[attacker]]) {         ++g_PlayerLevel[attacker];                 client_print(attacker, print_chat, "[* Mod] Congratulations! You are now level %i!", g_PlayerLevel[attacker])     }         if(get_cvar_num("MM_savexp") == 1)         {         SaveXP(attacker)         }         ShowHUD(attacker); }

TESTED! It doesn't work. Your level is set after a kill OR after a death with my command myth_addxp <user> <amount>
So I think I will have to set a task for that one.
The hp wont work. The plugin doesnt respond to the different classes.

[ --<-@ ] Black Rose 03-13-2006 11:27

i think this works.
Code:
public AddXP(id, ammount) {     if ( g_PlayerClass[id] > 0) {                 g_PlayerXP[id] += ammount                 for ( new i = 0 ; i < MAXLEVELS ; i++ ) {                         if ( g_PlayerLevel[id]!= MAXLEVELS + 1 ) {                                 if ( g_PlayerXP[id] >= LEVELS[g_PlayerLevel[id] + 1 ]) {                     g_PlayerLevel[id]++                                         client_print(id, print_chat, "[* Mod] Congratulations! You are now level %i!", g_PlayerLevel[id])                 }                                 if ( g_PlayerXP[id] < LEVELS[g_PlayerLevel[id]])                     if ( g_PlayerLevel[id] > 0 )                     g_PlayerLevel[id]--             }         }     }         if(get_cvar_num("MM_savexp") == 1) {         SaveXP(id)     }         ShowHUD(id) // Call This every time xp changes. }

change your DeathMsg to this:
Code:
public DeathMsg() {     if(!get_cvar_num("sv_mythmod"))         return         new attacker = read_data(1)         new tempxp = get_cvar_num("MM_xp_per_kill")         AddXP(attacker, tempxp) }
and to that other problem with set_user_health, add if ( is_user_alive(id) && is_user_connected(id) ) {
set_user_hp(id, 100 + .....

and if you got a cvar, for giving xp, do something like this:
Code:
public GiveXP(id, level, cid) {     if (! cmd_access( id, level, cid, 0 ) )         return PLUGIN_HANDLED     new arg[32], xp[10]         read_argv(1, arg, 31)     read_argv(2, xp, 9)         new player = cmd_target( id, arg, 2 )         if ( !player ) {         return PLUGIN_HANDLED     }         AddXP(player, str_to_num(xp))         client_print(player,print_chat,"An admin gave you %d xp", str_to_num(xp))     ShowHUD(id)     return PLUGIN_CONTINUE }

hope this helps ya

Werewolf 03-13-2006 13:28

OK when I added that, then I wasn't able to start the server xD
Something wrong with it. Error message:
Code:

Host_Error: WriteDest_Parm: not a client
I don't know what it means but I think it has something to do with the GiveXP code. :roll:
Server doesn't respond to different classes either :cry:

Zenith77 03-13-2006 15:23

make sure the target is connected by something like

Code:
if(!is_user_connected(player)) return PLUGIN_HANDLED; //or if(!is_user_connected(id)) return PLUGIN_HANDLED;

Not to sure which var is causing the problem

Kensai 03-13-2006 18:13

Lol.

Since you helped me. Here's how I did it in my Ninja Mod.


Global Level, Class, XP Variables.

Code:
new PlayerClass[33] new PlayerXP[33] new PlayerLevel[33]

Give XP Command:

Code:
register_concmd("amx_ninja_xp", "cmd_xp", ADMIN_KICK, "<user> <xp to add> - Adds XP to the target player")
Code:
public cmd_xp(id, level, cid) {     if(get_cvar_num("ninja_on") == 0)         return 1;             if(!cmd_access(id, level, cid, 3))         return 1;         new arg[32], arg2[32]     read_argv(1, arg, 31)     read_argv(2, arg2, 31)         new target = cmd_target(id, arg, 2)         if(!target)     {         return 1;     }         PlayerXP[target] += str_to_num(arg2)     ShowHUD(target)     client_print(id, print_console, "[Ninja Mod] Added %i XP to %s", str_to_num(arg2), target)     client_print(target, print_chat, "[Ninja Mod] %i XP has been added to you.", str_to_num(arg2))         return 1; }

Deatch MSG (gives XP amount from cvar):

Code:
register_cvar("ninja_xppk", "20")//XP Per Kill, i.e. gives 20 xp for every kill
Code:
public DeathMsg() {     if(get_cvar_num("ninja_on") == 0)         return 1;         new attacker = read_data(1)         if(PlayerClass[attacker] == CLASS_NOTHING)     {         client_print(attacker, print_chat, "[Ninja Mod] You must choose a race to gain XP, type /changeninja")         return 1;     }         if(is_user_alive(attacker))     {         PlayerXP[attacker] += get_cvar_num("ninja_xppk")     }         if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])     {         PlayerLevel[attacker] += 1         client_print(attacker,print_chat,"[Ninja Mod] Congratulations! You are now level %i!", PlayerLevel[attacker])         SaveXP(attacker)         ShowHUD(attacker)     }         ShowHUD(attacker)     return 0; }

That works perfectly for me.



And for the classes.

I have them defined like so:


Code:
#define CLASS_NOTHING 0 #define CLASS_SHADOW 1 #define CLASS_SWIFT 2 #define CLASS_SHINOBI 3 #define CLASS_SEER 4 #define MAXCLASSES 5 new const CLASSES[MAXCLASSES][] = {     "None",     "Shadow",     "Swift",     "Shinobi",     "Seer" }

Level XP requirements defined like so:
Code:
new const LEVELS[10] = {     100,       200,       400,       800,     1600,     3200,     6400,     12800,     25600,     51200 }


Class powers like this:

Code:
register_event("CurWeapon", "Swift", "be")//Since speed changes every wep switch, this fixes the loss of speed prob with wep change

Code:
public Swift(id) {     if(get_cvar_num("ninja_on") == 0)         return 1;             new lvl = PlayerLevel[id]         if(lvl == 0)         return 1;             switch (lvl)     {         case 0:{             return 1;         }         case 1:{             set_user_maxspeed(id, 340.0)             client_cmd(id, "cl_forwardspeed 340")             client_cmd(id, "cl_sidespeed 340")             client_cmd(id, "cl_backspeed 340")         }         case 2:{             set_user_maxspeed(id, 360.0)             client_cmd(id, "cl_forwardspeed 360")             client_cmd(id, "cl_sidespeed 360")             client_cmd(id, "cl_backspeed 360")         }         case 3:{             set_user_maxspeed(id, 380.0)             client_cmd(id, "cl_forwardspeed 380")             client_cmd(id, "cl_sidespeed 380")             client_cmd(id, "cl_backspeed 380")         }         case 4:{             set_user_maxspeed(id, 400.0)             client_cmd(id, "cl_forwardspeed 400")             client_cmd(id, "cl_sidespeed 400")             client_cmd(id, "cl_backspeed 400")         }         case 5:{             set_user_maxspeed(id, 420.0)             client_cmd(id, "cl_forwardspeed 420")             client_cmd(id, "cl_sidespeed 420")             client_cmd(id, "cl_backspeed 420")         }         case 6:{             set_user_maxspeed(id, 440.0)             client_cmd(id, "cl_forwardspeed 440")             client_cmd(id, "cl_sidespeed 440")             client_cmd(id, "cl_backspeed 440")         }         case 7:{             set_user_maxspeed(id, 460.0)             client_cmd(id, "cl_forwardspeed 460")             client_cmd(id, "cl_sidespeed 460")             client_cmd(id, "cl_backspeed 460")         }         case 8:{             set_user_maxspeed(id, 480.0)             client_cmd(id, "cl_forwardspeed 480")             client_cmd(id, "cl_sidespeed 480")             client_cmd(id, "cl_backspeed 480")         }         case 9:{             set_user_maxspeed(id, 500.0)             client_cmd(id, "cl_forwardspeed 500")             client_cmd(id, "cl_sidespeed 500")             client_cmd(id, "cl_backspeed 500")         }         case 10:{             set_user_maxspeed(id, 520.0)             client_cmd(id, "cl_forwardspeed 520")             client_cmd(id, "cl_sidespeed 520")             client_cmd(id, "cl_backspeed 520")         }     }     return 0; }

Each case is the Level of the Player.


And I get their class like this

Code:
if(PlayerClass[id] == CLASS_SWIFT) {         blah }


Hope that made sense.

[ --<-@ ] Black Rose 03-14-2006 10:11

on the lvl switch you have allready checked if the player is lvl 0, then u have a lvl 0 case.

and this does the same thing as your switch:
Code:
    set_user_maxspeed(id, ( 20 * lvl ) + 320.0 )     client_cmd(id, "cl_forwardspeed %d", ( 20 * lvl ) + 320 )     client_cmd(id, "cl_sidespeed %d", ( 20 * lvl ) + 320 )     client_cmd(id, "cl_backspeed %d", ( 20 * lvl ) + 320 )

Werewolf 03-15-2006 11:29

Quote:

Originally Posted by [ --<-@
Black Rose]on the lvl switch you have allready checked if the player is lvl 0, then u have a lvl 0 case.

True but that is wrong topic :roll:
And let him do as he want to do it :wink:
Btw should I create separate files to make it easier to see where I have all the scripts?
Example. I've got an inl named myth_skills.inl and there I only have the things that belong to the skills the different classes have.


All times are GMT -4. The time now is 20:14.

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