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

Request: Help making the time right.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Apocalyman
Member
Join Date: Nov 2022
Old 09-29-2023 , 17:22   Request: Help making the time right.
Reply With Quote #1

Hello! I am trying to call this set_task function:
Code:
set_task(25.0,"StopFWServer",_,_,_,"b")
But even though "StopFWServer" is supposed to happen after 25 seconds, it always happens randomly and not at the wanted time which is 25 seconds even though 25 is written. Can anyone please let me know why? thanks

Last edited by Apocalyman; 09-29-2023 at 17:22.
Apocalyman is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 09-29-2023 , 17:59   Re: Request: Help making the time right.
Reply With Quote #2

Show the whole code. If the task is called in random times but it’s always less than 25 seconds is probably because you have created more than one task.
Posting the whole code would be the proper way to fix but you i can provide you a solution without seeing the code.
First create a task id like
#define TASK_ID 15849
Later check if the task id exists on that id
If it doesn’t exist, set the task under that id.

Btw, this should have been posted under scripting help since you are not asking for a plugin but a fix.
__________________
Jhob94 is offline
Apocalyman
Member
Join Date: Nov 2022
Old 09-29-2023 , 18:15   Re: Request: Help making the time right.
Reply With Quote #3

Quote:
Originally Posted by Jhob94 View Post
Show the whole code. If the task is called in random times but it’s always less than 25 seconds is probably because you have created more than one task.
Posting the whole code would be the proper way to fix but you i can provide you a solution without seeing the code.
First create a task id like
#define TASK_ID 15849
Later check if the task id exists on that id
If it doesn’t exist, set the task under that id.

Btw, this should have been posted under scripting help since you are not asking for a plugin but a fix.
My bad I didnt know. Here I will send the whole plugin to make it easier:
Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < hamsandwich >
#include < ColorChat > // amx 1.9.0 this include not support anymore
 
#define FW_ACCESS ADMIN_KICK
 
new CTRounds[33] = 0
 
new bool: FW_Started = false
new FWTime
new NumberSelected
 
public plugin_init()  
{
    register_clcmd("say","HandleSay")
    RegisterHam(Ham_Spawn,"player","PlayerRespawned", 1)
    set_task(10.0,"Ratio",_,_,_,"b")
}

public client_disconnect( id ) // if you running server with lastest amx version 1.9.0 change this line - client_disconnect -> 
{
	CTRounds[ id ] = 0;
}
 
public Ratio()
{
    new CTCounter, TCounter
    new players[32],pnum
    get_players(players,pnum)
    for(new i = 0;i<pnum;i++)
    {
        new cid = players[i]
        switch(cs_get_user_team(cid))
        {
            case CS_TEAM_T:
            {
                TCounter++
            }
            case CS_TEAM_CT:
            {
                CTCounter++
            }
        }
    }
     
     
    if(CTCounter == 0 && TCounter >= 2)
    {
        StartFWRatio()
    }
    else if(CTCounter == 1 && TCounter >= 7)
    {
        StartFWRatio()
    }
    else if(CTCounter == 2 && TCounter >= 16)
    {
        StartFWRatio()
    }
    else if(CTCounter == 3 && TCounter >= 21)
    {
        StartFWRatio()
    }
}

public PlayerRespawned(id)
{
    if(!is_user_alive(id))
    {
        return 1;
    }

    if(cs_get_user_team(id) == CS_TEAM_CT)
    {
        if(CTRounds[id] == 9)
        {
            cs_set_user_team(id,CS_TEAM_T)
            ExecuteHamB(Ham_CS_RoundRespawn, id)
            new szName[32];
            get_user_name(id,szName,31)
            ColorChat(0,TEAM_COLOR,"^4[ ^1Apoc ^4] ^3%s^1 his was^4 10 ^1rounds in CT.",szName)
            CTRounds[id] = 0
            StartFWRounds
             // Restart the round
        }
        else
        {    
            CTRounds[id]++
            ColorChat(id,TEAM_COLOR,"^4[ ^1Apoc ^4] ^1You have been CT [^4%d^1/10] Rounds!",CTRounds[id])
             
        }
    }
    else
    {
        CTRounds[id] = 0
    }
    return 0;
}

