Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
04-15-2012
, 08:17
Re: New XP Mod tutorial
#278
I'm trying to make a xp plugin trough this tutorial but i have a few complications:
I want to have 2 diffrent classes, the classes automaticly set itself depending on what team the player is on (so a diffrent ranking for terrorists and CT's).
This is what I have done so far, im lost now.
could anyone take a look and tell me how i can make players have diffrent ranks/level/xp when they switch team?
Errors
Code:
Error: Expected token: "]", but found "[" on line 152
Error: Expected token: "]", but found "[" on line 159
Warning: Symbol is assigned a value that is never used: "iVictim" on line 162
Error: Expected token: "]", but found "[" on line 169
Error: Undefined symbol "Rank" on line 169
Error: Invalid expression, assumed zero on line 169
Error: Too many error messages on one line on line 169
Compilation aborted.
6 Errors.
There might be some more errors, compiler stopped after line 169.
Spoiler
PHP Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <nvault> #include <cstrike> #include <hamsandwich> #define PLUGIN "JB Rank" #define VERSION "1.0" #define AUTHOR "Striker07" new const g_szPluginPrefix [] = "XP Ranking" ; new g_iMaxPlayers ; #define FIRST_PLAYER_ID 1 #define IsPlayer(%1) (FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers) new g_iMsgSayText ; new PlayerXP [ 33 ], PlayerLevel [ 33 ]; //these are cvars for special kills new g_iXpKill , g_iXPHSKill , g_iXPKnifeKill , g_iXPFragKill ; new g_iVault ; enum _ : Ranks { player_level_1 , player_level_2 , player_level_3 , player_level_4 , player_level_5 , player_level_6 , player_level_7 , player_level_8 , player_level_9 , player_level_10 } new const ranknames [ Ranks ][] = { "Thug's lil bitch" , "Rookie" , "Thief" , "Gangsta" , "DrugDealer" , "PIMP" , "Gangleader" , "Assasin" , "Copkilla" , "Godfather" }; new const CTranknames [ Ranks ][] = { "Trainee" , "Greenhorn" , "Agent" , "Undercover Agent" , "Soldier" , "Special Agent" , "Lieutenant" , "Captain" , "General" , "Admiral" }; new const LEVELS [ Ranks ] = { 0 , 100 , 200 , 400 , 800 , 1600 , 3200 , 6400 , 12800 , 20000 }; new const LEVELSCT [ Ranks ] = { 0 , 100 , 250 , 500 , 1000 , 2000 , 4000 , 8000 , 16000 , 25000 }; new gHudSync ; public plugin_init () { register_plugin ( PLUGIN , VERSION , AUTHOR ); //Sync the hud messages gHudSync = CreateHudSyncObj (); // variables for colorchat g_iMaxPlayers = get_maxplayers (); g_iMsgSayText = get_user_msgid ( "SayText" ); //Player Events //RegisterHam(Ham_Spawn, "player", "fwdHamPlayerSpawn", 1); RegisterHam ( Ham_Killed , "player" , "fwdHamPlayerKilled" , 1 ); //Cvars g_iXpKill = register_cvar ( "xmt_kill_xp" , "3" ); g_iXPHSKill = register_cvar ( "xmt_hs_kill_xp" , "2" ); g_iXPKnifeKill = register_cvar ( "xmt_knifekill_xp" , "3" ); g_iXPFragKill = register_cvar ( "xmt_fragkill_xp" , "5" ); //Nvault g_iVault = nvault_open ( "xp_rank" ); } public fwdHamPlayerKilled ( iVictim , iKiller , iShouldGib ) { new attacker = read_data ( 1 ); new iVictim = read_data ( 2 ); new headshot = read_data ( 3 ); new szName [ 32 ]; get_user_name ( attacker , szName , 31 ); new clip , ammo , weapon = get_user_weapon ( attacker , clip , ammo ); PlayerXP [ attacker ] += get_pcvar_num ( g_iXpKill ); if( headshot ) PlayerXP [ attacker ] += get_pcvar_num ( g_iXPHSKill ); if( weapon == CSW_KNIFE ) PlayerXP [ attacker ] += get_pcvar_num ( g_iXPKnifeKill ); if( weapon == CSW_HEGRENADE ) PlayerXP [ attacker ] += get_pcvar_num ( g_iXPFragKill ); if( cs_get_user_team ( attacker ) == CS_TEAM_CT ) while( PlayerXP [ attacker ] >= LEVELS [ PlayerLevel [ attacker ]]) { PlayerLevel [ attacker ] += 1 ; /*Line152*/ fnColorPrint ( 0 , "Player ^4%s ^1is now level^4 %i: %s ^1!" , szName , PlayerLevel [ attacker ], CTranknames [ PlayerXP [ attacker ][ Rank ] ] ); //Line 152 } else if( cs_get_user_team ( attacker ) == CS_TEAM_T ) while( PlayerXP [ attacker ] >= LEVELS [ PlayerLevel [ attacker ]]) { PlayerLevel [ attacker ] += 1 ; /*Line159*/ fnColorPrint ( 0 , "Player ^4%s ^1is now level^4 %i: %s ^1!" , szName , PlayerLevel [ attacker ], ranknames [ PlayerXP [ attacker ][ Rank ] ]); //Line 159 } ShowHud ( attacker ); } public ShowHud ( id ) { if( cs_get_user_team ( id ) == CS_TEAM_CT ) { set_hudmessage ( 0 , 0 , 255 , 0.06 , 0.26 , 0 , 0.0 , 15.0 , _ , _ , - 1 ); /*Line 169*/ ShowSyncHudMsg ( id , gHudSync , "Level: [%i: %s] ^nXP: [%d / %d]" , PlayerLevel [ id ], CTranknames [ PlayerXP [ id ][ Rank ] ], PlayerXP [ id ], ( PlayerXP [ id ][ Rank ] + 1 )== Ranks ? LEVELSCT [ PlayerXP [ id ][ Rank ]][ 1 ] : LEVELSCT [ PlayerXP [ id ][ Rank ] + 1 ][ 0 ] ); } else if( cs_get_user_team ( id ) == CS_TEAM_T ) { set_hudmessage ( 0 , 0 , 255 , 0.06 , 0.26 , 0 , 0.0 , 15.0 , _ , _ , - 1 ); /*Same error as 169*/ ShowSyncHudMsg ( id , gHudSync , "Level: [%i: %s] ^nXP: [%d / %d]" , PlayerLevel [ id ], ranknames [ PlayerXP [ id ][ Rank ] ], PlayerXP [ id ], ( PlayerXP [ id ][ Rank ] + 1 )== Ranks ? LEVELS [ PlayerXP [ id ][ Rank ]][ 1 ] : LEVELS [ PlayerXP [ id ][ Rank ] + 1 ][ 0 ] ); } } public client_connect ( id ) { LoadData ( id ); } public client_disconnect ( id ) { SaveData ( id ); } public SaveData ( id ) { new AuthID [ 35 ]; get_user_authid ( id , AuthID , 34 ); new vaultkey [ 64 ], vaultdata [ 256 ]; format ( vaultkey , 63 , "%s-Mod" , AuthID ); format ( vaultdata , 255 , "%i#%i#" , PlayerXP [ id ], PlayerLevel [ id ]); nvault_set ( g_iVault , vaultkey , vaultdata ); return PLUGIN_CONTINUE ; } public LoadData ( id ) { new AuthID [ 35 ]; get_user_authid ( id , AuthID , 34 ); new vaultkey [ 64 ], vaultdata [ 256 ]; format ( vaultkey , 63 , "%s-Mod" , AuthID ); format ( vaultdata , 255 , "%i#%i#" , PlayerXP [ id ], PlayerLevel [ id ]); nvault_get ( g_iVault , vaultkey , vaultdata , 255 ); replace_all ( vaultdata , 255 , "#" , " " ); new playerxp [ 32 ], playerlevel [ 32 ]; parse ( vaultdata , playerxp , 31 , playerlevel , 31 ); PlayerXP [ id ] = str_to_num ( playerxp ); PlayerLevel [ id ] = str_to_num ( playerlevel ); return PLUGIN_CONTINUE ; } fnColorPrint ( index , const Msg [], any :...) { /*Credits to pastout for his colorprint! :) */ new Buffer [ 190 ], Buffer2 [ 192 ]; formatex ( Buffer2 , charsmax ( Buffer2 ), "^x04[%s] ^x01%s" , g_szPluginPrefix , Msg ); vformat ( Buffer , charsmax ( Buffer ), Buffer2 , 3 ); if (! index ) { for (new i = 1 ; i <= g_iMaxPlayers ; i ++) { if (! is_user_connected ( i )) continue; message_begin ( MSG_ONE_UNRELIABLE , g_iMsgSayText , _ , i ); write_byte ( i ); write_string ( Buffer ); message_end (); } } else { if (! is_user_connected ( index )) return; message_begin ( MSG_ONE , g_iMsgSayText , _ , index ); write_byte ( index ); write_string ( Buffer ); message_end (); } }
Last edited by striker07; 04-15-2012 at 08:19 .