Raised This Month: $ Target: $400
 0% 

Errors! XP-mod Help please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-07-2007 , 13:30   Errors! XP-mod Help please
Reply With Quote #1

This Mod Worked Great With XunTrics Xp-Mod [TUT]
But some errors was relly annoying fixing so i decided to try PM's Version!

It worked better but when i put skills in for classes this happen!
Help please


Here is Errors!

Code:
Error: Empty statement on line 129 Error: Empty statement on line 133 Error: Empty statement on line 137 Error: Empty statement on line 141 Error: Empty statement on line 161 Warning: Tag mismatch on line 216

Here is Code!
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <nvault> #define PLUGIN "Team Fortress Mod - Counter Strike STYLE" #define VERSION "1.0b" #define AUTHOR "Frozen Usp" #define TASK_REGEN 999 #define MAXCLASSES 5 #define NUM_OF_LEVELS 20 new pclass:g_PlayerClass[33]; new g_PlayerXP[33]; new g_PlayerLevel[33]; new curweapon[33] new g_vault enum pclass { CLASS_NOTHING=0, CLASS_SCOUT, CLASS_SOLDIER, CLASS_HWGUY, CLASS_MEDIC, NUM_OF_CLASSES } new const CLASS_NAMES[NUM_OF_CLASSES][] = { "None", "Scout", "Soldier", "HwGuy", "Medic" } new gmsgStatusText; new const LEVELS[NUM_OF_LEVELS] = { 100, 200, 300, 450, 500, 700, 800, 900, 1100, 3200, 4000, 4500, 5000, 5500, 6000, 6600, 7700, 8800, 9900, 15000 } public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_cvar("amx_tfcmod" , "1") register_cvar("XP_per_kill", "20") register_cvar("SaveXP","1") register_clcmd("say /changeclass", "ChooseClass") register_clcmd("say_team /changeclass", "ChooseClass") register_clcmd("say /level", "ShowHUD") register_clcmd("say_team /level", "ShowHUD") register_clcmd("say /savexp", "SaveXP") register_clcmd("say_team /savexp", "SaveXP") register_clcmd("fullupdate","on_fullupdate") register_event("CurWeapon", "Event_CurWeapon", "be","1=1") register_event("DeathMsg", "DeathMsg", "ae") register_event("ResetHUD","on_spawn","be") register_menucmd(register_menuid("menu_ChooseClass"),1023,"MenuAction_ChooseClass") gmsgStatusText = get_user_msgid("StatusText") g_vault = nvault_open("VAULT") } public on_fullupdate(id) { return PLUGIN_HANDLED ; } public on_spawn(id) { // give the user 50 extra health if( g_PlayerClass[id] == CLASS_HWGUY); set_user_health(id,200) // and 100 points of armour + a helmet if( g_PlayerClass[id] == CLASS_HWGUY || g_PlayerClass[id] ==CLASS_SOLDIER); cs_set_user_armor(id,150,CS_ARMOR_VESTHELM) // and reduce their gravity to half if( g_PlayerClass[id] == CLASS_SCOUT || g_PlayerClass[id] ==CLASS_SOLDIER); set_user_gravity(id,0.7) // and in 5 seconds, call the on_regen function if( g_PlayerClass[id] == CLASS_MEDIC); set_task(5.0,"on_regen",TASK_REGEN+id) } public on_weaponevent(id) { new dummy ; new tempweapon = get_user_weapon(id,dummy,dummy) // get their current weapon if ( tempweapon != curweapon[id] ) {     // if they have changed weapon store their new weapon     curweapon[id] = tempweapon     set_user_maxspeed(id,(get_user_maxspeed(id)*1.5)) } } public Event_CurWeapon(id) if( g_PlayerClass[id] == CLASS_SCOUT || g_PlayerClass[id] ==CLASS_MEDIC); { set_user_maxspeed(id,400.0) } }   public on_regen(id) { // here, we take away the constant part of the task's id ( 999 ) // and are left with just the player id // (the task id is 999 + player's id ) if ( id > TASK_REGEN ) id -= TASK_REGEN ; // don't regen dead people ! if ( !is_user_alive(id) )     return ; // give user 5 hp set_user_health(id,get_user_health(id)+5) // and do it again in 5 seconds set_task(5.0,"on_regen",TASK_REGEN+id) } public SaveXP(id) { new AuthID[35] get_user_authid(id,AuthID,34) new vaultkey[64],vaultdata[256] format(vaultkey,63,"%s-CLASS",AuthID) format(vaultdata,255,"%i#%i#%i#",g_PlayerClass[id],g_PlayerXP[id],g_PlayerLevel[id]) nvault_set(g_vault,vaultkey,vaultdata) return PLUGIN_HANDLED } public LoadXP(id) { new AuthID[35] get_user_authid(id,AuthID,34) new vaultkey[64],vaultdata[256] format(vaultkey,63,"%s-CLASS",AuthID) format(vaultdata,255,"%i#%i#%i#",g_PlayerClass[id],g_PlayerXP[id],g_PlayerLevel[id]) nvault_get(g_vault,vaultkey,vaultdata,255) replace_all(vaultdata, 255, "#", " ") new playerclas[32], playerxpp[32], playerlv[32] parse(vaultdata, playerclas, 31, playerxpp, 31, playerlv, 31) g_PlayerClass[id] = str_to_num(playerclas) g_PlayerXP[id] = str_to_num(playerxpp) g_PlayerLevel[id] = str_to_num(playerlv) return PLUGIN_HANDLED } public ChooseClass(id) { new menu[] = "TFC Mod: Choose Class^n^n1. Scout^n2. Soldier^n3. HwGuy^n4. Medic^n^n0. Exit" new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3 show_menu(id, keys, menu, -1, "menu_ChooseClass")     } public MenuAction_ChooseClass(id, pclass:key) { // The keys map to the pclass ids (I think), so no need to have a big if construct;) if (key == g_PlayerClass[id]) {     client_print(id, print_chat, "[TFC Mod] You are already a %s! Choose something else!", CLASS_NAMES[key]);     ChooseClass(id);     return; } client_print(id, print_chat, "[TFC Mod] You are now a %s!", key); g_PlayerClass[id] = key;       ShowHUD(id); } public ResetHUD(id) { if (g_PlayerClass[id] == CLASS_NOTHING)     ChooseClass(id); } public DeathMsg() { if (!get_cvar_num("amx_tfcmod"))     return; new attacker = read_data(1) if (g_PlayerClass[attacker] == CLASS_NOTHING)     return; if(g_PlayerLevel[attacker] == NUM_OF_LEVELS)     return; g_PlayerXP[attacker] += get_cvar_num("XP_per_kill") if(g_PlayerXP[attacker] >= LEVELS[g_PlayerLevel[attacker]]) {     ++g_PlayerLevel[attacker];         client_print(attacker, _:print_chat, "[TFC Mod] Congratulations! You are now level %i!", g_PlayerLevel[attacker]) } ShowHUD(attacker); } public client_connect(id) { // A client is coming -> clear all vars for him, so that he doesn't have the pclass/level/xp of the player who was in here before him g_PlayerClass[id] = CLASS_NOTHING; g_PlayerXP[id] = 0; g_PlayerLevel[id] = 0; } public client_disconnect(id) { if(get_cvar_num("SaveXP") == 1) {         SaveXP(id) } } ShowHUD(id)     { new HUD[51] format(HUD, 50, "[%s]Level: %i XP: %i", CLASS_NAMES[g_PlayerClass[id]], g_PlayerLevel[id], g_PlayerXP[id]) message_begin(MSG_ONE, gmsgStatusText, {0,0,0}, id) write_byte(0) write_string(HUD) message_end() }
Frozen Usp is offline
Send a message via MSN to Frozen Usp
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-07-2007 , 14:37   Re: Errors! XP-mod Help please
Reply With Quote #2

