Raised This Month: $ Target: $400
 0% 

Please fix my code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SwiFtStRiDeR
Member
Join Date: Jan 2008
Location: Los Angeles, California,
Old 03-14-2008 , 19:01   Please fix my code
Reply With Quote #1

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

#define MAXRANKS 55

new PlayerXP[33],PlayerLevel[33],PlayerRank[33], g_status_sync
new XP_Kill,XP_Knife,XP_Hs,SaveXP
new g_vault  

public plugin_init()
{
    
register_plugin("Call of Duty 4: Modern Warfare Xp Mod""1.0""SwiFtStRyDeR")
    
register_event("DeathMsg""eDeath""a")
    
register_event("StatusValue""on_ShowStatus""be""1=2""2!0");
    
SaveXP register_cvar("SaveXP","1")
    
XP_Kill=register_cvar("XP_per_kill""10")
    
XP_Hs=register_cvar("XP_hs_bonus","5")
    
XP_Knife=register_cvar("XP_knife_bonus","10")
    
g_vault nvault_open("cod4mwxm")
    
register_clcmd("say /xp""ShowHud")
    
register_clcmd("say_team /xp""ShowHud")
}  

new const 
RANKS[] = {
    
"Private First Class",
    
"Private First Class",
    
"Private First Class",
    
"Lance Corporal",
    
"Lance Corporal",
    
"Lance Corporal",
    
"Corporal",
    
"Corporal",
    
"Corporal",
    
"Sergeant",
    
"Sergeant",
    
"Sergeant",
    
"Staff Sergeant",
    
"Staff Sergeant",
    
"Staff Sergeant",
    
"Gunnery",
    
"Gunnery Sergeant",
    
"Gunnery Sergeant",
    
"Master",
    
"Master Sergeant",
    
"Master Sergeant",
    
"Master Gunnery Sergeant",
    
"Master Gunnery Sergeant",
    
"Master Gunnery Sergeant",
    
"2nd Lieutenant",
    
"2nd Lieutenant",
    
"2nd Lieutenant",
    
"1st Lieutenant",
    
"1st Lieutenant",
    
"1st Lieutenant",
    
"Captain",
    
"Captain",
    
"Captain",
    
"Major",
    
"Major",
    
"Major",
    
"Lieutenant Colonel",
    
"Lieutenant Colonel",
    
"Lieutenant Colonel",
    
"Colonel",
    
"Colonel",
    
"Colonel",
    
"Brigadier General",
    
"Brigadier",
    
"Brigadier",
    
"Major General",
    
"Major General",
    
"Major General",
    
"Lieutenant General",
    
"Lieutenant General",
    
"Lieutenant General",
    
"General",
    
"General",
    
"General",
    
"Commander"
}  

new const 
EXPERIENCE[] = {
    
0,
    
30,
    
120,
    
270,
    
480,
    
750,
    
1080,
    
1470,
    
1920,
    
2430,
    
3000,
    
3650,
    
4380,
    
5190 ,
    
6080,
    
7050,
    
8100,
    
9230,
    
10440,
    
11730,
    
13100,
    
14550,
    
16080,
    
17690,
    
19380,
    
21150,
    
23000,
    
24930,
    
26940,
    
29030,
    
31240,
    
33570,
    
36020,
    
38590,
    
41280,
    
44090,
    
47020,
    
50070,
    
53240,
    
56530,
    
59940,
    
63470,
    
67120,
    
70890,
    
74780,
    
78790,
    
82920,
    
87170,
    
91540,
    
96030,
    
100640,
    
105370,
    
110220,
    
115190,
    
120280
}  

public 
eDeath(idattacker)

    if(
PlayerRank[attacker] == 0)
        return 
PLUGIN_CONTINUE
    
    
new iVictim read_data)
    new 
headshot read_data)
    new 
