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


Raised This Month: $ Target: $400
 0% 

expresison has no effect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
igorzeni
Junior Member
Join Date: May 2023
Old 05-11-2024 , 16:59   expresison has no effect
Reply With Quote #1

It's giving an error on line 20 and I can't compile

#include <amxmodx>

// Define os IDs de menus
enum {
MENU_DEMO_SELECTOR,
};

// Função para mostrar o menu de seleção de jogadores
public show_demo_selector_menu(id) {
new const menuTitle[] = "Selecione um jogador:";
new const menuPrompt[] = "Selecione o jogador que deseja gravar a demo:";
new playersMenuItems[32][32];
new numPlayers = 0;

// Adiciona os jogadores ao menu
new maxPlayers = get_maxplayers();
new i;
for (i = 1; i <= maxPlayers; i++) {
if (is_user_connected(i)) {
format(playersMenuItems[numPlayers], sizeof(playersMenuItems[numPlayers]), "%s", get_user_name(i));
numPlayers++;
}
}

// Mostra o menu
show_menu(id, MENU_DEMO_SELECTOR, menuTitle, menuPrompt, playersMenuItems, numPlayers);
}

// Função para tratar as seleções do menu
public client_menu_handler(id, menu, item) {
if (menu == MENU_DEMO_SELECTOR) {
new const playerName[32];
get_user_name(item + 1, playerName, sizeof(playerName));

// Solicita o nome da demo
client_print(id, print_chat, "Digite o nome da demo para o jogador %s:", playerName);
client_cmd(id, "amx_input %d "Nome da demo"", id);
}
}

// Função chamada quando o jogador insere o nome da demo
public client_cmd(id, cmd[]) {
new playerName[32];
new demoName[64];
new demoPath[128];

if (equal(cmd, "Nome da demo")) {
read_args(playerName, sizeof(playerName));
read_args(demoName, sizeof(demoName));

// Formata o caminho do arquivo de demo
format(demoPath, sizeof(demoPath), "demos/%s.dem", demoName);

// Grava a demo
client_cmd(id, "amx_record "%s"", demoPath);
client_print(id, print_chat, "Demo para o jogador %s está sendo gravada como "%s".", playerName, demoName);
}
}

// Função chamada quando o plugin é inicializado
public plugin_init() {
register_plugin("Demo Recorder", "1.0", "Author");
register_clcmd("say /recorddemo", "cmd_recorddemo");
}

// Comando de chat para abrir o menu de seleção de jogadores
public cmd_recorddemo(id) {
if (!is_user_admin(id)) {
client_print(id, print_chat, "Apenas administradores podem usar este comando.");
return PLUGIN_HANDLED;
}

show_demo_selector_menu(id);
return PLUGIN_HANDLED;
}
igorzeni is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-11-2024 , 17:18   Re: expresison has no effect
Reply With Quote #2

Quote:
Originally Posted by igorzeni View Post
It's giving an error on line 20 and I can't compile
}
Share the error and put your code between php tags please.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-11-2024 , 19:50   Re: expresison has no effect
Reply With Quote #3

