Raised This Month: $ Target: $400
 0% 

buy an m4


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 07-26-2008 , 04:36   buy an m4
Reply With Quote #1

This is my first plugin ever made without any help other than looking at other code. Im posting it for people to tell me what i did wrong, what i can do better,to critisize me, or use? probably another plugin out there like this but whatever. So here it is
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define PLUGIN "Buy_m4" #define VERSION "1.0" #define AUTHOR "{PHILMAGROIN}" new m4_cost public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd("say /m4", "buym4")     m4_cost = register_cvar("m4_price", "800") } public buym4(id) {     if(!is_user_alive(id))         return PLUGIN_HANDLED                 new money = cs_get_user_money(id);         new cost;                 cost = get_pcvar_num(m4_cost)                 if(money < cost)         {             client_print(id, print_chat,"[AMXX] You dont't have enough money for an m4.")         }         else {             cs_set_user_money(id, cs_get_user_money(id) - cost);             {                 client_print(id, print_chat,"[AMXX] Kill Em with your new m4.")                 give_item(id, "weapon_m4a1");             }         return 1;     } }
__________________
[B]

Last edited by {PHILMAGROIN}; 07-26-2008 at 04:38.
{PHILMAGROIN} is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-26-2008 , 05:21   Re: buy an m4
Reply With Quote #2

Code:
        new cost;                 cost = get_pcvar_num(m4_cost)

No need for more than 1 line

Code:
new cost = get_pcvar_num(m4_cost)
---------------------------------
Code:
cs_set_user_money(id, cs_get_user_money(id) - cost);
You already have the player's money stored in "money"
Code:
cs_set_user_money(id, money - cost);
---------------------------------
Code:
        else {             cs_set_user_money(id, money - cost);             {                 client_print(id, print_chat,"[AMXX] Kill Em with your new m4.")                 give_item(id, "weapon_m4a1");             }         return 1;
You messed up your brackets
Code:
        else {             cs_set_user_money(id, money - cost);             client_print(id, print_chat,"[AMXX] Kill Em with your new m4.")             give_item(id, "weapon_m4a1");         }     return 1;
----------------------------------
Final:
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define PLUGIN "Buy_m4" #define VERSION "1.0" #define AUTHOR "{PHILMAGROIN}" new m4_cost public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd("say /m4", "buym4")     m4_cost = register_cvar("m4_price", "800") } public buym4(id) {     if(!is_user_alive(id))         return PLUGIN_HANDLED         new money = cs_get_user_money(id);     new cost cost = get_pcvar_num(m4_cost)         if(money < cost)     {         client_print(id, print_chat,"[AMXX] You dont't have enough money for an m4.")     }     else {         cs_set_user_money(id, money - cost);         client_print(id, print_chat,"[AMXX] Kill Em with your new m4.")         give_item(id, "weapon_m4a1");     }     return PLUGIN_HANDLED; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 07-26-2008 , 06:10   Re: buy an m4
Reply With Quote #3

Thanks. i added ability to buy ammo with it.

Code:
// Description: This plugin is mainly for terrorists to be able to buy an m4. Cts can buy one as // well but its the same price as an m4 on the buy menu. // Commands: say /m4 or /m4ammo // Cvars: "m4_price" "m4_aprice" #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define PLUGIN "Buy_m4" #define VERSION "1.1" #define AUTHOR "{PHILMAGROIN}" new m4_cost, m4_ammo; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("say /m4", "buym4")     register_clcmd("say /m4ammo", "buym4ammo")     m4_cost = register_cvar("m4_price", "2500")     m4_ammo = register_cvar("m4_aprice", "3000") } public buym4(id) {     if(!is_user_alive(id))         return PLUGIN_HANDLED             new money = cs_get_user_money(id);     new cost = get_pcvar_num(m4_cost)             if(money < cost)     {         client_print(id, print_chat,"[AMXX] You don't have enough money for an m4.")     }     else {         cs_set_user_money(id, money - cost);         client_print(id, print_chat,"[AMXX] You just purchased an m4.")              give_item(id,"weapon_m4a1");     }     return PLUGIN_HANDLED } public buym4ammo(id) {     if(!is_user_alive(id))         return PLUGIN_HANDLED             new money = cs_get_user_money(id);     new cost = get_pcvar_num(m4_ammo)             if(money < cost)     {         client_print(id, print_chat,"[AMXX] You don't have enough money for an m4 with extra ammo.")     }     else {         cs_set_user_money(id, money - cost);         client_print(id, print_chat,"[AMXX] You just purchased an m4 with extra ammo.")         give_item(id, "weapon_m4a1");         give_item(id, "ammo_556nato");         give_item(id, "ammo_556nato");         give_item(id, "ammo_556nato");     }     return PLUGIN_HANDLED }
__________________
[B]

Last edited by {PHILMAGROIN}; 07-26-2008 at 11:58.
{PHILMAGROIN} is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-26-2008 , 06:14   Re: buy an m4
Reply With Quote #4

http://wiki.amxmodx.org/CS_Weapons_Information

To give ammo, you should give the actual ammo.
Quote:
22 weapon_m4a1 230 30 90 4 ammo_556nato 3100 60 m4a1
Code:
give_item(id, "ammo_556nato")
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 07-26-2008 , 06:19   Re: buy an m4
Reply With Quote #5

Thanks.
__________________
[B]
{PHILMAGROIN} is offline
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 07-26-2008 , 08:01   Re: buy an m4
Reply With Quote #6

you should use register_clcmd not register_concmd.
clcmd = you can type it in chat.
concmd = you gotta type it in console..
PvtSmithFSSF is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 07-26-2008 , 08:50   Re: buy an m4
Reply With Quote #7

concmd works aswell, its just that you can execute the cmd from a console
which is a bad idea
__________________
minimiller is offline
Send a message via MSN to minimiller
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 07-26-2008 , 09:38   Re: buy an m4
Reply With Quote #8

So you're saying concmd will also let you type it in chat and it still works?? Sorry if that sounded rude I meant it as a question because you're smarter hehe
PvtSmithFSSF is offline
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 07-26-2008 , 11:53   Re: buy an m4
Reply With Quote #9

ya i actually meant to fix this.
__________________
[B]
{PHILMAGROIN} is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 07-26-2008 , 12:04   Re: buy an m4
Reply With Quote #10

Lol no problem
Yea if you use concmd("say /m4") or clcmd("say /m4") they do the same thing
However the concmd can be executed from a console and the clcmd cannot
__________________
minimiller is offline
Send a message via MSN to minimiller
Reply


Thread Tools
Display Modes

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 05:38.


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