Do not put semicolons after your if statements
__________________
M249-M4A1 is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-07-2007 , 14:45   Re: Errors! XP-mod Help please
Reply With Quote #3

OMG...
Thats the worst i ahve done...
Thanks man
sorry i can't give you karma anymore got to spread out reputation first

But the Warning stile remains to this line
g_PlayerXP[id] = str_to_num(playerxpp)
Frozen Usp is offline
Send a message via MSN to Frozen Usp
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-07-2007 , 14:49   Re: Errors! XP-mod Help please
Reply With Quote #4

Try this (didn't test it. I also fixed your code majorly because the indentations were so messed up):

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <nvault>

#define PLUGIN "Team Fortress Mod - Counter Strike STYLE"
#define VERSION "1.0b"
#define AUTHOR "Frozen Usp"

#define TASK_REGEN 999
#define MAXCLASSES 5
#define NUM_OF_LEVELS 20

new pclass:g_PlayerClass[33];
new 
g_PlayerXP[33];
new 
g_PlayerLevel[33];
new 
curweapon[33]
new 
g_vault

enum pclass 
{
    
CLASS_NOTHING=0,
    
CLASS_SCOUT,
    
CLASS_SOLDIER,
    
CLASS_HWGUY,
    
CLASS_MEDIC,
    
    
NUM_OF_CLASSES
}


new const 
CLASS_NAMES[NUM_OF_CLASSES][] = {
    
"None",
    
"Scout",
    
"Soldier",
    
"HwGuy",
    
"Medic"
}

new 
gmsgStatusText;

new const 
LEVELS[NUM_OF_LEVELS] = {
    
100,
    
200,
    
300,
    
450,
    
500,
    
700,
    
800,
    
900,
    
1100,
    
3200,
    
4000,
    
4500,
    
5000,
    
5500,
    
6000,
    
6600,
    
7700,
    
8800,
    
9900,
    
15000
}



public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_cvar("amx_tfcmod" "1")
    
register_cvar("XP_per_kill""20")
    
register_cvar("SaveXP","1")
    
    
register_clcmd("say /changeclass""ChooseClass")
    
register_clcmd("say_team /changeclass""ChooseClass")
    
register_clcmd("say /level""ShowHUD")
    
register_clcmd("say_team /level""ShowHUD")
    
register_clcmd("say /savexp""SaveXP")
    
register_clcmd("say_team /savexp""SaveXP")
    
register_clcmd("fullupdate","on_fullupdate")
    
    
register_event("CurWeapon""Event_CurWeapon""be","1=1")
    
register_event("DeathMsg""DeathMsg""ae")
    
register_event("ResetHUD","on_spawn","be")
    
    
register_menucmd(register_menuid("menu_ChooseClass"),1023,"MenuAction_ChooseClass")
    
    
gmsgStatusText get_user_msgid("StatusText")
    
g_vault nvault_open("VAULT")
    
}


