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.

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

Re: US Military Mod
 
Wow, thanks, again another noobish mistake.

I will fix this later when I get a chance.




I have updated it, but i still cant get it to display at all ingame, someone plz help :'(

bmann_420 01-30-2008 03:26

Re: US Military Mod
 
Its a nice compilation, but this is also why you dont post your first plugins. Constant updates on nobbish mistakes = dont publish. Dont get me wrong, seems good and all, just get to know your shit and ..... then post it. :D

fxfighter 01-30-2008 03:51

Re: US Military Mod
 
Remove on connect becase we cant show him the message if he hasnt got in yet.
That's pretty much it^^
PHP Code:

client_print(idprint_chat"[Rank Mod] XP Loaded!"); 

Noticed that i made the same mistake at the script i posted in xp tutorial thread:oops:

hasta 01-30-2008 06:12

Re: US Military Mod
 
Quote:

Originally Posted by >)SL(< | Wicked (Post 579486)
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.

Will u do this plugin by name? Not all admins use Steam servers ;)

>)SL(< | Wicked 01-30-2008 07:35

Re: US Military Mod
 
Quote:

Originally Posted by bmann_420 (Post 579809)
Its a nice compilation, but this is also why you dont post your first plugins. Constant updates on nobbish mistakes = dont publish. Dont get me wrong, seems good and all, just get to know your shit and ..... then post it. :D

Well, I knew that i wouldnt get published, I just posted it so i could get some help.

Quote:

Originally Posted by fxfighter (Post 579817)
Remove on connect becase we cant show him the message if he hasnt got in yet.
That's pretty much it^^
PHP Code:

client_print(idprint_chat"[Rank Mod] XP Loaded!"); 

Noticed that i made the same mistake at the script i posted in xp tutorial thread:oops:

Ok, I'll take that out, but i still don't see the HUD message showing my my rank and xp...

Quote:

Originally Posted by hasta (Post 579833)
Will u do this plugin by name? Not all admins use Steam servers ;)

Umm... I'm not really sure how to do that, also, i think i would have to go through and change A LOT of stuff. Once i get more familiar with scripting, i will look into how to do that. ;)

fxfighter 01-30-2008 07:46

Re: US Military Mod
 
Quote:

Originally Posted by >)SL(< | Wicked (Post 579851)

Ok, I'll take that out, but i still don't see the HUD message showing my my rank and xp...

PHP Code:

set_hudmessage(255000.750.0106.015.0); 


you show the hud message at the top right-.- if you run cz whit tutori it shuldnt be visible

use
Quote:

set_hudmessage(255, 0, 0, 0.01, 0.2, 0, 6.0, 12.0)
top left under radar

>)SL(< | Wicked 01-30-2008 09:18

Re: US Military Mod
 
Oohhhh, ok thank you.

Also, once I add this, will the mod work? Because I also don't see anything when I kill someone, so I don't think its really working, but I will test it out again when I get home from school.

fxfighter 01-30-2008 10:18

Re: US Military Mod
 
1 Attachment(s)
Fixed your code all bugs shuld be removed.
i added resetxp function and small stuf if you didnt mind.
hud is shown at the top right corner...
Dont thank me or hate me i did it becase i was bored-.-

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

Re: US Military Mod
 
Thank you, im looking at it right now, and Im learning alot from it. +Karma!


I got a question. Does this look right?
PHP Code:

public client_connect(id)
{
 if(
get_pcvar_num(SaveXP) == 1)
 {
  
LoadData(id);
 }
 
 if(
PlayerXP[id] == && PlayerClass[id] == && PlayerLevel[id] == 0)
 {
  
ChooseClass(id);
 }
 


Would this open up my ChooseClass menu if a new player comes in the server who hasnt been in before?

If so, YES!! :D I thought of it my self lol :D.


O and could a moderator move this to scripting help, since im basically getting help with this. Thanks

fxfighter 01-30-2008 10:46

Re: US Military Mod
 
yes it opens the menu but!
it opens the menu when he press the connect button-.-
so do the cheek when he spawns or when a new round starts and it all shuld be fine.

>)SL(< | Wicked 01-30-2008 10:52

Re: US Military Mod
 
so... I would make a new fuction like so:
PHP Code:

public client_putinserver(id)
{
 if(
PlayerXP[id] == && PlayerClass[id] == && PlayerLevel[id] == 0)
 {
  
ChooseClass(id);
 }
 



YamiKaitou 01-30-2008 11:34

Re: US Military Mod
 
Quote:

Originally Posted by hasta (Post 579833)
Will u do this plugin by name? Not all admins use Steam servers ;)

Give me 10 USD and I will do it for you. Besides, he is not required to support Non-Steam servers.

>)SL(< | Wicked 01-30-2008 12:23

Re: US Military Mod
 
2 Attachment(s)
Hey, fighter, i just put in a menu, but right now it doesnt do anything (meaning nothing happens if you choose sumthing in the menu). I am hoping to use this menu to let ppl choose if they want to be in the army, marines, or navy. Each will have similar but different ranking names. I will add the sma to this reply. Could you check it out to see if everything is good? You dont have to though, its completely up to you.

Thanks

fxfighter 01-30-2008 14:01

Re: US Military Mod
 
remove this becase he isnt in yet and if he is he cant pick becase motd and the team menu is in the way.
PHP Code:

public client_putintserver(id)
{
 if(
PlayerXP[id] == && PlayerClass[id] == && PlayerLevel[id] == 0)
 {
 
  
ChooseClass(id);
 }
 


this opens the menu on round start if he hasnt picked a class
PHP Code:

public plugin_init()
{
 
register_logevent("Round_start"2"1=Round_Start")
}
public 
Round_start() 
{
 new 
i
 
for (i=0i<33i++) 
 {
 
  if(
is_user_connected(i) && PlayerClass[i] == 0)
  {
   
ChooseClass(i);
  }
 }


shuld i clean up the code?

>)SL(< | Wicked 01-30-2008 14:26

Re: US Military Mod
 
m... no not yet. Ill change that to.

Whats your steam account name, so i can add u as a friend?

fxfighter 01-30-2008 14:29

Re: US Military Mod
 
steam = links_return
msn = fxfighter9

>)SL(< | Wicked 01-30-2008 14:36

Re: US Military Mod
 
Are u not on?

Im almost on all the time so yeah....

>)SL(< | Wicked 01-30-2008 19:56

Re: US Military Mod
 
1 Attachment(s)
Hey, fighter, could you look over my code as it is rite now. I got 3 errors and idk what they are. also, i added a 2d array for the classes. soo yeah thank you so much.

Edit:
nvm i got 8 errors DX
Quote:

/home/groups/amxmodx/tmp3/phpVLaEB8.sma(14) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/tmp3/phpVLaEB8.sma(21) : error 010: invalid function or declaration
/home/groups/amxmodx/tmp3/phpVLaEB8.sma(75) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpVLaEB8.sma(75) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpVLaEB8.sma(75) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpVLaEB8.sma(75) : fatal error 107: too many error messages on one line

Compilation aborted.
6 Errors.
Im uploading the new .sma


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

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