AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Misstake in the code (https://forums.alliedmods.net/showthread.php?t=173783)

KamiN 12-10-2011 12:42

Misstake in the code
 
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])
        {


fysiks 12-10-2011 19:43

Re: Misstake in the code
 
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.

KamiN 12-11-2011 04:59

Re: Misstake in the code
 
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 12-11-2011 05:13

Re: Misstake in the code
 
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.


All times are GMT -4. The time now is 11:47.

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