Raised This Month: $ Target: $400
 0% 

Call Of Duty Mod


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 06-28-2010 , 22:29   Re: Call Of Duty Mod
Reply With Quote #13

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

/*#include "cod4/Menu.inl"*/

#define PLUGIN "COD4"
#define VERSION "1.0"
#define AUTHOR "<GT>LINK"

#define CLASS_NOTHING 0
#define CLASS_ASSUALT 1
#define CLASS_DEMO 4
#define CLASS_HEAVYG 3
#define CLASS_SNIPER 5
#define CLASS_SPECOPS 2
#define MAXCLASSES 6
#define MAXRANK 55

new PlayerRank[33]
new 
PlayerClass[33]
new 
PlayerXP[33]
new 
PlayerLevel[33]
new 
g_vault
new g_msgStatusIcon
new iPlayers[32]
new 
iNum

new const CLASSES[MAXCLASSES][] = {
    
"None",
    
"Assault",
    
"Spec Ops",
    
"Heavy Gunner",
    
"Demolitions",
    
"Sniper"
}

new const 
RANK[MAXRANK][] = {
    
"Private First Class",
    
"Private First Class I",
    
"Private First Class II"
    
"Lance Corporal"
    
"Lance Corporal I",
    
"Lance Corporal II"
    
"Corporal"
    
"Corporal I",
    
"Corporal II"
    
"Sargeant",
    
"Sargeant I"
    
"Sargeant II"
    
"Staff Sargeant"
    
"Staff Sargeant I"
    
"Straff Sargeant II",
    
"Gunnery Sargeant"
    
"Gunnery Sargeant I"
    
"Gunnery Sargeant II"
    
"Master Sargeant",
    
"Master Sargeant I",
    
"Master Sargeant II",
    
"Master Gunnery Sergeant"
    
"Master Gunnery Sergeant I"
    
"Master Gunnery Sergeant II",
    
"2nd Lieutenant",
    
"2nd Lieutenant I",
    
"2nd Lieutenant II"
    
"1st Lieutenant"
    
"1st Lieutenant I"
    
"1st Lieutenant II"
    
"Captain",
    
"Captain I"
    
"Captain II"
    
"Major"
    
"Major I"
    
"Major II",
    
"Lt. Colonel",
    
"Lt. Colonel I",
    
"Lt. Colonel II",
    
"Colonel",
    
"Colonel I"
    
"Colonel II"
    
"Brigadier General",
    
"Brigadier General I",
    
"Brigadier General II"
    
"Major General",
    
"Major General I"
    
"Major General II",
    
"Lieutenant General",
    
"Lieutenant General I",
    
"Lieutenant General II"
    
"General",
    
"General I"
    
"General II"
    
"Commander"
}

new 
msgtext