public 
on_fullupdate(id)
{
    return 
PLUGIN_HANDLED ;
}


public 
on_spawn(id)
{
    
// give the user 50 extra health
    
if( g_PlayerClass[id] == CLASS_HWGUY)
        
set_user_health(id,200)
    
    
// and 100 points of armour + a helmet
    
if( g_PlayerClass[id] == CLASS_HWGUY || g_PlayerClass[id] ==CLASS_SOLDIER)
        
cs_set_user_armor(id,150,CS_ARMOR_VESTHELM)
    
    
// and reduce their gravity to half
    
if( g_PlayerClass[id] == CLASS_SCOUT || g_PlayerClass[id] ==CLASS_SOLDIER)
        
set_user_gravity(id,0.7)
    
    
// and in 5 seconds, call the on_regen function
    
if( g_PlayerClass[id] == CLASS_MEDIC)
        
set_task(5.0,"on_regen",TASK_REGEN+id)
}


public 
on_weaponevent(id)
{
    new 
dummy ;
    
    new 
tempweapon get_user_weapon(id,dummy,dummy)
    
// get their current weapon
    
if ( tempweapon != curweapon[id] )
    {
        
// if they have changed weapon store their new weapon
        
curweapon[id] = tempweapon
        set_user_maxspeed
(id,(get_user_maxspeed(id)*1.5))
    }
}

public 
Event_CurWeapon(id)
{
    if( 
g_PlayerClass[id] == CLASS_SCOUT || g_PlayerClass[id] ==CLASS_MEDIC)
    {
        
set_user_maxspeed(id,400.0)
    }
}


public 
on_regen(id)
{
    
// here, we take away the constant part of the task's id ( 999 )
    // and are left with just the player id
    // (the task id is 999 + player's id )
    
if ( id TASK_REGEN )
        
id -= TASK_REGEN ;
    
    
// don't regen dead people !
    
if ( !is_user_alive(id) )
        return ;
    
    
// give user 5 hp
    
set_user_health(id,get_user_health(id)+5)
    
    
// and do it again in 5 seconds
    
set_task(5.0,"on_regen",TASK_REGEN+id)
}

public 
SaveXP(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-CLASS",AuthID)
    
format(vaultdata,255,"%i#%i#%i#",g_PlayerClass[id],g_PlayerXP[id],g_PlayerLevel[id])
    
nvault_set(g_vault,vaultkey,vaultdata)
    return 
PLUGIN_HANDLED
}


