Raised This Month: $ Target: $400
 0% 

Call Of Duty Mod


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JaGareN
Senior Member
Join Date: Mar 2009
Old 06-28-2010 , 22:21   Re: Call Of Duty Mod
Reply With Quote #1

You dont have "TAB" space after and before the "{" and "}".
Also are you using notepad?
JaGareN is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 06-28-2010 , 22:24   Re: Call Of Duty Mod
Reply With Quote #2

Quote:
Originally Posted by JaGareN View Post
You dont have "TAB" space after and before the "{" and "}".
Also are you using notepad?
He isn't talking about how he is spacing and tabbing it. He means he spaced teh functions out.
__________________
Hi.
Kreation is offline
JaGareN
Senior Member
Join Date: Mar 2009
Old 06-28-2010 , 22:27   Re: Call Of Duty Mod
Reply With Quote #3

Quote:
Originally Posted by Kreation View Post
He isn't talking about how he is spacing and tabbing it. He means he spaced teh functions out.
I have understand that but to make only spaces between the functions will not make the code clearly.
JaGareN is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 06-28-2010 , 22:29   Re: Call Of Duty Mod
Reply With Quote #4

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
JaGareN
Senior Member
Join Date: Mar 2009
Old 06-28-2010 , 22:34   Re: Call Of Duty Mod
Reply With Quote #5

Yes that is much better..
JaGareN is offline
linkosc
Senior Member
Join Date: Apr 2007
Location: Everywhere
Old 06-29-2010 , 00:03   Re: Call Of Duty Mod
Reply With Quote #6

ok I got you so I would have to set a bool var like
PHP Code:
new bool:n_ChangeClass[33]
 
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!")
 
n_ChangeClass[id] = false
 

then like :
if(n_ChangeClass[id] == false) {
set_task(

I dont know Im confusing my self
__________________
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by linkosc; 06-29-2010 at 00:13. Reason: Duh feeling stupid lol
linkosc is offline
Send a message via AIM to linkosc
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-29-2010 , 00:19   Re: Call Of Duty Mod
Reply With Quote #7

Quote:
Originally Posted by linkosc View Post
I dont want the player to be able to choose another class mid round because it will give him all new weapons and ammo. I need help so that he can choose another class but it wont change till next round. Cany anyone help me?
Do this:

PHP Code:
public DoChooseClass(idkey)
{
    
PlayerClass[id] = key+1

Also, in HamPlayerSpawnPost() only check if player is alive once and then use a switch for PlayerClass[id]'s.
__________________
fysiks is offline
linkosc
Senior Member
Join Date: Apr 2007
Location: Everywhere
Old 06-30-2010 , 05:24   Re: Call Of Duty Mod
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
Do this:

PHP Code:
public DoChooseClass(idkey)
{
    
PlayerClass[id] = key+1

Also, in HamPlayerSpawnPost() only check if player is alive once and then use a switch for PlayerClass[id]'s.

I tried adding that in. I recieved a few compiling errors. Im not sure what this would do anyway. I dont know what to do. Im looking throught the wc3ft Plugin to see if I can find how they do it but no luck so far.....
__________________
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
linkosc is offline
Send a message via AIM to linkosc
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-30-2010 , 16:19   Re: Call Of Duty Mod
Reply With Quote #9

Quote:
Originally Posted by linkosc View Post
I tried adding that in. I recieved a few compiling errors. Im not sure what this would do anyway. I dont know what to do. Im looking throught the wc3ft Plugin to see if I can find how they do it but no luck so far.....
Do you mean your tried editing your code to look like what I posted? You can't just add what I gave you. It will definitely cause errors.
__________________
fysiks is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 06-29-2010 , 09:09   Re: Call Of Duty Mod
Reply With Quote #10

PHP Code:
public HamPlayerSpawnPost(id) {
    
    if( !
is_user_aliveid ) ) return HAM_HANDLED
    
    
switch(PlayerClass[id])
    {
        case 
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");
        }
        case 
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");
        }
    
    ....

I'm working in a mod similar than this.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
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 14:53.


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