AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   US Military Mod (https://forums.alliedmods.net/showthread.php?t=66346)

>)SL(< | Wicked 01-28-2008 19:49

US Military Mod
 
1 Attachment(s)
This is my very first mod. I hope that it doesn't get deleted :cry:.

Well, this is just a simple XP based mod that I made following XunTric's tutorial. I took some of that stuff out, added stuff, changed stuff... and I got this!

There are 27 different ranks, you start at private and work your way up to General. By default, XP per kill is set to 1. If you want to change the XP per kill, you might want to go into the .sma file and change lines 184 and 248 to better suit the output.

I hope to be able to add a menu so that you can choose if you want to be in the Marines or the US Army, and at any time you can change which one your in. But say for example, your a Sergeant in the US Army, with 130 kills, I would like that to stay only on the Army side if you switch to the Marines so you start at scratch in the Marines instead of skipping the first 4 ranks.

There are 2 CVARS for this plugin:
Code:

xp_per_kill 1 //by default is set to 1
sv_rankmod 1 //by default set to 1, 0 turns of the plugin

Well, enjoy!
I haven't really been able to test it, so if someone could real quick, that would be awsome!

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <nvault>

#define PLUGIN "Rank Mod"
#define VERSION "1.00"
#define AUTHOR "Robert aka Wicked"

#define MAXCLASSES 27

new PlayerClass[33];
new 
PlayerXP[33];
new 
PlayerLevel[33];
new 
XP_Killg_vaultSaveXP;

new const 
CLASSES[MAXCLASSES][] = {
    
"Private",
    
"Private 1st Class",
    
"Specialist",
    
"Corporal",
    
"Sergant",
    
"Staff Sergeant",
    
"Sergeant 1st Class",
    
"Master Sergeant",
    
"1st Sergeant",
    
"Sergeant Major",
    
"Command Sergeant Major",
    
"Sergeant Major Of The Army",
    
"Warrant Officer",
    
"Chief Warrant Officer[1]",
    
"Chief Warrant Officer[2]",
    
"Chief Warrant Officer[3]",
    
"Master Chief Warrant Officer",
    
"2nd Lieutenant",
    
"1st Lieutenant",
    
"Captian",
    
"Major",
    
"Lieutenant Colonel",
    
"Colonel",
    
"Brigadier General",
    
"Major General",
    
"Lieutenant General",
    
"General"
};

new const 
LEVELS[26] = {
    
25,
    
50,
    
75,
    
100,
    
150,
    
200,
    
250,
    
300,
    
400,
    
500,
    
600,
    
800,
    
1000,
    
1200,
    
1400,
    
1600,
    
1800,
    
2000,
    
2500,
    
3000,
    
3500,
    
4000,
    
5500,
    
6000,
    
7000,
    
8000
};

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
//CVAR line, adds a cvar command to the plugin (on/off)
    
register_cvar("sv_rankmod""1");
    
    
register_event("DeathMsg""eDeath""a");
    
    
SaveXP register_cvar("SaveXP","1");
    
XP_Kill=register_cvar("XP_per_kill""1");
    
g_vault nvault_open("VAULT");
}

public 
SaveData(id)
{
    new 
AuthID[35];
    
get_user_authid(id,AuthID,34);
 
    new 
vaultkey[64],vaultdata[256];
    
format(vaultkey,63,"%s-Rank Mod",AuthID);
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]);
    
nvault_set(g_vault,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-Rank Mod",authid);
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]);
    
nvault_get(g_vault,vaultkey,vaultdata,255);
 
    
replace_all(vaultdata255"#"" ");
 
    new 
playerxp[32], playerlevel[32];
 
    
parse(vaultdataplayerxp31playerlevel31);
 
    
PlayerXP[id] = str_to_num(playerxp);
    
PlayerLevel[id] = str_to_num(playerlevel);
 
    return 
PLUGIN_CONTINUE;
}

//Loads Class, Level, and XP connect
public client_connect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
LoadData(id);
        
client_print(idprint_chat"[Rank Mod] XP Loaded!");
    }
}

//Saves XP on disconnect
public client_disconnect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
SaveData(id);
    }
    
PlayerXP[id] = 0;
    
PlayerLevel[id] = 0;
    
PlayerClass[id] = 0;
}

public 
eDeath(  ) 
{
    new 
iVictim read_data);
    new 
attacker get_user_attacker(iVictim);
 
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill);
 
    if(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
    
PlayerLevel[attacker] += 1;
 
    
ShowHud(attacker);
    
SaveData(attacker);
}