public 
LoadXP(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-CLASS",AuthID)
    
format(vaultdata,255,"%i#%i#%i#",g_PlayerClass[id],g_PlayerXP[id],g_PlayerLevel[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
    
    
replace_all(vaultdata255"#"" ")
    
    new 
playerclas[32], playerxpp[32], playerlv[32]
    
    
parse(vaultdataplayerclas31playerxpp31playerlv31)
    
    switch (
str_to_num(playerclas))
    {
        case 
1g_PlayerClass[id] = CLASS_SCOUT;
        case 
2g_PlayerClass[id] = CLASS_SOLDIER;
        case 
3g_PlayerClass[id] = CLASS_HWGUY;
        case 
4g_PlayerClass[id] = CLASS_MEDIC;
        default: 
g_PlayerClass[id] = CLASS_NOTHING;
    }
    
    
g_PlayerXP[id] = str_to_num(playerxpp)
    
g_PlayerLevel[id] = str_to_num(playerlv)
    
    return 
PLUGIN_HANDLED
}

public 
ChooseClass(id)
{
    new 
menu[] = "TFC Mod: Choose Class^n^n1. Scout^n2. Soldier^n3. HwGuy^n4. Medic^n^n0. Exit"
    
new keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
    
    show_menu
(idkeysmenu, -1"menu_ChooseClass")    
    
}

public 
MenuAction_ChooseClass(idpclass:key)
{
    
// The keys map to the pclass ids (I think), so no need to have a big if construct;)
    
if (key == g_PlayerClass[id])
    {
        
client_print(idprint_chat"[TFC Mod] You are already a %s! Choose something else!"CLASS_NAMES[key]);
        
ChooseClass(id);
        return;
    }
    
client_print(idprint_chat"[TFC Mod] You are now a %s!"key);
    
g_PlayerClass[id] = key;      
    
ShowHUD(id);
}

public 
ResetHUD(id)
{
    if (
g_PlayerClass[id] == CLASS_NOTHING)
        
ChooseClass(id);
}


public 
DeathMsg()
{
    if (!
get_cvar_num("amx_tfcmod"))
        return;
    
    new 
attacker read_data(1)
    
    if (
g_PlayerClass[attacker] == CLASS_NOTHING)
        return;
    
    if(
g_PlayerLevel[attacker] == NUM_OF_LEVELS)
        return;
    
    
g_PlayerXP[attacker] += get_cvar_num("XP_per_kill")
    
    if(
g_PlayerXP[attacker] >= LEVELS[g_PlayerLevel[attacker]])
    {
        ++
g_PlayerLevel[attacker];
        
        
client_print(attacker_:print_chat"[TFC Mod] Congratulations! You are now level %i!"g_PlayerLevel[attacker])
    }
    
ShowHUD(attacker);
}


public 
client_connect(id)
{
    
// A client is coming -> clear all vars for him, so that he doesn't have the pclass/level/xp of the player who was in here before him
    
g_PlayerClass[id] = CLASS_NOTHING;
    
g_PlayerXP[id] = 0;
    
g_PlayerLevel[id] = 0;
}

public 
client_disconnect(id)
{
    if(
get_cvar_num("SaveXP") == 1) {
        
        
SaveXP(id)
    }
}

public 
ShowHUD(id)
{
    new 
HUD[51]
    
format(HUD50"[%s]Level: %i XP: %i"CLASS_NAMES[g_PlayerClass[id]], g_PlayerLevel[id], g_PlayerXP[id])
    
    
message_begin(MSG_ONEgmsgStatusText, {0,0,0}, id)
    
write_byte(0)
    
write_string(HUD)
    
message_end()

__________________
M249-M4A1 is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-08-2007 , 07:42   Re: Errors! XP-mod Help please
Reply With Quote #5

The first one worked 2
No Diffrent found

P.S i was going to do the indentation
but i hade to go
Thanks anyway
Frozen Usp is offline
Send a message via MSN to Frozen Usp
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-08-2007 , 12:23   Re: Errors! XP-mod Help please
Reply With Quote #6

Quote:
Originally Posted by Frozen Usp View Post
The first one worked 2
No Diffrent found

P.S i was going to do the indentation
but i hade to go
Thanks anyway
The only difference between the second one I posted and the first, was the first had this:

PHP Code:
enum

and I put the { on the same line as enum, because doing that would make indentations work with the AMXX Studio auto-indenter
__________________
M249-M4A1 is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 12:33   Re: Errors! XP-mod Help please
Reply With Quote #7

enum ftw.

I recently discovered the joys of :
PHP Code:
enum ( += 32 )

for defining TASK_... values.
purple_pixie is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-08-2007 , 13:00   Re: Errors! XP-mod Help please
Reply With Quote #8

Quote:
Originally Posted by purple_pixie View Post
enum ftw.

I recently discovered the joys of :
PHP Code:
enum ( += 32 )

for defining TASK_... values.
Tell me more
__________________
M249-M4A1 is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-08-2007 , 16:01   Re: Errors! XP-mod Help please
Reply With Quote #9

Yea...
Tell us more...
Frozen Usp is offline
Send a message via MSN to Frozen Usp
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 16:22   Re: Errors! XP-mod Help please
Reply With Quote #10

Well you know the concept of:
PHP Code:
 #define TASK_REGEN 1000
#define TASK_SPAWN 1032
#define TASK_FIREDAMAGE 1064
...
set_task(...,TASK_SPAWN+id
etc.

Well easier than having to keep adding 32 to the number each time yourself, you could do:
PHP Code:
enum ( += 32 )
{
    
TASK_REGEN=1000,
    
TASK_SPAWN,
    
TASK_FIREDAMAGE
    
...


Last edited by purple_pixie; 10-08-2007 at 16:25.
purple_pixie is offline
Reply



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 16:13.


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