RSSy MYGO.pl Opublikowano Styczeń 1, 2023 o 20:34 RSSy Udostępnij Opublikowano Styczeń 1, 2023 o 20:34 I use the level system that Neeeeel made in a tutorial, it works perfectly but I don't know how I can adapt the zombies so that they are by levels, please help. Level System -> PHP Code: /*================================================================================ -------------------------------- -*- [ZP] Level system -*- -------------------------------- This plugin is part of Zombie Plague Mod and is distributed under the terms of the GNU General Public License. Check ZP_ReadMe.txt for details. ================================================================================*/ #include < amxmodx > #include < zp50_ammopacks > #include < zp50_colorchat > #define MAXPLAYERS 32 // We will use this macro to calculate the necessary ammopacks of the next level // PS: power means power, in this case the entered levels are being squared // PD2: This equation can be modified to suit each one, this would be the "difficulty" if you want to call it that #define cost_levelup(%1) (13 * %1) + ((11 * power(%1, 2)) / 2) // We create a global variable to store the levels of each player new g_level[ MAXPLAYERS + 1 ]; public plugin_init( ) register_plugin( "[ZP] Level system", ZP_VERSION_STRING, "ZP Dev Team" ); public plugin_natives( ) { // Well here we register the natives that we will later use in the other plugins register_native( "zp_set_level", "native_set_level" ); register_native( "zp_get_level", "native_get_level" ); } // We make the player's level 1 when connected, in this place you should load the levels (you can do it in an external plugin) public client_putinserver( id ) g_level[ id ] = 1; // This function is the forward that is called every time ammopacks are added or subtracted, it will be seen in more detail later public zp_fw_ammopacks_change( id ) { new lvl = g_level[ id ]; // Here what I do is check if it has more ammopacks than necessary for the next level, a while is used in case it is necessary to go up/down more than 1 level at the same time. while( zp_ammopacks_get( id ) >= cost_levelup( lvl ) ) lvl++; while( zp_ammopacks_get( id ) < cost_levelup( ( lvl - 1 ) ) ) lvl--; // I do this more than anything to avoid overloading the saving of data, at the end of this forward I call the function that updates the data, and most of the times that this forward is called, the level does not change if( g_level[ id ] == lvl ) return PLUGIN_HANDLED; // If the level changes I show him a message... if( lvl > g_level[ id] ) zp_colored_print( id, "^x01 You leveled up^x04 [%d]^x01 Congrazz!!!", lvl ); else if( g_level[ id ] > lvl ) zp_colored_print( id, "^x01 You leveled down^x04 [%d]^x01 :(!!!", lvl ); // give it the corresponding level g_level[ id ] = lvl; return PLUGIN_HANDLED; } // This is the native to set the levels, it is made a bit different from the conventional ones, I did it like this to respect the way the other natives were created in this version of ZP // Instead of putting the parameters next to the function name, they are loaded in a variable with get_param, I don't know the difference with conventional natives public native_set_level( plugin_id, num_params ) { new id = get_param( 1 ); new ammount = get_param( 2 ); g_level[ id ] = ammount; return ammount; } // And this is the native to get the levels, it's a simple return as you can see public native_get_level( plugin_id, num_params ) return g_level[ get_param( 1 ) ]; Include -> PHP Code: #if defined _zp50_levels_included #endinput #endif #define _zp50_levels_included native zp_set_level( id, ammount ); native zp_get_level( id ); Zombie Class -> PHP Code: /*================================================================================ --------------------------------- -*- [ZP] Class: Zombie: Light -*- --------------------------------- This plugin is part of Zombie Plague Mod and is distributed under the terms of the GNU General Public License. Check ZP_ReadMe.txt for details. ================================================================================*/ #include <amxmodx> #include <zp50_class_zombie> // Light Zombie Attributes new const zombieclass3_name[] = "Light Zombie" new const zombieclass3_info[] = "HP- Jump+ Knockback+" new const zombieclass3_models[][] = { "zombie_source" } new const zombieclass3_clawmodels[][] = { "models/escapesg_plague/v_knife_zombie.mdl" } const zombieclass3_health = 1400 const Float:zombieclass3_speed = 0.75 const Float:zombieclass3_gravity = 0.75 const Float:zombieclass3_knockback = 1.25 new g_ZombieClassID public plugin_precache() { register_plugin("[ZP] Class: Zombie: Light", ZP_VERSION_STRING, "ZP Dev Team") new index g_ZombieClassID = zp_class_zombie_register(zombieclass3_name, zombieclass3_info, zombieclass3_health, zombieclass3_speed, zombieclass3_gravity) zp_class_zombie_register_kb(g_ZombieClassID, zombieclass3_knockback) for (index = 0; index < sizeof zombieclass3_models; index++) zp_class_zombie_register_model(g_ZombieClassID, zombieclass3_models[index]) for (index = 0; index < sizeof zombieclass3_clawmodels; index++) zp_class_zombie_register_claw(g_ZombieClassID, zombieclass3_clawmodels[index]) } Attached Files zp50_levels.inc (155 Bytes) Get Plugin or Get Source (zp50_levels.sma - 3.5 KB) Get Plugin or Get Source (zp50_class_zombie_leech.sma - 3.4 KB) Przeczytaj cały wpis Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi