Hi, i and my friend update the plugin and now have some problems.
The plugin is working but my problem is when i change map all XP (points) and levels dont save.
I change the map and when i join it my levels and XP start in 0 again ... :$
PHP Code:
/* Include some modules */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <nvault>
#include <fakemeta>
#include <dhudmessage>
#include <colorchat>
/* Who made this bad coded plugin? */
#define PLUGIN "SURF XP MOD"
#define AUTHOR "Ardivaba"
#define VERSION "1.0"
/* Lets define some illegal stuff */
#define TUTORIAL 1001
#define TASK_TUT 1111
/* What is the sound of the message? */
#define MSOUND "items/nvg_off.wav"
enum _:Data
{
_csw[32],
_xp[32],
_model[64]
}
new const Stuff[][Data]=
{
"",
{CSW_KNIFE, 10, "models/PFA/Surf/v_gknife.mdl"},
{CSW_DEAGLE, 20, "models/PFA/Surf/v_gdeagle.mdl"},
{CSW_M3, 30, "models/PFA/Surf/v_gm3.mdl"},
{CSW_HEGRENADE, 40, "models/PFA/Surf/v_shegrenade.mdl"},
{CSW_AK47, 50, "models/PFA/Surf/v_gak47.mdl"},
{CSW_M4A1, 50, "models/PFA/Surf/v_gm4.mdl"},
{CSW_GLOCK18, 60, "models/PFA/Surf/v_gglock.mdl"},
{CSW_USP, 60, "models/PFA/Surf/v_gusp.mdl"},
{CSW_AWP, 100, "models/PFA/Surf/v_gawp.mdl"}
}
/* So many levels...oh my f**in god */
new const LEVELS[200] = {
10,
20,
30,
40,
50,
60,
100,
...
}
new PXP[ 33 ]
new PLEVEL[ 33 ]
new PKS[ 33 ]
new g_vault
new SzMaxPlayers, SzSayText
public plugin_init()
{
//You want credits? Take credits...you stealz0rs
register_plugin(PLUGIN, VERSION, AUTHOR)
//You poor little guy died, what we gonna do now?
register_event( "DeathMsg", "EventDeathMsg", "a" )
//All kinds of information
register_clcmd( "say /pontos", "printXp", -1, "Print player Xp" )
register_clcmd( "say /nivel", "printLevel", -1, "Print player level" )
register_clcmd( "say /proximonivel", "printNewLevel", -1, "Print player how many xp left to new level" )
register_clcmd( "say /ajuda", "printHelp", -1, "Print help" )
register_clcmd( "say /info", "printInfo", -1, "Print info" )
register_clcmd( "say /armas", "printWeapons", -1, "Print weapon unlocks" )
//Nozoom stuff
register_event("SetFOV","zoom","b","1<90")
register_event("CurWeapon","ev_CurWeapon", "be", "1=1")
//Meat...mmmm, delicious ham
RegisterHam(Ham_Spawn, "player", "EventPlayerSpawn", 1)
RegisterHam(Ham_TakeDamage, "player", "fwHamTakeDamage")
//nVault stuff
g_vault = nvault_open("SURFXPMOD")
}
public plugin_precache()
{
precache_sound(MSOUND)
new i
for(i = 1; i < sizeof Stuff; i++)
precache_model(Stuff[i][_model])
}
public client_putinserver(id)
{
set_task(1.0, "surfcyka", id, _, _, "b")
}
public client_connect( id )
{
PXP[ id ] = 0
LoadData( id )
}
public client_disconnect( id )
{
SaveData( id )
PXP[ id ] = 0
PLEVEL[ id ] = 0
PKS[ id ] = 0
}
public EventPlayerSpawn( id )
{
new health
new newhealth
new money
new newmoney
new armor
new newarmor
money = cs_get_user_money( id )
newmoney = money + (PLEVEL[ id ] * 100)
cs_set_user_money( id, newmoney)
if( PLEVEL[ id ] <= 25 )
{
health = get_user_health( id )
newhealth = health + (PLEVEL[ id ])
set_user_health( id, newhealth )
}
else
{
health = get_user_health( id )
newhealth = 125
armor = get_user_armor( id )
newarmor = armor + ((PLEVEL[ id ]) - 25)
set_user_armor( id, newarmor )
set_user_health( id, newhealth )
}
}
public EventDeathMsg()
{
new killer = read_data( 1 )
new victim = read_data( 2 )
new headshot = read_data( 3 )
new xp
new hs
if(PLEVEL[ killer ] > PLEVEL[ victim ])
{
xp = 4
}
if(PLEVEL[ killer ] < PLEVEL[ victim ])
{
xp = 6
}
if(PLEVEL[ killer ] == PLEVEL[ victim ])
{
xp = 5
}
PKS[ victim ] = 0
if( victim == killer )
{
return PLUGIN_CONTINUE
}
if(headshot)
{
xp = xp + 5
hs = 1
}
if(PKS[ killer ] < 10)
{
PKS[ killer ]++
}
xp = xp + PKS[ killer ]
add_xp( killer, xp, hs )
check_level( killer )
return PLUGIN_HANDLED
}
/* Add xp */
public add_xp( id, xp, hs )
{
new newlevel = LEVELS[PLEVEL[ id ]]-PXP[ id ]
PXP[ id ] = PXP[ id ] + xp
if(hs)
{
set_dhudmessage(10, 80, 255, 0.53, 0.26, 2, 2.0, 9.0 );
show_dhudmessage(id, "[ www.pFa-Cm.Org ]");
set_dhudmessage(100, 100, 100, 0.53, 0.30, 2, 0.0, 2.0 )
show_dhudmessage(id, "HEADSHOT! Ganhaste %d Pontos! ^nMataste %d seguidos^nFaltam %d Pontos para o Proximo Nivel!", xp, PKS[ id ], newlevel)
}
else
{
set_dhudmessage(10, 80, 255, 0.53, 0.26, 2, 2.0, 9.0 );
show_dhudmessage(id, "[ www.pFa-Cm.Org ]");
set_dhudmessage(100, 100, 100, 0.53, 0.30, 2, 0.0, 2.0 )
show_dhudmessage(id, "Ganhaste %d Pontos! ^nMataste %d seguidos^nFaltam %d Pontos para o Proximo Nivel!", xp, PKS[ id ], newlevel)
}
}
/* Lets check if player got a new level */
public check_level( id )
{
if(PXP[ id ] >= LEVELS[PLEVEL[ id ]])
{
PLEVEL[ id ]++
ColorChat(id, TEAM_COLOR, "^04[ www.pFa-Cm.Org ]^03 O teu Nivel Atual:^01 %d", PLEVEL[ id ])
}
}
/* Lets print the list of weapon achievments */
public printWeapons( id )
{
show_motd(id, "surf_armas.txt")
}
public SubMenu( id, iMenu, iItem )
{
if( iItem == MENU_EXIT )
{
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
new iAccess, iData[ 6 ], iName[ 64 ], iCallBack;
menu_item_getinfo( iMenu, iItem, iAccess, iData, charsmax( iData ), iName, charsmax( iName ), iCallBack );
new iKey = str_to_num( iData );
switch( iKey )
{
case 1:
{
}
case 2:
{
}
case 3:
{
}
case 4:
{
}
}
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
public printHelp( id )
{
show_motd(id, "surf_ajuda.txt")
}
/* Plugin information */
public printInfo( id )
{
show_motd(id, "surf_info.txt")
}
public surfcyka(id)
{
new newlevel = LEVELS[PLEVEL[ id ]]-PXP[ id ]
ColorChat(id, TEAM_COLOR, "^04[ www.pFa-Cm.Org ]^03 Nivel:^x01 %d.^x03 Proximo Nivel:^01 %d.^03 Pontos:^01 %d", PLEVEL[ id ], newlevel, PXP[ id ])
}
/* Lets print players ammount of xp */
public printXp( id )
{
ColorChat(id, TEAM_COLOR, "^04[ www.pFa-Cm.Org ]^03 Os teus Pontos Atuais:^01 %d", PXP[ id ])
}
/* Lets print when player get's new level */
public printNewLevel( id )
{
new newlevel = LEVELS[PLEVEL[ id ]]-PXP[ id ]
ColorChat(id, TEAM_COLOR, "^04[ www.pFa-Cm.Org ]^03 Pontos para o Proximo Nivel:^01 %d", newlevel)
}
/* Lets print players level */
public printLevel( id )
{
ColorChat(id, TEAM_COLOR, "^04[ www.pFa-Cm.Org ]^03 O teu Nivel Atual:^01 %d", PLEVEL[ id ])
}
/* Save Data to nVault */
public SaveData(id)
{
new AuthID[35]
get_user_name(id,AuthID,34)
new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PXP[id],PLEVEL[id])
nvault_set(g_vault,vaultkey,vaultdata)
return PLUGIN_CONTINUE
}
/* Load Data from nVault */
public LoadData(id)
{
new AuthID[35]
get_user_name(id,AuthID,34)
new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",PXP[id],PLEVEL[id])
nvault_get(g_vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new playerxp[32], playerlevel[32]
parse(vaultdata, playerxp, 31, playerlevel, 31)
PXP[id] = str_to_num(playerxp)
PLEVEL[id] = str_to_num(playerlevel)
return PLUGIN_CONTINUE
}
/* Golden Weapons */
public ev_CurWeapon(id)
{
if(!is_user_connected(id) || !is_user_alive(id))
{
return PLUGIN_HANDLED;
}
new Weapon_Id = read_data(2)
for(new i = 1; i < sizeof Stuff; i++)
{
if(Weapon_Id == Stuff[i][_csw] && PLEVEL[id] >= Stuff[i][_xp])
set_pev(id, pev_viewmodel2, Stuff[i][_model])
}
return PLUGIN_CONTINUE;
}
public fwHamTakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
{
for(new i = 1; i < sizeof Stuff; i++)
{
if(get_user_weapon(attacker) == Stuff[i][_csw] && PLEVEL[ attacker ] >= Stuff[i][_xp])
{
SetHamParamFloat(4, damage * 2.0)
return HAM_HANDLED
}
}
return HAM_IGNORED
}