public 
ShowHud(id)
{
 
set_hudmessage(255000.750.0106.015.0);
 
show_hudmessage(id"Rank: %s^nKills: %i^n",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]]);


Updates:
1.1 -
  • Took out Vault, replaced it with nVault
  • Changed the SaveXP function
  • changed the LoadXP function
  • took out ResetHUD
  • fixed the crash (hopefully)
1.00 -
  • Initial Release

chris 01-29-2008 00:41

Re: US Military Mod
 
Nice I'll try this out. By any chance is this the same as the BF2 Rank mod?

fxfighter 01-29-2008 02:00

Re: US Military Mod
 
it shuld krash the server i recommend you test your plugins before submiting them next time.
PHP Code:

public ResetHUD(id)
{
    
//Checks to see if rankmod is on
    
if(get_cvar_num("sv_rankmod") == 0) {
        return 
PLUGIN_HANDLED;
    }
 
    return 
PLUGIN_HANDLED;


Use PLUGIN_CONTINUE
You shuld replace vault whit nvault
You dont need all the defines.....
You Dont need fun and cstrike
Use Pcvars
Add more futures.

Quote:

public client_connect(id)
{ client_print(id, print_chat, "[Rank Mod] XP Loaded!");
client_print(id, print_chat, "[Rank Mod] Your a %s with %s kills", PlayerClas
}

you cant print chat in thare hud if they arent in yet.

hasta 01-29-2008 07:30

Re: US Military Mod
 
plugin work by steamid?
can u do this by name(nick)
tnx

>)SL(< | Wicked 01-29-2008 07:38

Re: US Military Mod
 
Quote:

Originally Posted by chris (Post 579437)
Nice I'll try this out. By any chance is this the same as the BF2 Rank mod?

Sort of... This is basically a dumb downed version.

Quote:

Originally Posted by fxfighter (Post 579452)
it shuld krash the server i recommend you test your plugins before submiting them next time.
PHP Code:

public ResetHUD(id)
{
    
//Checks to see if rankmod is on
    
if(get_cvar_num("sv_rankmod") == 0) {
        return 
PLUGIN_HANDLED;
    }
 
    return 
PLUGIN_HANDLED;


Use PLUGIN_CONTINUE
You shuld replace vault whit nvault
You dont need all the defines.....
You Dont need fun and cstrike
Use Pcvars
Add more futures.


you cant print chat in thare hud if they arent in yet.

could you help me with this then, im fairly new to this.
ok, this is what i should do?:
-Replace all instances of vault to nvault?

Thats basically all that i can understand since im new, so u gotta explain it a little more.

Also, i was gonna test this as soon as i got home from school today.

Oh and i cant believe i didnt see that one part where it should crash the server, it basically common sense that plugin_continue should be there =\

Quote:

Originally Posted by hasta (Post 579483)
plugin work by steamid?
can u do this by name(nick)
tnx

Trust me, you want to go by id, not nick, because if someone wants to change their name, they will have to start all over again.

fxfighter 01-29-2008 08:30

Re: US Military Mod
 
actuly you can remove the hole resethud event becase it actuly dont do enything.

i updated the xp tutorial script its at the last page have a look.
XP TUTORIAL
got pcvars,nvault and new menu system.

>)SL(< | Wicked 01-29-2008 11:10

Re: US Military Mod
 
Ohh, thank thank you :D

Would you like to help me with this mod? I got an idea of making a menu so that you can choose if your in the army or the marines.

>)SL(< | Wicked 01-29-2008 11:56

Re: US Military Mod
 
Quote:

Originally Posted by >)SL(< | Wicked (Post 579540)
Ohh, thank thank you :D

Would you like to help me with this mod? I got an idea of making a menu so that you can choose if your in the army or the marines.



OMG, if i follow that, i will need to rewrite everything! :|

I'll just change the vault to nvault, and take out the defines and test that in a little bit, once i get home from school.



Updated!

>)SL(< | Wicked 01-29-2008 14:45

Re: US Military Mod
 
Ok, i have tested it, and I need some help :(. Can someone please help me? I cant get anything to show up or work... It compiles fine though...

fxfighter 01-29-2008 15:33

Re: US Military Mod
 
you have remove the ResetHUD function but you still register it.
remove it or it should cause problems
Quote:

register_event("ResetHUD", "ResetHud", "b");

dont know if you removed it or not frome your main code but i can see it at the top post.


All times are GMT -4. The time now is 22:06.

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