Veteran Member
Join Date: Jul 2011
Location: Belgium
|
08-29-2016
, 10:50
Re: [HELP] Surf XP Levels Error
|
#6
|
Lol, what the hell have you been doing to this code? Also, you're using fvault functions without even having an fvault include?
I have added the fvault include and the plugin compiles now. Although, you have some warnings but i don't know what you're trying to do.
You open nvault and assign it to g_vault but further you do nothing with it? Also, why do you use fvault and nvault at the same time? I'd recommend using either one of them.
PHP Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <hamsandwich> #include <colorchat> #include <cstrike> #include <nvault> #include <fakemeta> #include <fvault>
#define PLUGIN "SURF XP MOD" #define AUTHOR "Ardivaba" #define VERSION "1.0"
#define TUTORIAL 1001 #define TASK_TUT 1111
#define MSOUND "items/nvg_off.wav"
enum { RED = 1, BLUE, YELLOW, GREEN }
new const g_TutorPrecache[][] = { "gfx/career/icon_!.tga", "gfx/career/icon_!-bigger.tga", "gfx/career/icon_i.tga", "gfx/career/icon_i-bigger.tga", "gfx/career/icon_skulls.tga", "gfx/career/round_corner_ne.tga", "gfx/career/round_corner_nw.tga", "gfx/career/round_corner_se.tga", "gfx/career/round_corner_sw.tga", "resource/TutorScheme.res", "resource/UI/TutorTextWindow.res" }
new g_MsgTutor new g_MsgTutClose
new const LEVELS[200] = { 10, 20, 40, 80, 160, ... }
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_AWP, 100, "models/PFA/Surf/v_gawp.mdl"}, {CSW_GLOCK18, 200, "models/PFA/Surf/v_gglock.mdl"}, {CSW_USP, 200, "models/PFA/Surf/v_gusp.mdl"} }
new PXP[ 33 ] new PLEVEL[ 33 ] new PKS[ 33 ] new g_vault
new SzMaxPlayers, SzSayText
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR)
register_event( "DeathMsg", "EventDeathMsg", "a" )
register_clcmd( "say /xp", "printXp", -1, "Ile masz Expa" ) register_clcmd( "say /nivel", "printLevel", -1, "Jaki masz level" ) register_clcmd( "say /proximonivel", "printNewLevel", -1, "Ile musisz miec jeszcze expa do nastepnego levela" ) register_clcmd( "say /info", "printInfo", -1, "Wyswietla Info" ) register_clcmd( "say /armas", "printWeapons", -1, "Info o Odblokowanych Broniach" )
register_event("CurWeapon","ev_CurWeapon", "be", "1=1")
RegisterHam(Ham_Spawn, "player", "EventPlayerSpawn", 1) RegisterHam(Ham_TakeDamage, "player", "fwHamTakeDamage")
g_vault = nvault_open("SURFXPMOD")
g_MsgTutor = get_user_msgid("TutorText") g_MsgTutClose = get_user_msgid("TutorClose")
register_clcmd("say", "hook_say") register_clcmd("say_team", "hook_say_team") SzMaxPlayers = get_maxplayers() SzSayText = get_user_msgid ("SayText") register_message(SzSayText, "MsgDuplicate") }
public plugin_precache() { precache_sound(MSOUND)
new i
for(i = 0; i < sizeof g_TutorPrecache; i++) { precache_generic(g_TutorPrecache[i]) }
for(i = 1; i < sizeof Stuff; i++) { precache_model(Stuff[i][_model]) } }
public hook_say(id) { new SzMessages[192], SzName[32] new SzAlive = is_user_alive(id)
read_args(SzMessages, 191) remove_quotes(SzMessages) get_user_name(id, SzName, 31)
new Admin = 0, iFlags = get_user_flags(id)
if(iFlags & ADMIN_IMMUNITY) { // as flags que cada tag vai ter !! Admin = 1 } else if(iFlags & ADMIN_LEVEL_H) { Admin = 2 } else if(iFlags & ADMIN_LEVEL_G) { Admin = 3 } else if(iFlags & ADMIN_LEVEL_F) { Admin = 4 } else if(iFlags & ADMIN_LEVEL_E) { Admin = 5 } else if(iFlags & ADMIN_LEVEL_D) { Admin = 6 } else if(iFlags & ADMIN_RESERVATION) { Admin = 7 } else if(iFlags & ADMIN_USER) { Admin = 8 }
if(!is_valid_msg(SzMessages)) { return PLUGIN_CONTINUE; }
switch(Admin) { case 1: { format(SzMessages, 191, "^1%s ^4[FUNDADOR] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 2: { format(SzMessages, 191, "^1%s ^4[LEADER] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 3: { format(SzMessages, 191, "^1%s ^4[ADMIN] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 4: { format(SzMessages, 191, "^1%s ^4[MOD.GERAL] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 5: { format(SzMessages, 191, "^1%s ^4[MOD] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 6: { format(SzMessages, 191, "^1%s ^4[CONFIG] Nivel: %d ^3%s : ^3%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 7: { format(SzMessages, 191, "^1%s ^4[VIP] Nivel: %d ^3%s : ^1%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 8: { format(SzMessages, 191, "^1%s ^4Nivel: %d ^3%s : ^1%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } }
for(new i = 1; i <= SzMaxPlayers; i++) { if(!is_user_connected(i)) { continue; }
if(SzAlive && is_user_alive(i) || !SzAlive && !is_user_alive(i)) { message_begin(MSG_ONE, get_user_msgid("SayText"), {0, 0, 0}, i); write_byte(id); write_string(SzMessages); message_end(); } } return PLUGIN_CONTINUE }
public hook_say_team(id) { new SzMessages[192], SzName[32] new SzAlive = is_user_alive(id)
read_args(SzMessages, 191) remove_quotes(SzMessages) get_user_name(id, SzName, 31)
new Admin = 0, iFlags = get_user_flags(id)
if(iFlags & ADMIN_IMMUNITY) { // as flags que cada tag vai ter !! Admin = 1 } else if(iFlags & ADMIN_LEVEL_H) { Admin = 2 } else if(iFlags & ADMIN_LEVEL_G) { Admin = 3 } else if(iFlags & ADMIN_LEVEL_F) { Admin = 4 } else if(iFlags & ADMIN_LEVEL_E) { Admin = 5 } else if(iFlags & ADMIN_LEVEL_D) { Admin = 6 } else if(iFlags & ADMIN_RESERVATION) { Admin = 7 } else if(iFlags & ADMIN_USER) { Admin = 8 }
if(!is_valid_msg(SzMessages)) { return PLUGIN_CONTINUE; }
switch(Admin) { case 1: { format(SzMessages, 191, "^1%s(Equipa) ^4[FUNDADOR] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 2: { format(SzMessages, 191, "^1%s(Equipa) ^4[LEADER] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 3: { format(SzMessages, 191, "^1%s(Equipa) ^4[ADMIN] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 4: { format(SzMessages, 191, "^1%s(Equipa) ^4[MOD.GERAL] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 5: { format(SzMessages, 191, "^1%s(Equipa) ^4[MOD] Nivel: %d ^3%s : ^4%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 6: { format(SzMessages, 191, "^1%s(Equipa) ^4[CONFIG] Nivel: %d ^3%s : ^3%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 7: { format(SzMessages, 191, "^1%s(Equipa) ^4[VIP] Nivel: %d ^3%s : ^1%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } case 8: { format(SzMessages, 191, "^1%s(Equipa) ^4Nivel: %d ^3%s : ^1%s", SzAlive ? "" : "*Morto*", PLEVEL[id], SzName, SzMessages) } }
for(new i = 1; i <= SzMaxPlayers; i++) { if(!is_user_connected(i)) { continue; }
if(SzAlive && is_user_alive(i) || !SzAlive && !is_user_alive(i)) { message_begin(MSG_ONE, get_user_msgid("SayText"), {0, 0, 0}, i); write_byte(id); write_string(SzMessages); message_end(); } } return PLUGIN_CONTINUE }
public MsgDuplicate(id) { return PLUGIN_HANDLED; }
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 ] <= 50 ) { health = get_user_health( id ) newhealth = health + (PLEVEL[ id ]) set_user_health( id, newhealth ) } else { health = get_user_health( id ) newhealth = 150
armor = get_user_armor( id ) newarmor = armor + ((PLEVEL[ id ]) - 50) 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 = 3 }
if(PLEVEL[ killer ] < PLEVEL[ victim ]) { xp = 5 }
if(PLEVEL[ killer ] == PLEVEL[ victim ]) { xp = 4 }
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 )
new Text[ 100 ] formatex(Text,191,"Morreste!") MakeTutor(victim,Text,RED,3.0) return PLUGIN_CONTINUE }
public add_xp( id, xp, hs ) { new newlevel = LEVELS[PLEVEL[ id ]]-PXP[ id ]
PXP[ id ] = PXP[ id ] + xp
if(hs) { new Text[ 100 ] formatex(Text,191,"HEADSHOT! Ganhaste %d XP! ^nMataste %d seguidos^nFaltam %d XP para o Proximo Nivel!", xp, PKS[ id ], newlevel) MakeTutor(id,Text,GREEN,3.0) } else { new Text[ 100 ] formatex(Text,191,"Ganhaste %d XP! ^nMataste %d seguidos^nFaltam %d XP para o Proximo Nivel!", xp, PKS[ id ], newlevel) MakeTutor(id,Text,GREEN,3.0) } }
public check_level( id ) { if(PXP[ id ] >= LEVELS[PLEVEL[ id ]]) { PLEVEL[ id ]++ new Text[ 100 ] formatex(Text,191,"Estas no Nivel %d", PLEVEL[ id ]) MakeTutor(id,Text,GREEN,5.0) ColorChat(id, TEAM_COLOR, "^04[ PFA | SURF ]^03 Estas no Nivel:^04 %d", PLEVEL[ id ]) } }
public printWeapons( id ) { new Text[ 255 ] formatex(Text,191, "Nivel 10: Faca Dourada^nNivel 20: AK-47 + M4A1 Dourada^nNivel 30: Deagle Dourada^nNivel 40: Shotgun Dourada^nNivel 50: Granada NAZI^nNivel 70: Glock + USP Dourada^nNivel 100: AWP^n^nTodas as Armas tiram o Dobro do Dano.") MakeTutor(id,Text,YELLOW,7.0) }
public printInfo( id ) { new Text[ 255 ] formatex(Text,191, "Como Funciona o XP do Surf?^n-Ganhas armas douradas/especiais num certo nivel.^n^nSo Isso?^n-Nao, Tambem ganhas 1 HP por nivel e mais dinheiro!") MakeTutor(id,Text,YELLOW,7.0) }
public printXp( id ) { new Text[ 100 ] formatex(Text,191,"O Teu XP: %d", PXP[ id ]) MakeTutor(id,Text,YELLOW,3.0) ColorChat(id, TEAM_COLOR, "^04[ PFA | SURF ] ^03O Teu XP:^04 %d", PXP[ id ]) }
public printNewLevel( id ) { new newlevel = LEVELS[PLEVEL[ id ]]-PXP[ id ] new Text[ 100 ] formatex(Text,191,"Faltam-te para o Priximo Nivel: %d XP", newlevel) MakeTutor(id,Text,YELLOW,3.0) ColorChat(id, TEAM_COLOR, "^04[ PFA | SURF ] ^03Faltam-te para o Proximo Nivel:^04 %d ^03XP", newlevel) }
public printLevel( id ) { new Text[ 100 ] formatex(Text,191,"Estas no nivel %d", PLEVEL[ id ]) MakeTutor(id,Text,YELLOW,3.0) ColorChat(id, TEAM_COLOR, "^04[ PFA | SURF ] ^03Estas no Nivel:^04 %d", PLEVEL[ id ]) }
new const g_savedata[] = "xp"
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",PXP[id],PLEVEL[id])
fvault_set_data(g_savedata,vaultkey,vaultdata) } public LoadData(id) { new AuthID[35], playerxp[32], playerlevel[32] get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256] format(vaultkey,63,"%s-Mod",AuthID)
fvault_get_data(g_savedata,vaultkey,vaultdata, charsmax(vaultdata))
parse(vaultdata, playerxp, charsmax(playerxp), playerlevel, charsmax(playerlevel))
PXP[id] = str_to_num(playerxp) PLEVEL[id] = str_to_num(playerlevel) }
MakeTutor(id,Text[],Color,Float:Time = 0.0) {
client_cmd( id, "spk %s", MSOUND )
if(is_user_connected( id )) { message_begin(MSG_ONE_UNRELIABLE,g_MsgTutor,_,id) write_string(Text) write_byte(0) write_short(0) write_short(0) write_short(1<<Color) message_end() } if(Time != 0.0) {
if( task_exists( id + TASK_TUT ) ) { remove_task( id + TASK_TUT ) } set_task(Time,"RemoveTutor",id + TASK_TUT) } } public RemoveTutor(taskID) { new id = taskID - TASK_TUT message_begin(MSG_ALL,g_MsgTutClose,_,id) message_end() } 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 }
bool:is_valid_msg(const SzMessages[]) { if( SzMessages[0] == '@' || !strlen(SzMessages)){ return false; } return true; }
__________________
|
|