Raised This Month: $ Target: $400
 0% 

cvars are bitches


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zombiezzz
Veteran Member
Join Date: Nov 2009
Location: Nov 2009
Old 12-22-2009 , 12:18   cvars are bitches
Reply With Quote #1

hola i need help with my ScoutzKnivez Mod. Im trying to add cvars for the cost of an item in my shop. but idk where i but it and when i try to do it it messes up and its jsut to confusing.

PHP Code:
/*-----------------ScoutzKnivez-------------
/By Zombiezz! :D
/
/------------------Cvars--------------------
/sk_class_cost- Chanegs the vost for players to change class [its set on $1000]
/sv_gravity- Changes the ammount of gravity for everyone on the server 
/
/------------------Chain Log----------------
/Chain Log:
/v0.1 Release
/v0.2 fixed some code
/v0.3 Fixed stlye of code and added a cvar
/v0.4 lazerev fixed code and added money for classes.
/v0.5 i added a shop. 
/v0.6 added new cvar and grenadepack
/v0.7 fixed some code.
/v0.8 added Health to shop
/v0.9 Fixed some code from help
/v1.0 Fixed code somewhere ._.
/v1.1 Fixed classes enum thigny thanks to someone i forgot the name o well ty. 
/v1.2 Added deagle to shop
/
/------------------Have Fun!----------------
*/
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich> 
 
#define PLUGIN "Scoutz Knivez"
#define AUTHOR "Zombiezzz"
#define VERSION "1.2"
enum
{
    
CLASS_NOTHING 0,
    
CLASS_SCOUT_BIG,
    
CLASS_SCOUT_SPEED,
    
CLASS_SCOUT_GRAVITY,
    
CLASS_SCOUT_GRENADE,
    
CLASS_SCOUT_ELITE,
    
MAXCLASSES
}  
new 
PlayerClass[33]
new 
g_pClassMoney;
new const 
CLASSES[MAXCLASSES] [] = {
    
"None",
    
"Scout Big",
    
"Scout Runner",
    
"Scout Gravity",
    
"Scout Grenade",
    
"Scout Elite"
}
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
 
    
RegisterHamHam_Spawn"player""Select_Class"
    
    
g_pClassMoney register_cvar("sk_class_cost""1000")
    
register_cvar("sv_gravity""800")
 
    
register_clcmd("say /class""Change_Class")
    
register_clcmd("say_team /class""Change_Class")
    
register_clcmd("say /skme""ShowInfo")
    
register_clcmd("say_team /skme""ShowInfo")
    
register_clcmd("say /shop""ShopMenu")
    
register_clcmd("say_team /shop""ShopeMenu")
    
    
register_event("CurWeapon""CheckSpeed""be");
}
public 
Change_Class(id)
{
    new 
money get_pcvar_num(g_pClassMoney);
    if( (
PlayerClass[id] == CLASS_NOTHING) || ( cs_get_user_moneyid ) < money ) ) {
        
client_print(idprint_chat"[Scoutz Knivez] You can't change your class right now!")
        return 
PLUGIN_HANDLED;
    }
    else 
    {
        
cs_set_user_moneyidcs_get_user_moneyid ) - money )
        
PlayerClass[id] = CLASS_NOTHING
        client_print
(idprint_chat"[Scoutz Knivez] You can choose your class at next round!")
    }
    return 