You're using get_user_name() incorrectly. And you can use copy() instead of format/formatex if you are only copying, or just get the user name directly into the array.
PHP Code:
if (is_user_connected(i)) {
    
format(playersMenuItems[numPlayers], sizeof(playersMenuItems[numPlayers]), "%s"get_user_name(i));
    
numPlayers++;

->
PHP Code:
if (is_user_connected(i)) 
{
    
get_user_name(playersMenuItems[numPlayers++], charsmaxplayersMenuItems[] ) );

__________________

Last edited by Bugsy; 05-11-2024 at 20:15.
Bugsy is offline
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-11-2024 , 20:56   Re: expresison has no effect
Reply With Quote #4

Quote:
Originally Posted by igorzeni View Post
It's giving an error on line 20 and I can't compile
Here:

PHP Code:
#include <amxmodx>
#include <amxmisc>

new g_maxPlayersg_Target[33]

// Função chamada quando o plugin é inicializado
public plugin_init()
{
    
register_plugin("Demo Recorder""1.0""Author")
    
register_clcmd("say /recorddemo""show_demo_selector_menu")
    
register_clcmd("Nome da demo""demoNameCmd")

    
g_maxPlayers get_maxplayers()
}

public 
client_authorized(id)
{
    
g_Target[id] = 0
}

// Comando de chat para abrir o menu de seleção de jogadores
public show_demo_selector_menu(id)
{
    if(!
is_user_admin(id))
    {
        
client_print(idprint_chat"Apenas administradores podem usar este comando.")
        return 
PLUGIN_HANDLED
    
}

    new 
dMenu menu_create("Selecione o jogador que deseja gravar a demo:""demo_selector_menu_handle")

    new 
szName[32], szID[3], totalPlayers 0

    
// Adiciona os jogadores ao menu
    
for(new 1g_maxPlayersi++)
    {
        if(
is_user_connected(i) && != id)
        {
            
get_user_name(iszNamecharsmax(szName))
            
formatex(szIDcharsmax(szID), "%d"i)
            
menu_additem(dMenuszNameszID)
            
totalPlayers++
        }
    }

    
// Mostra o menu
    
if(totalPlayers)
    {
        
menu_display(iddMenu)
    }
    else
    {
        
client_print(idprint_chat"Nenhum jogador conectado")
    }

    return 
PLUGIN_HANDLED
}

// Função para tratar as seleções do menu
public demo_selector_menu_handle(iddMenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(dMenu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[3], iDataname[1], accesscallback
    menu_item_getinfo
(dMenuitemaccessdatacharsmax(data), namecharsmax(name), callback)
    
menu_destroy(dMenu)
    
iData str_to_num(data)

    if(!
is_user_connected(iData))
    {
        
client_print(idprint_chat"Jogador desconectado")
        return 
PLUGIN_HANDLED
    
}

    
g_Target[id] = iData

    
new playerName[33]
    
get_user_name(iDataplayerNamecharsmax(playerName))
    
client_print(idprint_chat"Digite o nome da demo para o jogador: %s"playerName)
    
client_cmd(id"messagemode ^"Nome da demo^"")

    return 
PLUGIN_HANDLED
}

// Função chamada quando o jogador insere o nome da demo
public demoNameCmd(id)
{
    if(!
is_user_admin(id))
    {
        
client_print(idprint_chat"Apenas administradores podem usar este comando.")
        return 
PLUGIN_HANDLED
    
}
    if(!
is_user_connected(g_Target[id]))
    {
        
g_Target[id] = 0
        client_print
(idprint_chat"Jogador desconectado")
        return 
PLUGIN_HANDLED
    
}

    new 
demoName[25]
    
read_argv(3demoNamecharsmax(demoName))

    if(!
demoName[0])
    {
        
g_Target[id] = 0
        client_print
(idprint_chat"Nome invalido")
        return 
PLUGIN_HANDLED
    
}

    new 
playerName[33]
    
get_user_name(g_Target[id], playerNamecharsmax(playerName))
    
client_print(idprint_chat"Demo para o jogador %s está sendo gravada como ^"%s.dem^""playerNamedemoName)
    
client_cmd(g_Target[id], "stop;record ^"%s^""demoName)

    
g_Target[id] = 0

    
return PLUGIN_HANDLED


Last edited by v120kaaimcfg; 05-11-2024 at 20:57.
v120kaaimcfg is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-11-2024 , 21:24   Re: expresison has no effect
Reply With Quote #5

Quote:
Originally Posted by v120kaaimcfg View Post
Here:

PHP Code:
#include <amxmodx>
#include <amxmisc>

new g_maxPlayersg_Target[33]

// Função chamada quando o plugin é inicializado
public plugin_init()
{
    
register_plugin("Demo Recorder""1.0""Author")
    
register_clcmd("say /recorddemo""show_demo_selector_menu")
    
register_clcmd("Nome da demo""demoNameCmd")

    
g_maxPlayers get_maxplayers()
}

public 
client_authorized(id)
{
    
g_Target[id] = 0
}

// Comando de chat para abrir o menu de seleção de jogadores
public show_demo_selector_menu(id)
{
    if(!
is_user_admin(id))
    {
        
client_print(idprint_chat"Apenas administradores podem usar este comando.")
        return 
PLUGIN_HANDLED
    
}

    new 
dMenu menu_create("Selecione o jogador que deseja gravar a demo:""demo_selector_menu_handle")

    new 
szName[32], szID[3], totalPlayers 0

    
// Adiciona os jogadores ao menu
    
for(new 1g_maxPlayersi++)
    {
        if(
is_user_connected(i) && != id)
        {
            
get_user_name(iszNamecharsmax(szName))
            
formatex(szIDcharsmax(szID), "%d"i)
            
menu_additem(dMenuszNameszID)
            
totalPlayers++
        }
    }

    
// Mostra o menu
    
if(totalPlayers)
    {
        
menu_display(iddMenu)
    }
    else
    {
        
client_print(idprint_chat"Nenhum jogador conectado")
    }

    return 
PLUGIN_HANDLED
}

// Função para tratar as seleções do menu
public demo_selector_menu_handle(iddMenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(dMenu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[3], iDataname[1], accesscallback
    menu_item_getinfo
(dMenuitemaccessdatacharsmax(data), namecharsmax(name), callback)
    
menu_destroy(dMenu)
    
iData str_to_num(data)

    if(!
is_user_connected(iData))
    {
        
client_print(idprint_chat"Jogador desconectado")
        return 
PLUGIN_HANDLED
    
}

    
g_Target[id] = iData

    
new playerName[33]
    
get_user_name(iDataplayerNamecharsmax(playerName))
    
client_print(idprint_chat"Digite o nome da demo para o jogador: %s"playerName)
    
client_cmd(id"messagemode ^"Nome da demo^"")

    return 
PLUGIN_HANDLED
}

// Função chamada quando o jogador insere o nome da demo
public demoNameCmd(id)
{
    if(!
is_user_admin(id))
    {
        
client_print(idprint_chat"Apenas administradores podem usar este comando.")
        return 
PLUGIN_HANDLED
    
}
    if(!
is_user_connected(g_Target[id]))
    {
        
g_Target[id] = 0
        client_print
(idprint_chat"Jogador desconectado")
        return 
PLUGIN_HANDLED
    
}

    new 
demoName[25]
    
read_argv(3demoNamecharsmax(demoName))

    if(!
demoName[0])
    {
        
g_Target[id] = 0
        client_print
(idprint_chat"Nome invalido")
        return 
PLUGIN_HANDLED
    
}

    new 
playerName[33]
    
get_user_name(g_Target[id], playerNamecharsmax(playerName))
    
client_print(idprint_chat"Demo para o jogador %s está sendo gravada como ^"%s.dem^""playerNamedemoName)
    
client_cmd(g_Target[id], "stop;record ^"%s^""demoName)

    
g_Target[id] = 0

    
return PLUGIN_HANDLED

Then why can i perfectly compile this code?

__________________

Last edited by Napoleon_be; 05-11-2024 at 21:26.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-11-2024 , 21:30   Re: expresison has no effect
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
Then why can i perfectly compile this code?

Maybe because I've written it and it's not AI generated like OP's code? What kind of question is this mate?
v120kaaimcfg is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-11-2024 , 21:32   Re: expresison has no effect
Reply With Quote #7

Quote:
Originally Posted by v120kaaimcfg View Post
Maybe because I've written it and it's not AI generated like OP's code? What kind of question is this mate?
I copy pasted your code into my IDE and compiled it without any problems, what is my problem here? I don't actually know.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-11-2024 , 21:40   Re: expresison has no effect
Reply With Quote #8

Quote:
Originally Posted by Napoleon_be View Post
I copy pasted your code into my IDE and compiled it without any problems, what is my problem here? I don't actually know.
nah u must be trippin no other explanation
v120kaaimcfg is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 05-12-2024 , 06:11   Re: expresison has no effect
Reply With Quote #9

  • Quote:
    Originally Posted by Exolent[jNr] View Post
    Code:
    for( new i = 1; i <= g_MaxPlayers; i++ )
  • Code:
    new playerName[33] new playerName[32]
__________________
mlibre is offline
igorzeni
Junior Member
Join Date: May 2023
Old 05-12-2024 , 08:52   Re: expresison has no effect
Reply With Quote #10

thanks for the help
igorzeni 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 09:19.


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