AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Last round? (https://forums.alliedmods.net/showthread.php?t=185145)

Bilal Pro 05-13-2012 08:44

Last round?
 
Hey there,

How will i find out what round is the last round?

Bilal Pro 05-13-2012 08:56

Re: Last round?
 
Would this work for example:
PHP Code:

test get_timeleft()

if (
test <= 60)
{
    
client_print(0print_center"This is the last minute of the map!")



Devil259 05-13-2012 09:02

Re: Last round?
 
Test by yourself.

Bilal Pro 05-13-2012 09:18

Re: Last round?
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Mapbuild Vote"
#define VERSION "1.0"
#define AUTHOR "Bilal"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
set_task(1.0"CheckTimeleft"_,_,_"b")
}

public 
CheckTimeleft(id)
{
    new 
test get_timeleft()
    
    if (
test <= 60)
    {
        
CmdMenu(id)
    }
    return 
PLUGIN_CONTINUE
}

public 
CmdMenu(id)
{
    new 
menu menu_create("\yRate this map:""Menuhandler")
    
    
menu_additem(menu"Excellent""1")
    
menu_additem(menu"Good""2")
    
menu_additem(menu"Regular""3")
    
menu_additem(menu"Terrible""4")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
Menuhandler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], name[64], accescallback
    menu_item_getinfo
(menuitem ,accesdatacharsmax(data), namecharsmax(name), callback)
    new 
key str_to_num(data)
    
    switch (
key)
    {
        case 
1client_print(idprint_center"Thank you for your vote!")
            case 
2client_print(idprint_center"Thank you for your vote!")
            case 
3client_print(idprint_center"Thank you for your vote!")
            case 
4client_print(idprint_center"Thank you for your vote!")
        }
    return 
PLUGIN_HANDLED


Server is crashing when theres 1 minute left

<VeCo> 05-13-2012 09:23

Re: Last round?
 
Check that at round start.

Also, you can use this: http://forums.alliedmods.net/showthread.php?p=758905

Bilal Pro 05-13-2012 09:31

Re: Last round?
 
Still crashing
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Mapbuild Vote"
#define VERSION "1.0"
#define AUTHOR "Bilal"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("RoundStart"2"1=Round_Start")
}

public 
RoundStart()
{
    
set_task(1.0"CheckTimeleft"_,_,_"b")
}

public 
CheckTimeleft(id)
{
    new 
test get_timeleft()
    
    if (
test <= 60)
    {
        
CmdMenu(id)
    }
    return 
PLUGIN_CONTINUE
}

public 
CmdMenu(id)
{
    new 
menu menu_create("\yRate this map:""Menuhandler")
    
    
menu_additem(menu"Excellent""1")
    
menu_additem(menu"Good""2")
    
menu_additem(menu"Regular""3")
    
menu_additem(menu"Terrible""4")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
Menuhandler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], name[64], accescallback
    menu_item_getinfo
(menuitem ,accesdatacharsmax(data), namecharsmax(name), callback)
    new 
key str_to_num(data)
    
    switch (
key)
    {
        case 
1client_print(idprint_center"Thank you for your vote!")
            case 
2client_print(idprint_center"Thank you for your vote!")
            case 
3client_print(idprint_center"Thank you for your vote!")
            case 
4client_print(idprint_center"Thank you for your vote!")
        }
    return 
PLUGIN_HANDLED


Crash message: MSG_ONE or MSG_ONEUNRELIABLE with no target entity

<VeCo> 05-13-2012 09:32

Re: Last round?
 
You don't need a task. Use a loop to show the menu to all players.

Bilal Pro 05-13-2012 09:35

Re: Last round?
 
Now i've tryed this.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Mapbuild Vote"
#define VERSION "1.0"
#define AUTHOR "Bilal"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
set_task(1.0"CheckTimeleft"_,_,_"b")
}

public 
CheckTimeleft()
{
    new 
players[32], iNum
    get_players
(playersiNum"ch")
    new 
test get_timeleft()
    
    for (new 
i<iNumi++)
    {
        if (
test <= 60)
        {
            
CmdMenu(players[i])
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
CmdMenu(id)
{
    new 
menu menu_create("\yRate this map:""Menuhandler")
    
    
menu_additem(menu"Excellent""1")
    
menu_additem(menu"Good""2")
    
menu_additem(menu"Regular""3")
    
menu_additem(menu"Terrible""4")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
Menuhandler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], name[64], accescallback
    menu_item_getinfo
(menuitem ,accesdatacharsmax(data), namecharsmax(name), callback)
    new 
key str_to_num(data)
    
    switch (
key)
    {
        case 
1client_print(idprint_center"Thank you for your vote!")
            case 
2client_print(idprint_center"Thank you for your vote!")
            case 
3client_print(idprint_center"Thank you for your vote!")
            case 
4client_print(idprint_center"Thank you for your vote!")
        }
    return 
PLUGIN_HANDLED


Doesn't show the menu, but the crash is fixed

EDIT: solved

Napoleon_be 05-13-2012 10:07

Re: Last round?
 
Instead of printing every message at your cases, delete the switch and just print it once instead of 4 times.

Bilal Pro 05-13-2012 10:56

Re: Last round?
 
Thanks


All times are GMT -4. The time now is 00:19.

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