Raised This Month: $51 Target: $400
 12% 

Why this check doesnt work?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danonix
Senior Member
Join Date: Dec 2012
Old 05-07-2013 , 10:33   Why this check doesnt work?
Reply With Quote #1

Hello,

I have got a question, why this check doesn't work?

PHP Code:
    switch(item){
        case 
0:{
            if(
stats[0] < 50){
                
client_print(idprint_chat"You cant use this knife");
                return 
PLUGIN_HANDLED
            
}
            else 
SetKnife(id0
thanks
danonix is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-07-2013 , 11:06   Re: Why this check doesnt work?
Reply With Quote #2

stats[0] --> stats[id]
__________________

Last edited by Napoleon_be; 05-07-2013 at 11:06.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
danonix
Senior Member
Join Date: Dec 2012
Old 05-07-2013 , 11:33   Re: Why this check doesnt work?
Reply With Quote #3

But if I will enter stats[id] it will read kills or deaths?

Last edited by danonix; 05-07-2013 at 12:02.
danonix is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-07-2013 , 12:11   Re: Why this check doesnt work?
Reply With Quote #4

I can't know that without having a look into your function where you count the stats[] variable.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
danonix
Senior Member
Join Date: Dec 2012
Old 05-07-2013 , 12:13   Re: Why this check doesnt work?
Reply With Quote #5

It looks like this
PHP Code:
public cbMyMenu(idmenuitem){
    static 
stats[8]
    new 
prefix[10];
    
get_pcvar_string(g_cPrefixprefixcharsmax(prefix)); 
    if(!
is_user_alive(id)){
        
ColorChat(idGREEN"[%s]^x01 Nie mozesz zmienic noza bedac niezywym"prefix);
        return 
PLUGIN_HANDLED
    
}
    
    switch(
item){
        case 
0:{
            if(
stats[0] < 50){
                
client_print(idprint_chat"You cant use this knife");
                return 
PLUGIN_HANDLED
            
}
            else 
SetKnife(id0)
        }


Last edited by danonix; 05-07-2013 at 12:14.
danonix is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-07-2013 , 12:21   Re: Why this check doesnt work?
Reply With Quote #6

You're not doing anything with that variable...
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
yan1255
Senior Member
Join Date: Jul 2011
Old 05-07-2013 , 12:30   Re: Why this check doesnt work?
Reply With Quote #7

Maybe try to give a full code... and then we could help you...
from what I see as Napoleon_be said... You're not doing anything with the variable...
__________________
yan1255 is offline
danonix
Senior Member
Join Date: Dec 2012
Old 05-07-2013 , 12:42   Re: Why this check doesnt work?
Reply With Quote #8

There is no more code, I've been even trying with get_user_frags(id), but still same problem, it didnt help.
Code:
public cbMyMenu(id, menu, item){
    static stats[8]
    new prefix[10];
    if(!is_user_alive(id)){
        ColorChat(id, GREEN, "[%s]^x01 Nie mozesz zmienic noza bedac niezywym", prefix);
        return PLUGIN_HANDLED
    }
    get_pcvar_string(g_cPrefix, prefix, charsmax(prefix)); 
    
    switch(item){
        case 0:{
            if(stats[0] < 50){
                client_print(id, print_chat, "You cant use this knife");
                return PLUGIN_HANDLED
            }
            else SetKnife(id, 0)
        }
    }
    return PLUGIN_CONTINUE
}

public SetKnife(id , Knife) {
    knife_model[id] = Knife
    
    new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo) 
    if ( Weapon != CSW_KNIFE )
        return PLUGIN_HANDLED
    
    new vModel[56],pModel[56]
    
    switch(Knife)
    {
        case 0: {
            format(vModel,55,"models/v_knife.mdl")
            format(pModel,55,"models/p_knife.mdl")
        }        
    } 
    
    entity_set_string(id, EV_SZ_viewmodel, vModel)
    entity_set_string(id, EV_SZ_weaponmodel, pModel)
    
    return PLUGIN_HANDLED;  
}
danonix is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-07-2013 , 12:49   Re: Why this check doesnt work?
Reply With Quote #9

The problem is, you're not doing anything with the variable "stats[8]". You should declare it global & use it in Ham_Kill function or DeathMsg event to count the kills the player has.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
danonix
Senior Member
Join Date: Dec 2012
Old 05-07-2013 , 13:14   Re: Why this check doesnt work?
Reply With Quote #10

So could you explain me please, why in this case it works?
Code:
public rangi(id)
{
    static stats[8], body[8];
    get_user_stats(id, stats, body);
    
    if(stats[0] <= 50) {
        ranga_status[id] = "Ofiara";
        nastepna[id] = (50 - stats[0]);
    }
danonix 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 20:18.


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