clipammoweapon get_user_weapon(id,clip,ammo);
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill
    if(
headshot
        
PlayerXP[attacker] += get_pcvar_num(XP_Hs
    if(
weapon == CSW_KNIFE
        
PlayerXP[attacker] += get_pcvar_num(XP_Knife)  
    while(
PlayerRank[attacker] >= RANKS[PlayerRank[attacker]]) 
    
client_print(attackerprint_chat"[CoD4 MW XP Mod] Congratulations! You are a level %i %s!"PlayerLevel[attacker],PlayerRank[attacker]]) 
    
PlayerLevel[attacker] += 


{
public 
ShowHud(id
}     
{
set_hudmessage(255000.750.0106.015.0
show_hudmessage(id"Level: %i^nXP: %i^nRank: %s",PlayerLevel[id],PlayerXP[id],PlayerRank[id]]) 
}  

public 
on_ShowStatus(id)
{
new 
name[32], pid read_data(2);
new 
pidlevel PlayerLevel[pid];
new 
pidrank PlayerRank[pid];
new 
pidxp PlayerXP[pid];

get_user_name(pidname31);
new 
color1 0color2 0;

if (
get_user_team(pid) == 1)
    
color1 255;
    else
        
color2 255        
    
    set_hudmessage
(color1100color2, -1.00.3500.0120.0);    
    
ShowSyncHudMsg(idg_status_sync"%s^nLevel: %d %s^nRank: %d %s^nXp: %d"namePlayerLevel[pidlevel]+1PlayerRank[pidrank]+1PlayerXP[pidxp]+1);
}

public 
on_HideStatus(id)
{
    
ClearSyncHud(idg_status_sync);
}

public 
client_connect(id
{
    if(
get_pcvar_num(SaveXP) == 1
    { 
        
LoadData(id
    } 
}  

public 
client_disconnect(id

    if(
get_pcvar_num(SaveXP) == 1
    { 
        
SaveData(id
    } 


public 
SaveData(id

    new 
AuthID[35get_user_authid(id,AuthID,34)
    new 
vaultkey[64],vaultdata[256
    
format(vaultkey,63,"%s-Mod",AuthID
    
format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id], PlayerRank[id]) 
    
nvault_set(g_vault,vaultkey,vaultdata
    return 
PLUGIN_CONTINUE 
}  

public 
LoadData(id

    new 
AuthID[35get_user_authid(id,AuthID,34
    new 
vaultkey[64],vaultdata[256
    
format(vaultkey,63,"%s-Mod",AuthID
    
format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id], PlayerRank[id])  
    
nvault_get(g_vault,vaultkey,vaultdata,255
    
replace_all(vaultdata255"#"" "
    new 
playerxp[32], playerlevel[32], playerrank[32
    
parse(vaultdataplayerxp31playerlevel31 playerrank31
    
PlayerXP[id] = str_to_num(playerxp
    
PlayerLevel[id] = str_to_num(playerlevel
    
PlayerRank[id] = str_to_num(playerrank)
    return 
PLUGIN_CONTINUE 

Your plugin successfully compiled!
Use the link below to download your plugin.
Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/home/groups/amxmodx/tmp3/phpOumrej.sma(155) : error 001: expected token: ",", but found "]"
/home/groups/amxmodx/tmp3/phpOumrej.sma(155) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpOumrej.sma(155) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpOumrej.sma(155) : fatal error 107: too many error messages on one line

Compilation aborted.
4 Errors.
Done.

Will these errors affect the plugin in gameplay?
__________________
Quote:
Originally Posted by Hawk552
hi my description sucks and I go on and on and on until I start foaming at the mouth and fall backwards

Last edited by SwiFtStRiDeR; 03-14-2008 at 20:32.
SwiFtStRiDeR is offline
Send a message via MSN to SwiFtStRiDeR
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-14-2008 , 19:08   Re: Please fix my code
Reply With Quote #2

attach the .sma, or use [php] tags.
no one wants to mess with code that isnt indented
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 03-14-2008 , 19:21   Re: Please fix my code
Reply With Quote #3

a lot of false { and }
you defined const RANK twice...
fix this first
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who don´t.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
Old 03-14-2008, 19:35
SwiFtStRiDeR
This message has been deleted by SwiFtStRiDeR.
SwiFtStRiDeR
Member
Join Date: Jan 2008
Location: Los Angeles, California,
Old 03-14-2008 , 19:35   Re: Please fix my code
Reply With Quote #4

Ok, put [php] tags around and fixed defining ranks twice.
__________________
Quote:
Originally Posted by Hawk552
hi my description sucks and I go on and on and on until I start foaming at the mouth and fall backwards
SwiFtStRiDeR is offline
Send a message via MSN to SwiFtStRiDeR
jasonf20
Junior Member
Join Date: Mar 2008
Old 03-14-2008 , 19:46   Re: Please fix my code
Reply With Quote #5

im not sure but dont u need the parameters in the eDeath function?
like: edeath (id, attacker)
jasonf20 is offline
atomen
Veteran Member
Join Date: Oct 2006
Location: Stockholm, Sweden
Old 03-15-2008 , 07:24   Re: Please fix my code
Reply With Quote #6

I've have nearly fixed the whole code just 1 warning.
I don't know how i should use it in the code.

Since you have used "RANKS" instead.
Quote:
Warning 203 = Line 252 : "Symbol is never used : 'EXPERIENCE'"
And here's the script, I've made it a little bit more readable.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define MAXRANKS 55

new PlayerXP[33],PlayerLevel[33],PlayerRank[33], g_status_sync
new XP_Kill,XP_Knife,XP_Hs,SaveXP
new g_vault  

public plugin_init()
{
    
register_plugin("Call of Duty 4: Modern Warfare Xp Mod""1.0""SwiFtStRyDeR")
    
register_event("DeathMsg""eDeath""a")
    
register_event("StatusValue""on_ShowStatus""be""1=2""2!0");
    
SaveXP register_cvar("SaveXP","1")
    
XP_Kill=register_cvar("XP_per_kill""10")
    
XP_Hs=register_cvar("XP_hs_bonus","5")
    
XP_Knife=register_cvar("XP_knife_bonus","10")
    
g_vault nvault_open("cod4mwxm")
    
register_clcmd("say /xp""ShowHud")
    
register_clcmd("say_team /xp""ShowHud")
}  

new const 
RANKS[] = {
    
"Private First Class",
    
"Private First Class",
    
"Private First Class",
    
"Lance Corporal",
    
"Lance Corporal",
    
"Lance Corporal",
    
"Corporal",
    
"Corporal",
    
"Corporal",
    
"Sergeant",
    
"Sergeant",
    
"Sergeant",
    
"Staff Sergeant",
    
"Staff Sergeant",
    
"Staff Sergeant",
    
"Gunnery",
    
"Gunnery Sergeant",
    
"Gunnery Sergeant",
    
"Master",
    
"Master Sergeant",
    
"Master Sergeant",
    
"Master Gunnery Sergeant",
    
"Master Gunnery Sergeant",
    
"Master Gunnery Sergeant",
    
"2nd Lieutenant",
    
"2nd Lieutenant",
    
"2nd Lieutenant",
    
"1st Lieutenant",
    
"1st Lieutenant",
    
"1st Lieutenant",
    
"Captain",
    
"Captain",
    
"Captain",
    
"Major",
    
"Major",
    
"Major",
    
"Lieutenant Colonel",
    
"Lieutenant Colonel",
    
"Lieutenant Colonel",
    
"Colonel",
    
"Colonel",
    
"Colonel",
    
"Brigadier General",
    
"Brigadier",
    
"Brigadier",
    
"Major General",
    
"Major General",
    
"Major General",
    
"Lieutenant General",
    
"Lieutenant General",
    
"Lieutenant General",
    
"General",
    
"General",
    
"General",
    
"Commander"
}  

new const 
EXPERIENCE[] = {
    
0,
    
30,
    
120,
    
270,
    
480,
    
750,
    
1080,
    
1470,
    
1920,
    
2430,
    
3000,
    
3650,
    
4380,
    
5190 ,
    
6080,
    
7050,
    
8100,
    
9230,
    
10440,
    
11730,
    
13100,
    
14550,
    
16080,
    
17690,
    
19380,
    
21150,
    
23000,
    
24930,
    
26940,
    
29030,
    
31240,
    
33570,
    
36020,
    
38590,
    
41280,
    
44090,
    
47020,
    
50070,
    
53240,
    
56530,
    
59940,
    
63470,
    
67120,
    
70890,
    
74780,
    
78790,
    
82920,
    
87170,
    
91540,
    
96030,
    
100640,
    
105370,
    
110220,
    
115190,
    
120280
}  

public 
eDeath(idattacker)

    if(
PlayerRank[attacker] == 0)
        return 
0;

    new 
headshot read_data)
    new 
clipammoweapon get_user_weapon(id,clip,ammo);
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill)

    if(
headshot)
    {
        
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
    }

    if(
weapon == CSW_KNIFE)
    {
        
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
    }

    while(
PlayerRank[attacker] >= RANKS[PlayerRank[attacker]])
    
client_print(attackerprint_chat"[CoD4 MW XP Mod] Congratulations! You are a level %i %s!"PlayerLevel[attacker],PlayerRank[attacker]) 
    
PlayerLevel[attacker] += 1

    
return 0;


public 
ShowHud(id
{
    
set_hudmessage(255000.750.0106.015.0
    
show_hudmessage(id"Level: %i^nXP: %i^nRank: %s"PlayerLevel[id], PlayerXP[id], PlayerRank[id]) 
}

public 
on_ShowStatus(id)
{
    new 
name[32], pid read_data(2);
    new 
pidlevel PlayerLevel[pid];
    new 
pidrank PlayerRank[pid];
    new 
pidxp PlayerXP[pid];

    
get_user_name(pidname31);
    new 
color1 0color2 0;

    if (
get_user_team(pid) == 1)
    {
        
color1 255;
    }
    else
    {
        
color2 255
    
}       
    
    
set_hudmessage(color1100color2, -1.00.3500.0120.0);    
    
ShowSyncHudMsg(idg_status_sync"%s^nLevel: %d %s^nRank: %d %s^nXp: %d"namePlayerLevel[pidlevel]+1PlayerRank[pidrank]+1PlayerXP[pidxp]+1);
}

public 
on_HideStatus(id)
{
    
ClearSyncHud(idg_status_sync);
}

public 
client_connect(id
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
        
LoadData(id
    } 
}  

public 
client_disconnect(id

    if(
get_pcvar_num(SaveXP) == 1
    { 
        
SaveData(id
    } 


public 
SaveData(id)

    new 
AuthID[35]
    new 
vaultkey[64],vaultdata[256]

    
get_user_authid(id,AuthID,34)

    
format(vaultkey,63,"%s-Mod",AuthID
    
format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id], PlayerRank[id]) 

    
nvault_set(g_vault,vaultkey,vaultdata)
    return 
0;
}  

public 
LoadData(id

    new 
AuthID[35]
    new 
vaultkey[64],vaultdata[256]

    
get_user_authid(id,AuthID,34)

    
format(vaultkey,63,"%s-Mod",AuthID
    
format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id], PlayerRank[id])  

    
nvault_get(g_vault,vaultkey,vaultdata,255
    
replace_all(vaultdata255"#"" ")

    new 
playerxp[32], playerlevel[32], playerrank[32
    
parse(vaultdataplayerxp31playerlevel31playerrank31)

    
PlayerXP[id] = str_to_num(playerxp
    
PlayerLevel[id] = str_to_num(playerlevel
    
PlayerRank[id] = str_to_num(playerrank)

    return 
0;

__________________
atomen is offline
Send a message via MSN to atomen
eagleAR
New Member
Join Date: Jan 2007
Old 03-25-2008 , 07:18   Re: Please fix my code
Reply With Quote #7

give all RANKS a unique name
& you donot corelate PlayerXP[attacker] with EXPERIENCE in public eDeath(id, attacker)

Here
\
\
\
while(PlayerRank[attacker] >= RANKS[PlayerRank[attacker]])
client_print(attacker, print_chat, "[CoD4 MW XP Mod] Congratulations! You are a level %i %s!", PlayerLevel[attacker],PlayerRank[attacker])
PlayerLevel[attacker] += 1
eagleAR 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 03:53.


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