AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [REQ] XP mod tutorial without classes. (https://forums.alliedmods.net/showthread.php?t=167785)

fantarn 09-20-2011 05:30

[REQ] XP mod tutorial without classes.
 
Hello can anybody make a xpmod tutorial without classes?
Im not sure if this already exist i could only find tutorials with classes.

Thanks

Erox902 09-20-2011 07:33

Re: [REQ] XP mod tutorial without classes.
 
Just don't add anything including "classes":?:
Read the code slowly and you will understand it's just like doing it with classes.
Only simpler. If you did'nt just copy and pasted the whole tutorial this should be even easier than writing it.

liinuus 09-20-2011 12:27

Re: [REQ] XP mod tutorial without classes.
 
you can use this.
Code:
// based on a xp mod tutorial alredy posted on forum #include <amxmodx> #include <amxmisc> #include <nvault> #include <hamsandwich> // max levels #define MAX_LEVELS 6 new const g_iLevels[ MAX_LEVELS ] = {     100,     200,     400,     800,     1600,     3200 } new g_iPlayerXp[ 33 ], g_iPlayerLevel[ 33 ] new g_iKillXP, g_iKnifeBonus, g_iHSBonus, g_iSaveXP; new g_Vault; new const g_szVaultName[ ] = "NoClassesMod"; public plugin_init() {     register_plugin("XpMod", "1.0", "liinuus")         register_event("DeathMsg", "eDeath", "a")         register_clcmd("say /xp", "ShowHud")     register_clcmd("say_team /xp", "ShowHud")             g_iSaveXP = register_cvar( "SaveXP", "1" )         g_iKillXP = register_cvar( "Kill_XP", "10" )         g_iKnifeBonus = register_cvar( "KnifeBonus_XP", "10" )         g_iHSBonus = register_cvar( "HSBonus_XP", "5" )         g_Vault = nvault_open(g_szVaultName) } public eDeath(  )   {     new attacker = read_data( 1 )     new iVictim = read_data( 2 )           if( attacker == iVictim || !is_user_connected( attacker ) || get_user_team( attacker ) == get_user_team( iVictim )) return;           new headshot = read_data( 3 )           new weapon[7]     read_data( 4, weapon, charsmax( weapon ) )       g_iPlayerXp[ attacker ] += get_pcvar_num( g_iKillXP )           if( headshot )         g_iPlayerXp[ attacker ] += get_pcvar_num( g_iHSBonus )       if( equal( weapon, "knife" ) )         g_iPlayerXp[ attacker ] += get_pcvar_num( g_iKnifeBonus )         while( g_iPlayerXp[ attacker ] >= g_iLevels[ g_iPlayerLevel[ attacker ] ])     {         client_print( attacker, print_chat, "[Animal Mod] Congratulations! You are level %i", g_iPlayerLevel[ attacker ] )         g_iPlayerLevel[ attacker ] += 1     }         ShowHud( attacker )     SaveData( attacker ) }   public ShowHud( iPlayer ) {     set_hudmessage( 255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0 )     show_hudmessage( iPlayer, "Level: %i^nXP: %i",g_iPlayerLevel[ iPlayer ],g_iPlayerXp[ iPlayer ] ) }             public client_connect( iPlayer ) {     if( get_pcvar_num( g_iSaveXP ) != 0 )         LoadData( iPlayer ) } public client_disconnect( iPlayer ) {     if(get_pcvar_num( g_iSaveXP ) != 0)         SaveData( iPlayer )         ResetAll( iPlayer ) } public SaveData( iPlayer ) {     new vaultdata[ 256 ], vaultkey[ 64 ], Authid[ 35 ]         get_user_authid( iPlayer,Authid,34 )         format( vaultkey, 63,"%s-Mod", Authid )     format( vaultdata, 63,"%i#%i#", g_iPlayerXp[ iPlayer ], g_iPlayerLevel[ iPlayer ] )     nvault_set( g_Vault,vaultkey,vaultdata )         return PLUGIN_CONTINUE; } public LoadData( iPlayer ) {     new Authid[ 35 ]         get_user_authid( iPlayer,Authid,34 )           new vaultdata[ 256 ], vaultkey[ 64 ]        new playerxp[ 32 ], playerlevel[ 32 ]         format( vaultkey,63,"%s-Mod",Authid )     format( vaultdata, 63,"%i#%i#", g_iPlayerXp[ iPlayer ], g_iPlayerLevel[ iPlayer ] )     nvault_get( g_Vault,vaultkey,vaultdata,255 )       replace_all(vaultdata, 255, "#", " ")             parse( vaultdata, playerxp, 31, playerlevel, 31 )       g_iPlayerXp[ iPlayer ] = str_to_num( playerxp )         g_iPlayerLevel[ iPlayer ] = str_to_num( playerlevel )               return PLUGIN_CONTINUE } public ResetAll( iPlayer ) {     g_iPlayerXp[ iPlayer ] = 0     g_iPlayerLevel[ iPlayer ] = 0 } public plugin_end( ) {     nvault_close( g_Vault ) }


All times are GMT -4. The time now is 19:43.

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