Raised This Month: $ Target: $400
 0% 

Need Help, First Port


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nonok
Junior Member
Join Date: Sep 2004
Old 09-27-2004 , 19:39   Need Help, First Port
Reply With Quote #1

I am trying to compile latejoin.sma, for amxx 0.20. I have ns2 module, its a linux server, take a look at the code, it looks like it should work to me. I get tons of compiling errors when I try to compile though.

Code:
/* LATEJOIN.SMA   1.0a
 * -
 * (c) 2004 Steve Dudenhoeffer
 * -
 * This plugin will help out latejoiners (and people who aren't that good) by giving them
 * experience if they are far behind their team each time they spawn.
 * The way it works:
 *
 *  Every time a player spawns, the plugin notes his level
 *  If his level is less than 75% of the average level of everybody on their team
 *  Then he is given enough EXP to bring him up to that 75%.
 * 
 *  The plugin can be configured to give players only a maximum level.
 *
 *
 *  Configuration cvars:
 *     amx_latejoin - This is the percentage of the average level which is compared with the player.
 *                    Default: 75
 *
 *  Compile-time configuration:
 *     MAX - This is how many maximum levels a player can get from the given XP method.
 *           ie: If MAX is set to 4, and everybody on the player's team is level 10, but he is level 0,
 *               he will only become level 4.
 *           Default: 5 (set to 0 to disable)
 *                    
 *    USE_EXTRA_LEVELS - This option will configure the plugin along side of the AMX Extra Levels plugin. (untested)
 *                       Default: 0 (set to 1 to enable)
 *
 *  Requires NS2AMX 1.1+.
 *
 *  Some of the enums were shamelessly stolen from CheesyPeteza's Extra Levels plugin, thanks!
 */

#define USE_EXTRA_LEVELS      0   //  Set this to 1 if you're using the extra levels plugin.
#define MAX                   5   //  Maximum levels the plugin will give players
#define AMXMODX               0   //  Set this to 1 if you're using AMX Mod X, 0 otherwise.


// Don't edit below here...









#if AMXMODX == 1
#include <amxmodx>
#else
#include <amxmod>
#endif
#include <ns2amx>











#define OFFSET_EXPERIENCE     1588
#define EXPERIENCE_LIN        -28

#if !defined USE_EXTRA_LEVELS
#define USE_EXTRA_LEVELS  0
#endif
#if USE_EXTRA_LEVELS == 0
enum {
  XP_LEVEL_1	=     0,
  XP_LEVEL_2	=   100,
  XP_LEVEL_3	=   250,
  XP_LEVEL_4	=   450,
  XP_LEVEL_5	=   700,
  XP_LEVEL_6	=  1000,
  XP_LEVEL_7	=  1350,
  XP_LEVEL_8	=  1750,
  XP_LEVEL_9	=  2200,
  XP_LEVEL_10	=  2700
}
#else
enum {
  XP_LEVEL_1	=     0,
  XP_LEVEL_2	=   100,
  XP_LEVEL_3	=   250,
  XP_LEVEL_4	=   450,
  XP_LEVEL_5	=   700,
  XP_LEVEL_6	=  1000,
  XP_LEVEL_7	=  1350,
  XP_LEVEL_8	=  1750,
  XP_LEVEL_9	=  2200,
  XP_LEVEL_10	=  2700,
  XP_LEVEL_11	=  3250,
  XP_LEVEL_12	=  3850,
  XP_LEVEL_13	=  4500,
  XP_LEVEL_14	=  5200,
  XP_LEVEL_15	=  5950,
  XP_LEVEL_16	=  6750,
  XP_LEVEL_17	=  7600,
  XP_LEVEL_18	=  8500,
  XP_LEVEL_19	=  9450,
  XP_LEVEL_20	= 10450,
  XP_LEVEL_21	= 11500,
  XP_LEVEL_22	= 12600
}
#endif


new active
public plugin_init()
{
  register_plugin("Latejoin XP","1.0a","Steve Dudenhoeffer")
  register_cvar("amx_latejoin","75",FCVAR_SERVER)
  active=is_combat()
}
Float:SCALE()
{
  return get_cvar_float("amx_latejoin") * 0.01
}
public client_spawn(id)
{
  if (!active)
    return
  // No ready roomers
  if (pev(id,pev_team) == 0)
    return
  checkXP(id)
}


