AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why this check doesnt work? (https://forums.alliedmods.net/showthread.php?t=215394)

danonix 05-07-2013 10:33

Why this check doesnt work?
 
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

Napoleon_be 05-07-2013 11:06

Re: Why this check doesnt work?
 
stats[0] --> stats[id]

danonix 05-07-2013 11:33

Re: Why this check doesnt work?
 
But if I will enter stats[id] it will read kills or deaths?

Napoleon_be 05-07-2013 12:11

Re: Why this check doesnt work?
 
I can't know that without having a look into your function where you count the stats[] variable.

danonix 05-07-2013 12:13

Re: Why this check doesnt work?
 
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)
        }



Napoleon_be 05-07-2013 12:21

Re: Why this check doesnt work?
 
You're not doing anything with that variable...

yan1255 05-07-2013 12:30

Re: Why this check doesnt work?
 
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...

danonix 05-07-2013 12:42

Re: Why this check doesnt work?
 
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; 
}


Napoleon_be 05-07-2013 12:49

Re: Why this check doesnt work?
 
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.

danonix 05-07-2013 13:14

Re: Why this check doesnt work?
 
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]);
    }



All times are GMT -4. The time now is 10:57.

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