public HandleSay(id)
{
    new StrNumberSelected[22]
    num_to_str(NumberSelected, StrNumberSelected, 21)
    new szMessage[128], szArg1[38], szArg2[38];
    read_argv(1, szMessage, charsmax(szMessage));
    parse(szMessage, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2));
    
    if(equali(szArg1,"/fw") || equali(szArg1,"/first") || equali(szArg1,"!first") || equali(szArg1,"!fw"))
    {
        if(get_user_flags(id) & FW_ACCESS)
        {
            StartFW(id)
        }
    }
    else if(equali(szArg1,"/stopfw") || equali(szArg1,"!stopfw"))
    {
        if(get_user_flags(id) & FW_ACCESS)
        {
            StopFW(id)
        }
    }
    else if(equali(szArg1, StrNumberSelected))
    {
        if(FW_Started == true)
        {
            if(cs_get_user_team(id) == CS_TEAM_T)
            {
                FW_Started = false
                set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255))
                new szName[32]
                get_user_name(id, szName, 31)
                cs_set_user_team(id, CS_TEAM_CT); // Always switch to CT team
                ExecuteHamB(Ham_CS_RoundRespawn, id)
                show_hudmessage(0,"%s has won the first write!",szName)
                ColorChat(0, TEAM_COLOR, "^4[ ^1Apoc ^4] ^3%s^4 Won ^1the ^4first writes^1!", szName)
                 // Restart the round
            }
            else
            {
                ColorChat(id, TEAM_COLOR, "^4[ ^1Apoc ^4] ^1You are a^4 Guard^1 already!")
            }
        }
    }
    else if(equali(szArg1,"/rounds"))
    {
        new player = cmd_target(id, szArg2, 0)
        if(!(player))
        {
            ColorChat(id, TEAM_COLOR, "^4[ ^1Apoc ^4] ^1There is no player named^3 %s^1", szArg2)
            return 1;
        }
        new szName[32]
        get_user_name(player, szName, 31)
        if(cs_get_user_team(player) != CS_TEAM_CT)
        {
            ColorChat(id, TEAM_COLOR, "^4[ ^1Apoc ^4] ^1The player^3 %s^1 is not in CT team!", szName)
            return 1;
        }
        ColorChat(id, TEAM_COLOR, "^4[ ^1Apoc ^4] ^1The player^3 %s^1 Left^4 Rounds ^1[^4%d^1/10]^4 rounds!", szName, CTRounds[player])
    }
    return 0;
}

public StartFW(id)
{
    if(!FW_Started)
    {
        FW_Started = true
        FWTime = 6
        set_task(1.0,"CheckTime",1992,_,_,"b")
        new szAdmin[32]
        get_user_name(id,szAdmin,31)
        ColorChat(0,TEAM_COLOR,"^4[ ^1Apoc ^4] ^1Admin^3 %s ^4started ^1the first writes",szAdmin)
        set_task(25.0, "StopFWServer", id, _, _, "b")
    }
    else
    {
        ColorChat(id,TEAM_COLOR,"^4[ ^1Apoc ^4] ^1First writes is already ^4activated!")
    }
    return 1;
}
public StartFWRatio()
{
    if(!FW_Started)
    {
        FW_Started = true
        FWTime = 6
        set_task(1.0,"CheckTime",1992,_,_,"b")
        ColorChat(0,TEAM_COLOR,"^4[ ^1Apoc ^4] ^1Auto^4 First Writes ^1started")
        set_task(25.0,"StopFWServer",_,_,_,"b")

    }
}
public StartFWRounds()
{
    if(!FW_Started)
    {
        FW_Started = true
        FWTime = 9
        set_task(1.0,"CheckTime",1992,_,_,"b")
    }
}
public StopFW(id)
{
    if(FW_Started)
    {
        FW_Started = false
         
        new szName[32]
        get_user_name(id,szName,31)
        ColorChat(0,TEAM_COLOR,"^4[ ^1Apoc ^4] ^1Admin ^3%s ^4stopped ^1first writes!",szName)
         
    }
}