public client_changeteam(id,newteam,oldteam)
{
  if (!active)
    return
  if (newteam > 0 && pev(id,pev_deadflag) == 0)
    checkXP(id)
}
checkXP(id)
{
  new MyLevel=get_level(my_xp(id))
  new AvgLevel=average_xp(pev(id,pev_team))
  
  // This player is below the AvgLevel.  Give them XP.
  if (MyLevel < AvgLevel)
  {
    // Find difference in levels.
    new Difference = AvgLevel - MyLevel
    // Scale it
    Difference = floatround(Difference * SCALE())
    MyLevel += Difference
    // Now change XP
    
    // Check if the level we're going to set is above the max.
    if (MAX && MyLevel > MAX)
      MyLevel = MAX  // It is, lower it to the max allowed.
    new Float:xp = get_xp_for_level(MyLevel)
    // Small buffer.
    xp += 1.0
    if (xp > my_xp(id))
    {
      set_xp(id,xp)
      #if defined _amxmodx_included
        client_print(id,print_chat,"[AMXX] You have been given some experience because you're too far behind the rest of your team.")
      #else
        client_print(id,print_chat,"[AMX] You have been given some experience because you're too far behind the rest of your team.")
      #endif
    }
  }
  return PLUGIN_CONTINUE
}
Float:my_xp(id)
{
  return get_private_f(id,OFFSET_EXPERIENCE,EXPERIENCE_LIN)
}
average_xp(team)
{
  new level=0
  new count=0
  if (team == 0)
    return 0
  for (new i=1;i<=get_maxplayers();i++)
  {
    if (is_user_connected(i))
    {
      if (pev(i,pev_team) == team)
      {
        level+= get_level(my_xp(i))
        count++
      }
    }
  }
  if (count > 0)
  {
    new Float:flevel = float(level) / count
    level = floatround(flevel)
    return level
  }
  return 1
}
set_xp(id,Float:experience)
{
  set_private_f(id,OFFSET_EXPERIENCE,experience,EXPERIENCE_LIN)
}

get_level(Float:userxp) {
#if USE_EXTRA_LEVELS == 1
	if (userxp > XP_LEVEL_21)	return 21
	if (userxp > XP_LEVEL_20)	return 20
	if (userxp > XP_LEVEL_19)	return 19
	if (userxp > XP_LEVEL_18)	return 18
	if (userxp > XP_LEVEL_17)	return 17
	if (userxp > XP_LEVEL_16)	return 16
	if (userxp > XP_LEVEL_15)	return 15
	if (userxp > XP_LEVEL_14)	return 14
	if (userxp > XP_LEVEL_13)	return 13
	if (userxp > XP_LEVEL_12)	return 12
	if (userxp > XP_LEVEL_11)	return 11
#endif
	if (userxp > XP_LEVEL_10)	return 10
	if (userxp > XP_LEVEL_9)	return 9
	if (userxp > XP_LEVEL_8)	return 8
	if (userxp > XP_LEVEL_7)	return 7
	if (userxp > XP_LEVEL_6)	return 6
	if (userxp > XP_LEVEL_5)	return 5
	if (userxp > XP_LEVEL_4)	return 4
	if (userxp > XP_LEVEL_3)	return 3
	if (userxp > XP_LEVEL_2)	return 2
	if (userxp >= XP_LEVEL_1)	return 1

	return 0
}
Float:get_xp_for_level(level)
{
  if (level == 1) return float(XP_LEVEL_1)
  if (level == 2) return float(XP_LEVEL_2)
  if (level == 3) return float(XP_LEVEL_3)
  if (level == 4) return float(XP_LEVEL_4)
  if (level == 5) return float(XP_LEVEL_5)
  if (level == 6) return float(XP_LEVEL_6)
  if (level == 7) return float(XP_LEVEL_7)
  if (level == 8) return float(XP_LEVEL_8)
  if (level == 9) return float(XP_LEVEL_9)
  if (level == 10) return float(XP_LEVEL_10)
#if USE_EXTRA_LEVELS == 1
  if (level == 11) return float(XP_LEVEL_11)
  if (level == 12) return float(XP_LEVEL_12)
  if (level == 13) return float(XP_LEVEL_13)
  if (level == 14) return float(XP_LEVEL_14)
  if (level == 15) return float(XP_LEVEL_15)
  if (level == 16) return float(XP_LEVEL_16)
  if (level == 17) return float(XP_LEVEL_17)
  if (level == 18) return float(XP_LEVEL_18)
  if (level == 19) return float(XP_LEVEL_19)
  if (level == 20) return float(XP_LEVEL_20)
  if (level == 21) return float(XP_LEVEL_21)
  if (level == 22) return float(XP_LEVEL_22)
#endif
  return 0.0
}
__________________
Nonok is offline
Send a message via AIM to Nonok
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 09-27-2004 , 19:58  
Reply With Quote #2

why not make it easy for yourself and just read the info in the script?

Code:
#define AMXMODX               0   //  Set this to 1 if you're using AMX Mod X, 0 otherwise.
change to

Code:
#define AMXMODX               1   //  Set this to 1 if you're using AMX Mod X, 0 otherwise.
and try again
FeuerSturm is offline
Reply


Thread Tools
Display Modes

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 17:21.


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