Raised This Month: $ Target: $400
 0% 

Problem with Variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MPKiller545
Junior Member
Join Date: Aug 2011
Old 05-02-2012 , 06:06   Problem with Variable
Reply With Quote #1

Hi There!

I have some troubles with my plugin. I wanted to that one variable will have other values for each players, for example:

Tne New Round Started, players from Team A have earned 1 point to spend for weapons. Player A from Team A want to buy a M4A1 for 1 point. When he buy it, the rest of the teeam cant buy that M4A1 because they have a massage that they dont have any points.

Code:

*Sorry for my English, Im from Poland*



***CODE***
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#define PLUGIN "New Plug-in"
#define VERSION "1.0"
#define AUTHOR "author"
new mBronie
new numer


public plugin_init()
{
register_plugin(PLUGINVERSIONAUTHOR)
RegisterHam(Ham_Spawn"player""menubronie"1);

}


public 
menubronie(id)
{

mBronie menu_create("Bronie""mh_bronie")
menu_additem(mBronie"M4A1""1"0)
menu_display(idmBronie0)
numer 0
}



public 
mh_bronie(idmenuitem) {

if(
numer >= 1)
{
set_hudmessage(02550, -1.00.1706.012.0)
show_hudmessage(id"Niestety, ale juz wykorzystales wszystkie punkty.")
return 
PLUGIN_HANDLED
}

switch(
item)
{
case 
0:
{
give_item(id,"weapon_m4a1")
give_item(id,"ammo_556nato")
give_item(id,"ammo_556nato")
give_item(id,"ammo_556nato")
numer numer 1

}

PL -> ENG
*Bronie - Weapons*
*numer - number*

Last edited by MPKiller545; 05-02-2012 at 06:14.
MPKiller545 is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-02-2012 , 07:30   Re: Problem with Variable
Reply With Quote #2

PHP Code:
new numer 


PHP Code:
new numer[33
PHP Code:
public menubronie(id


mBronie menu_create("Bronie""mh_bronie"
menu_additem(mBronie"M4A1""1"0
menu_display(idmBronie0
numer 



PHP Code:
public menubronie(id


mBronie menu_create("Bronie""mh_bronie"
menu_additem(mBronie"M4A1""1"0
menu_display(idmBronie0
numer[id] = 

PHP Code:
if(numer >= 1

set_hudmessage(02550, -1.00.1706.012.0
show_hudmessage(id"Niestety, ale juz wykorzystales wszystkie punkty."
return 
PLUGIN_HANDLED 



PHP Code:
if(numer[id] >= 1

set_hudmessage(02550, -1.00.1706.012.0
show_hudmessage(id"Niestety, ale juz wykorzystales wszystkie punkty."
return 
PLUGIN_HANDLED 


Last edited by EpicMonkey; 05-02-2012 at 07:33.
EpicMonkey is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 05-02-2012 , 07:55   Re: Problem with Variable
Reply With Quote #3

test and tell me

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fun>

#define PLUGIN "Menu+Points"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

enum _:WeaponData {
    
WPN_NAME[20],
    
WPN_REAL_NAME[20],
    
WPN_CONSTANT,
    
WPN_BPAMMO,
    
WPN_PRICE
}

new const 
Weapon_Buy[][WeaponData] = {
    { 
"M4A1""weapon_m4a1"CSW_M4A190},
    { 
"AK-47""weapon_ak47"CSW_AK4790}
}

new 
g_Points[33], CsTeams:g_Team_Wing_MenuCallback
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawnPost"1)
    
    
register_message(get_user_msgid("TextMsg"), "Message_TextMsg")
    
    
g_MenuCallback menu_makecallback("check_points")
}

public 
fw_PlayerSpawnPost(id) {
    if(!
is_user_alive(id))
        return
    
    if(
cs_get_user_team(id) == g_Team_Win)
        
g_Points[id]++
    
    
show_buy_menu(id)
    
}

public 
Message_TextMsg() {
    static 
message[32
    
get_msg_arg_string(2messagecharsmax(message)) 
    
    if(
equal(message"#Terrorists_Win")) 
        
g_Team_Win CS_TEAM_T
    
else if(equal(message"#CTs_Win")) 
        
g_Team_Win CS_TEAM_CT
        
}

public 
show_buy_menu(id) {
    
    static 
menuitext[64]; menu menu_create("Menu Buy Weapon""buy_menu")
    
menu_addtext(menu"By [R]ak Acme Inc."0)
    for(
0sizeof Weapon_Buyi++) {
        
formatex(textcharsmax(text), "Weapon: %s | Bpammo: %d | Price: %d"Weapon_Buy[i][WPN_NAME], Weapon_Buy[i][WPN_BPAMMO], Weapon_Buy[i][WPN_PRICE])
        
menu_additem(menutext, .callback g_MenuCallback)
    }
        
    
menu_display(idmenu)
}

public 
buy_menu(idmenukey) {
    if(
key == MENU_EXIT) {
        
menu_destroy(menu)
        return
    }
    
    
give_item(idWeapon_Buy[key][WPN_REAL_NAME])
    
cs_set_user_bpammo(idWeapon_Buy[key][WPN_CONSTANT], Weapon_Buy[key][WPN_BPAMMO])
    
g_Points[id] -= Weapon_Buy[key][WPN_PRICE]
    
    
menu_destroy(menu)
}

public 
check_points(idmenukey)
    return 
g_Points[id] < Weapon_Buy[key][WPN_PRICE] ? ITEM_DISABLED ITEM_ENABLED 
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 05-02-2012 at 07:56.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
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 07:41.


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