public StopFWServer(id)
{
    if(FW_Started)
    {
        FW_Started = false
         
        new szName[32]
        get_user_name(id,szName,31)
        ColorChat(0,TEAM_COLOR,"^4[ ^1Apoc ^4] ^3The Server ^4stopped ^1the first writes!",szName)
         
    }
}
 
public CheckTime()
{
     
    if(FWTime > 1)
    {
        if(FW_Started)
        {
            FWTime--
            set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, 0.30, 0, 4.0, 4.0)
            show_hudmessage(0,"The first writes will start in %d seconds!",FWTime)
            new Num[10]
            num_to_word(FWTime,Num,9)
            client_cmd(0,"spk fvox/%s",Num)
        }
        else
        {
            remove_task(1992)
        }
    }
    else if(FWTime == 1)
    {
        FWTime--
        set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, 0.30, 0, 4.0, 4.0)
        NumberSelected = random_num(1,10000)
        new szText[100]
        formatex(szText,99,"The chosen number is: %d",NumberSelected)
        show_hudmessage(0,szText)
        ColorChat(0,TEAM_COLOR,"^4[ ^1Apoc ^4] ^1The ^4chosen ^1number is: ^4%d",NumberSelected)
        remove_task(1992)
    }
}

Last edited by Apocalyman; 09-29-2023 at 18:15.
Apocalyman is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-29-2023 , 22:31   Re: Request: Help making the time right.
Reply With Quote #4

You are setting a repeating task ("StopFWServer") inside of a repeating task ("Ratio"). This will inevitably create many repeating tasks calling the same function ("StopFWServer").

What is this plugin supposed to be doing?
__________________

Last edited by fysiks; 09-29-2023 at 22:33.
fysiks is offline
Apocalyman
Member
Join Date: Nov 2022
Old 09-30-2023 , 04:52   Re: Request: Help making the time right.
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
You are setting a repeating task ("StopFWServer") inside of a repeating task ("Ratio"). This will inevitably create many repeating tasks calling the same function ("StopFWServer").

What is this plugin supposed to be doing?
First writes. It gives the terrorists a random number (for jailbreak modes) and if they write it first they move to the CT team
Apocalyman is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 09-30-2023 , 07:20   Re: Request: Help making the time right.
Reply With Quote #6

Quote:
Originally Posted by Jhob94 View Post
First create a task id like
#define TASK_ID 15849
Later check if the task id exists on that id
If it doesn’t exist, set the task under that id.
I am mobile phone, try to do it yourself. If you can’t fix it i will help you later if i have time
__________________
Jhob94 is offline
Apocalyman
Member
Join Date: Nov 2022
Old 09-30-2023 , 07:39   Re: Request: Help making the time right.
Reply With Quote #7

Quote:
Originally Posted by Jhob94 View Post
I am mobile phone, try to do it yourself. If you can’t fix it i will help you later if i have time
Okay! I will try! thanks
Apocalyman is offline
Apocalyman
Member
Join Date: Nov 2022
Old 10-01-2023 , 10:19   Re: Request: Help making the time right.
Reply With Quote #8

Quote:
Originally Posted by Jhob94 View Post
I am mobile phone, try to do it yourself. If you can’t fix it i will help you later if i have time
Yeah sadly I am unable to do it
Apocalyman is offline
Apocalyman
Member
Join Date: Nov 2022
Old 10-03-2023 , 21:18   Re: Request: Help making the time right.
Reply With Quote #9

If anyone could help me with this it would be very appreciated as I am still confused on how to do it
Apocalyman 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 16:21.


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