This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Misstake in the code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KamiN
Senior Member
Join Date: Jun 2011
Old 12-10-2011 , 12:42   Misstake in the code
Reply With Quote #1

Sometimes (not all the time, i guess this "bug" pops up when in server are 14 - 16~ players) some of the players dont get things they must to (debends on the chosen day).
For e.g. they dont get guns on DAY_CTSHIELD, heres the code:

Code:
#define IsPlayer(%1) (1<=%1<=g_max_clients)

new g_max_clients

public plugin_init() {
    g_max_clients = get_maxplayers()
}

public do_specialday(id)
{
    new name[33]; get_user_name(id, name, charsmax(name))

    for(new i = 0; i < g_max_clients; i++)
    {
        switch(specialday[20])
        {

            case DAY_CTSHLD:
            {    
                if(IsPlayer(i) && is_user_alive(i))
                {
                    switch(cs_get_user_team(i))
                    {
                        case CS_TEAM_T:
                        {
                            strip_weapons(i)

                            give_item(i, "weapon_deagle")
                            give_item(i, "weapon_m4a1")
                            
                            cs_set_user_bpammo(i, CSW_DEAGLE, 9999)
                            cs_set_user_bpammo(i, CSW_M4A1, 9999)

                            if(!(pev(i, pev_flags) & FL_FROZEN))
                            {
                                client_print(i, print_center, "U'v been frozen for 6s!");
                                freeze = true
                                set_pev(i, pev_flags, (pev(i, pev_flags) | FL_FROZEN));
                                set_task(7.0, "unfreeze", TASK_unfreeze + id)
                            }
                        }
                        
                        case CS_TEAM_CT:
                        {
                            strip_weapons(i)
                            
                            give_item(i, "weapon_deagle")
                            give_item(i, "weapon_shield")
                            
                            cs_set_user_bpammo(i, CSW_DEAGLE, 35)

                
                        }
                    }
                }

                client_print(i, print_chat, "%s started CT SHIELD day", name)

                set_task(2.0, "specdaytxtprad", id, "", 0, "b", TASK_specd)
                set_task(6.0, "specdaytxtprad1", id)
                jail_open()
            }
        }
    }
}
Is there any misstake??

Im basicly talking about this part of code, becouse the rest of code i think is fine.

Code:
#define IsPlayer(%1) (1<=%1<=g_max_clients)

new g_max_clients

public plugin_init() {
    g_max_clients = get_maxplayers()
}

public do_specialday(id)
{
    new name[33]; get_user_name(id, name, charsmax(name))

    for(new i = 0; i < g_max_clients; i++)
    {
        switch(specialday[20])
        {

Last edited by KamiN; 12-10-2011 at 12:44.
KamiN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-10-2011 , 19:43   Re: Misstake in the code
Reply With Quote #2

According to the code you've given the function is never called. Also, there does not exist a case for DAY_CTSHIELD in that code.
__________________

Last edited by fysiks; 12-10-2011 at 19:43.
fysiks is offline
KamiN
Senior Member
Join Date: Jun 2011
Old 12-11-2011 , 04:59   Re: Misstake in the code
Reply With Quote #3

No no, theres everything fine, when u type /days there shows menu with days names and when u chose one of them then this function is called. And DAY_CTSHLD is registered.
KamiN is offline
KamiN
Senior Member
Join Date: Jun 2011
Old 12-11-2011 , 05:13   Re: Misstake in the code
Reply With Quote #4

Any way i hope now everything will be fine.

I'v deleted
Code:
IsPlayer
checking

and
Code:
for(new i = 0; i < g_max_clients; i++)
Edited to
Code:
for(new i = 1; i < g_max_clients; i++)
Maby now everything will be fine.

Last edited by KamiN; 12-11-2011 at 05:14.
KamiN 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 02:06.


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