PLUGIN_HANDLED;
}
public 
CheckSpeed(id
{
 if(
PlayerClass[id] == CLASS_SCOUT_SPEED)
         
set_user_maxspeed(id400.0);
}
public 
ShowInfo(id

    new 
name[33]
    
get_user_name(idname32)
    
    
set_hudmessage(025500.45, -0.1007.020.0)
    
show_hudmessage(id"Name: %s^nClass: %s^nKills: %i",name,CLASSES[PlayerClass[id]],get_user_frags(id))
}  
 
public 
Class_Handle(id menu item

    if(
item == MENU_EXIT
    { 
        
menu_destroy(menu); 
        return 
PLUGIN_HANDLED
    } 
    new 
szCommand[6] , szName[64]; 
    new 
access callback
    
menu_item_getinfo(menu item access szCommand szName 63 callback); 
    new 
num str_to_num(szCommand
  
    if( 
PlayerClass[id] == num 
    { 
        
client_print(id,print_chat,"[Scoutz Knivez] You are alredy a %s",CLASSES[num]) 
    } 
    else 
    {
        switch( 
num 
        { 
            case 
1
            { 
                
give_sk_items(id);
                
set_user_health(id250)
            } 
            case 
2
            { 
                
give_sk_items(id);
                
set_user_health(id70)
                
cs_set_user_bpammo(idCSW_SCOUT60)
            } 
            case 
3
            { 
                
give_sk_items(id);
                
set_user_gravity(id0.2)
                
cs_set_user_bpammo(idCSW_SCOUT60)
            } 
            case 
4:
            {
                
give_sk_items(id);
                
give_item(id"weapon_hegrenade")
                
set_user_gravity(id0.4)
                
set_user_health(id50)
                
cs_set_user_bpammo(idCSW_HEGRENADE3)
            }
            case 
5
            { 
                
give_sk_items(id);
                
set_user_health(id140)
                
set_user_armor(id100)
                
set_user_gravity(id0.5)
                
cs_set_user_bpammo(idCSW_SCOUT90)
            } 
        }
        
PlayerClass[id] = num 
        client_print
(id,print_chat,"[Scoutz Knivez] You are now %s",CLASSES[num]) 
    } 
    
menu_destroy(menu); 
    return 
PLUGIN_CONTINUE 
}  
public 
Select_Class(id)  
{
    if(
is_user_alive(id)) {
        
give_sk_items(id)
        if (
PlayerClass[id] == CLASS_SCOUT_BIG)
        {
            
set_user_health(id250)
        }
        if (
PlayerClass[id] == CLASS_SCOUT_SPEED)
        {
            
set_user_health(id70)
            
cs_set_user_bpammo(idCSW_SCOUT60)
        }
        if (
PlayerClass[id] == CLASS_SCOUT_GRAVITY)
        {
            
set_user_gravity(id0.2)
            
cs_set_user_bpammo(idCSW_SCOUT60)
        }
        if (
PlayerClass[id] == CLASS_SCOUT_GRENADE)
        {
            
give_item(id"weapon_hegrenade")
            
set_user_gravity(id0.4)
            
set_user_health(id50)
            
cs_set_user_bpammo(idCSW_HEGRENADE3)
        }
        if (
PlayerClass[id] == CLASS_SCOUT_ELITE)
        {
            
set_user_health(id140)
            
set_user_armor(id100)
            
set_user_gravity(id0.5)
            
cs_set_user_bpammo(idCSW_SCOUT90)
        }
        if (
PlayerClass[id] == CLASS_NOTHING)
        {
            new 
menu menu_create("Select your class" "Class_Handle");
            
menu_additem(menu ,"Scout Big""1" 0); 
            
menu_additem(menu ,"Scout Runner""2" 0); 
            
menu_additem(menu ,"Scout Gravity""3" 0); 
            
menu_additem(menu ,"Scout Grenade""4" 0);
            
menu_additem(menu ,"Scout Elite""5" 0);
        
            
menu_setprop(menu MPROP_EXIT MEXIT_ALL);
    
            
menu_display(id menu 0); 
            return 
PLUGIN_CONTINUE
        }    
    }
    return 
PLUGIN_HANDLED;
}
stock give_sk_items(id)
{
    
strip_user_weapons(id);
    
give_item(id"weapon_scout");
    
give_item(id"weapon_knife");
    
cs_set_user_bpammo(idCSW_SCOUT20);

public 
ShopMenu(id)

    new 
menu menu_create("Shop:""menu_handler"); 
     
    
menu_additem(menu"100 Armor: $1000""1"0); 
    
menu_additem(menu"Lower Gravity: $2000""2"0); 
    
menu_additem(menu"Grenade Pack: $5000""3"0);
    
menu_additem(menu"More HP: $6000""4"0);
    
menu_additem(menu"Deagle: $14000""5"0);
     
    
menu_setprop(menuMPROP_EXITMEXIT_ALL); 
    
menu_display(idmenu0); 

public 
menu_handler(idmenuitem

    if( 
item == MENU_EXIT 
    { 
        
menu_destroy(menu); 
        return 
PLUGIN_HANDLED
    } 
    new 
data[6], iName[64]; 
    new 
accesscallback
     
    
menu_item_getinfo(menuitemaccessdata,5iName63callback); 
    new 
key str_to_num(data); 
    new 
money cs_get_user_money(id
    switch(
key
    { 
        case 
1
        { 
            if(
money>=1000
            { 
                
cs_set_user_money(idmoney 1000); 
                 
                if( 
is_user_aliveid ) )  
                    
cs_set_user_armor(id100CS_ARMOR_VESTHELM)  
                 
                
client_print(idprint_chat"[Scoutz Knviez] You bought 100 armor for $1000"); 
            } 
             
        } 
        case 
2
        { 
            if(
money>=2000)
       {
           
cs_set_user_money(idmoney 2000);
                    
                if( 
is_user_aliveid ) )  
                    
set_user_gravity(id0.3)
                
           
client_print(idprint_chat"[Scoutz Knviez] You bought low gravity for $2000"); 
       }
         
        }
        case 
3:
        {
            if(
money>=5000
       {
           
cs_set_user_money(idmoney 5000);
                    
                if( 
is_user_aliveid ) )  
                  
give_item(id"weapon_flashbang")
                  
give_item(id"weapon_smokegrenade")
                  
give_item(id"weapon_hegrenade")
                
           
client_print(idprint_chat"[Scoutz Knviez] You bought Grenade Pack for $5000"); 
          }
         } 
    case 
4:
    {
        if(
money>=6000)
        {
             
cs_set_user_money(idmoney -6000);
            
        if( 
is_user_aliveid ) )
        
set_user_health(id225)
        
          
client_print(idprint_chat"[Scoutz Knviez] You bought more HP for $6000"); 
          }
         }
    case 
5:
    {
     if(
money>=14000)
 {
      
cs_set_user_money(idmoney -14000);
      
 if( 
is_user_aliveid ) )
    
give_item(id"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE45);
 
    
client_print(idprint_chat"[Scoutz Knivez] You bought a deagle for $14000");
   }
  }
    }
    
menu_destroy(menu); 
    return 
PLUGIN_HANDLED

__________________
Zombiezzz is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-22-2009 , 12:27   Re: cvars are bitches
Reply With Quote #2

I'm not sure to understand, what is exactly your problem? Right now, you don't explain clearly.
__________________
Arkshine is offline
Zombiezzz
Veteran Member
Join Date: Nov 2009
Location: Nov 2009
Old 12-22-2009 , 12:29   Re: cvars are bitches
Reply With Quote #3

i want to add cvars for cost of items right meow
PHP Code:
public menu_handler(idmenuitem

    if( 
item == MENU_EXIT 
    { 
        
menu_destroy(menu); 
        return 
PLUGIN_HANDLED
    } 
    new 
data[6], iName[64]; 
    new 
accesscallback
 
    
menu_item_getinfo(menuitemaccessdata,5iName63callback); 
    new 
key str_to_num(data); 
    new 
money cs_get_user_money(id
    switch(
key
    { 
        case 
1
        { 
            if(
money>=1000
            { 
                
cs_set_user_money(idmoney 1000); 
 
                if( 
is_user_aliveid ) )  
                    
cs_set_user_armor(id100CS_ARMOR_VESTHELM)  
 
                
client_print(idprint_chat"[Scoutz Knviez] You bought 100 armor for $1000"); 
            } 
that code elts players buy armor for $1000. I want to put a cvar tehre so that the person can jsut easly edit the cost of an item.
__________________
Zombiezzz is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-22-2009 , 12:32   Re: cvars are bitches
Reply With Quote #4

You know how to add a cvar, so again, what's your problem exactly?
__________________
Arkshine is offline
Zombiezzz
Veteran Member
Join Date: Nov 2009
Location: Nov 2009
Old 12-22-2009 , 12:34   Re: cvars are bitches
Reply With Quote #5

:[

i know hwo to add cvars yes but i dont know why it isnt working. i made a cvar for the cost of an item but it dosnt work. and im not sure where i place teh cvar in my code so it works.
__________________
Zombiezzz is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-22-2009 , 12:37   Re: cvars are bitches
Reply With Quote #6

You ask why it is not working without the code related to your problem...
__________________
Arkshine is offline
Zombiezzz
Veteran Member
Join Date: Nov 2009
Location: Nov 2009
Old 12-22-2009 , 12:40   Re: cvars are bitches
Reply With Quote #7

ok here you go arkshine. heres my code.
PHP Code:
public menu_handler(idmenuitem

    if( 
item == MENU_EXIT 
    { 
        
menu_destroy(menu); 
        return 
PLUGIN_HANDLED
    } 
    new 
data[6], iName[64]; 
    new 
accesscallback
     
    
menu_item_getinfo(menuitemaccessdata,5iName63callback); 
    new 
key str_to_num(data); 
    new 
money cs_get_user_money(id
    switch(
key
    { 
        case 
1
        { 
            if(
money>=get_pcvar_num(armor_cost);
            { 
                
cs_set_user_money(idmoney 1000); 
                 
                if( 
is_user_aliveid ) )  
                    
cs_set_user_armor(id100CS_ARMOR_VESTHELM)  
                 
                
client_print(idprint_chat"[Scoutz Knviez] You bought 100 armor for $1000"); 
            } 
             
        } 
__________________

Last edited by Zombiezzz; 12-22-2009 at 12:56.
Zombiezzz is offline
laziboi72
Senior Member
Join Date: Aug 2009
Location: deathrun_temple
Old 12-22-2009 , 13:02   Re: cvars are bitches
Reply With Quote #8

PHP Code:
if(money>=get_pcvar_num(armor_cost);
            { 
                
cs_set_user_money(idmoney get_pcvar_num(CVAR_COST));
                 
                if( 
is_user_aliveid ) )  
                    
cs_set_user_armor(id100CS_ARMOR_VESTHELM)  
                 
                
client_print(idprint_chat"[Scoutz Knviez] You bought 100 armor for $%i"get_pcvar_num(CVAR_COST)); 
            } 
you need to use get_pcvar_num("cvarcost") and replace your hard coded numbers
__________________
Taking a break from modding dunno when i will be back

FAIL, RIGHT HERE

Last edited by laziboi72; 12-22-2009 at 13:04.
laziboi72 is offline
Zombiezzz
Veteran Member
Join Date: Nov 2009
Location: Nov 2009
Old 12-22-2009 , 13:04   Re: cvars are bitches
Reply With Quote #9

nice +karam
__________________
Zombiezzz is offline
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 12-22-2009 , 13:04   Re: cvars are bitches
Reply With Quote #10

nvm. sorry
platzpatrone is offline
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 04:10.


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