new const LEVELS[55] = {
    
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,
    
82920,
    
87170,
    
91540,
    
96030,
    
100640,
    
105370,
    
110220,
    
115190,
    
120280
}

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_cvar("sv_cod4""1")
    
    
register_event("DeathMsg""DeathMsg""a")
    
    
register_cvar("XP_per_kill""30"
    
register_cvar("XP_Bomb""15"
    
register_cvar("XP_BDefuse""15"
    
register_cvar("XP_Xplode""20"
    
register_cvar("Min_players_XP""1"
    
register_cvar("XP_HS""10"
    
register_cvar("SaveXP","1")
    
g_vault nvault_open("cod4")
    
    
register_menucmd(register_menuid("menu_ChooseClass"),1023,"DoChooseClass"); 
    
register_event("ResetHUD""ResetHud""b"
    
msgtext get_user_msgid("StatusText"
    
g_msgStatusIcon get_user_msgid("StatusIcon")
    
register_message(g_msgStatusIcon"msgStatusIcon")
    
RegisterHam(Ham_Spawn"player""HamPlayerSpawnPost"1)
    
register_clcmd("say /changeclass""ChooseClass")
    
register_clcmd("say_team /changeclass""ChooseClass")
    
register_clcmd("say /class""ShowClass")
    
register_clcmd("say /rank""ShowRank")
}
public 
HamPlayerSpawnPost(id) {
    if(
is_user_alive(id) && PlayerClass[id] == CLASS_ASSUALT) {
        
        
fm_strip_user_weapons(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_m4a1");
        
fm_give_item(id"ammo_556nato");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
    }
    
    if(
is_user_alive(id) && PlayerClass[id] == CLASS_SPECOPS) {
        
        
fm_strip_user_weapons(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_mp5navy");
        
fm_give_item(id"ammo_9mm");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
    }
    
    if(
is_user_alive(id) && PlayerClass[id] == CLASS_HEAVYG) {
        
        
fm_strip_user_weapons(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_m249");
        
fm_give_item(id"ammo_556natobox");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
    }
    
    if(
is_user_alive(id) && PlayerClass[id] == CLASS_DEMO) {
        
        
fm_strip_user_weapons(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_m3");
        
fm_give_item(id"ammo_buckshot");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
    }
    
    if(
is_user_alive(id) && PlayerClass[id] == CLASS_SNIPER) {
        
        
fm_strip_user_weapons(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_scout");
        
fm_give_item(id"ammo_762nato");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
    }
    
}

public 
msgStatusIcon(msgidmsgdestid) {
    
    static 
szIcon[8];
    
get_msg_arg_string(2szIcon7);
    
    if(
equal(szIcon"buyzone") && get_msg_arg_int(1)) {
        
        
set_pdata_int(id235get_pdata_int(id235) & ~(1<<0));
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

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#%i#",PlayerXP[id],PlayerLevel[id],PlayerRank[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-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)
    
    
PlayerXP[id] = str_to_num(playerxp)
    
PlayerLevel[id] = str_to_num(playerlevel)
    
PlayerRank[id] = str_to_num(playerrank)
    
    return 
PLUGIN_CONTINUE
}

public 
client_connect(id) {
    
    if(
get_cvar_num("SaveXP") == 1) {
        
        
        
LoadData(id)
        
client_print(idprint_chat"[Call of Duty 4] XP Loaded!")
        
client_print(idprint_chat"[Call of Duty 4] You are a %s with level %s and %s XP"PlayerClass[id], PlayerLevel[id], PlayerXP[id], PlayerRank[id])
    }
    
}

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

public 
ResetHud(id) {
    
    if(
PlayerClass[id] == CLASS_NOTHING) {
        
        
        
ChooseClass(id)
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_HANDLED
}

public 
DeathMsg() {
    
    if(
get_cvar_num("sv_cod4") == 0) {
        
        return 
PLUGIN_HANDLED
    
}
    
    if(
get_playersnum() < get_cvar_num("Min_players_XP")) {
        
        return 
0;
    }
    new 
attacker read_data(1)
    new 
headshot read_data(3)
    
    if(
PlayerClass[attacker] == CLASS_NOTHING) {
        return 
PLUGIN_HANDLED
    
}
    if(
PlayerLevel[attacker] == 50) {
        return 
PLUGIN_HANDLED
    
}
    
    
PlayerXP[attacker] += get_cvar_num("XP_per_kill")
    if(
headshot)
        
PlayerXP[attacker] += get_cvar_num("XP_HS")
    if(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {
        
PlayerLevel[attacker] += 1
        client_print
(attackerprint_chat"[Call of Duty 4] Congratulations! You are now level %i!"PlayerLevel[attacker])
        if(
get_cvar_num("SaveXP") == 1) {
            
SaveData(attacker)
        }
        
        
ShowHUD(attacker)
    }
    
    
ShowHUD(attacker)
    return 
PLUGIN_CONTINUE
}

public 
ShowHUD(id) {
    
    new 
HUD[51]
    
format(HUD50"[%s]Level: %i XP: %i"RANK[PlayerClass[id]], PlayerLevel[id], PlayerXP[id], PlayerRank[id]) 
    
message_begin(MSG_ONEmsgtext, {0,0,0}, id
    
write_byte(0
    
write_string(HUD
    
message_end() 
    return 
PLUGIN_CONTINUE
}

public 
ShowClass(id) {
    
    new 
HUDS[61]
    
format(HUDS60"[%s]Level: %i XP: %i"CLASSES[PlayerClass[id]], PlayerLevel[id], PlayerXP[id], PlayerRank[id])
    
    
message_begin(MSG_ONEmsgtext, {0,0,0}, id)
    
write_byte(0)
    
write_string(HUDS)
    
message_end()
    return 
PLUGIN_CONTINUE
}

public 
ShowRank(id) {
    
    new 
HUDD[71]
    
format(HUDD70"[%s]Level: %i XP: %i"RANK[PlayerClass[id]], PlayerLevel[id], PlayerXP[id], PlayerRank[id])
    
    
message_begin(MSG_ONEmsgtext, {0,0,0}, id)
    
write_byte(0)
    
write_string(HUDD)
    
message_end()
    return 
PLUGIN_HANDLED
}

public 
ChooseClass(id) {
    
    new 
menu[] = "Call Of Duty 4: Choose Class^n^n1. Assault^n2. Spec Ops^n3. Heavy Gunner^n4. Demolitions^n5. Sniper";
    new 
keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    
show_menu(idkeysmenu, -1"menu_ChooseClass")    
    return 
PLUGIN_CONTINUE
}

public 
DoChooseClass(idkey) {
    
    if(
key == 0) {
        
        
        if(
PlayerClass[id] == CLASS_ASSUALT) {
            
            
client_print(idprint_chat"[Call of Duty 4] You are allready a Assault! Choose something else!")
            
ChooseClass(id)           
            return 
PLUGIN_HANDLED
        
}
        
        
PlayerClass[id] = CLASS_ASSUALT
        fm_strip_user_weapons
(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_m4a1");
        
fm_give_item(id"ammo_556nato");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
client_print(idprint_chat"[Call of Duty 4] You are now Assault Class!")
    }
    
    
    if(
key == 3) {
        
        
        if(
PlayerClass[id] == CLASS_DEMO) {              
            
client_print(idprint_chat"[Call of Duty 4] You are allready Demolitions! Choose something else!")
            
ChooseClass(id)
            return 
PLUGIN_HANDLED
        
}
        
        
PlayerClass[id] = CLASS_DEMO
        fm_strip_user_weapons
(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_m3");
        
fm_give_item(id"ammo_buckshot");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
client_print(idprint_chat"[Call of Duty 4] You are now Demolitions!")
    }
    
    
    if(
key == 2) {
        if(
PlayerClass[id] == CLASS_HEAVYG) {
            
client_print(idprint_chat"[Call of Duty 4] You are allready a Heavy Gunner! Choose something else!")
            
ChooseClass(id)
            return 
PLUGIN_HANDLED
        
}
        
        
PlayerClass[id] = CLASS_HEAVYG
        fm_strip_user_weapons
(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_m249");
        
fm_give_item(id"ammo_556natobox");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
client_print(idprint_chat"[Call of Duty 4] You are now a Heavy Gunner!")
    }
    
    if(
key == 4) {
        if(
PlayerClass[id] == CLASS_SNIPER) {
            
client_print(idprint_chat"[Call of Duty 4] You are allready a Sniper! Choose something else!")
            
ChooseClass(id)
            return 
PLUGIN_HANDLED
        
}
        
        
PlayerClass[id] = CLASS_SNIPER
        fm_strip_user_weapons
(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_scout");
        
fm_give_item(id"ammo_762nato");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
client_print(idprint_chat"[Call of Duty 4] You are now a Sniper!")
    }
    
    if(
key == 1) {
        if(
PlayerClass[id] == CLASS_SPECOPS) {
            
client_print(idprint_chat"[Call of Duty 4] You are allready Spec Ops! Choose something else!")
            
ChooseClass(id)
            return 
PLUGIN_HANDLED
        
}
        
        
PlayerClass[id] = CLASS_SPECOPS
        fm_strip_user_weapons
(id);
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_mp5navy");
        
fm_give_item(id"ammo_9mm");
        
fm_give_item(id"weapon_glock18");
        
fm_give_item(id"ammo_9mm");
        
client_print(idprint_chat"[Call of Duty 4] You are now Spec Ops!")
    }
    
get_playersiPlayersiNum )
    new 
id
    
for( new 0iNumi++ ) {
        
id iPlayers[i]
        if( 
is_user_aliveid ) && cs_get_user_teamid ) == CS_TEAM_T ) {
            
give_itemid"weapon_c4" )
            break;
        }
    }
    if( 
is_user_aliveid ) && cs_get_weapon_idid ) == CSW_C4 ) {
        
cs_set_user_plant(id11)
    }

Clear enough for you?

EDIT: As for the problem, you could make a bool and set it true when they pick a class and then check if it equals false before it will allow them to switch, and on roundstart make it false.

Ex:
PHP Code:
new bool:canswitch[33];

//wherever they switch and get their guns
if(PlayerClass[id] == CLASS1)
{
    
give_item(id"weapon_awp");
    
// [...]
    
canswitch[id] = false;

Then where you do the class change check if the bool 'canswitch' equals true or something.
__________________
Hi.

Last edited by Kreation; 06-28-2010 at 22:35.
Kreation is offline
 



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 14:53.


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