Raised This Month: $ Target: $400
 0% 

Compile Error ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 07-09-2014 , 04:58   Compile Error ?
Reply With Quote #1

Please someone correct it, i tried many time to correct but still compile error :\

Code:
#include <amxmodx>
#include <hamsandwich>

enum _:gMenu
{
    NAME[32],
    ACTION[32]
};

new const gMenu_cmds[] [gMenu] = {
    { "Buy Menu", "say /buy" }

};

public plugin_init(){
    register_plugin("","1.0","");    
    RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)    
    register_clcmd("say /menu","cmd_menu");
}


public cmd_menu(client){
    new m = menu_create("Your Menu :-","mHandler");

    for (new i; i < sizeof gMenu_cmds; i++)
        menu_additem(m,gMenu_cmds[i][NAME]);

    menu_display(client,m);
}

public mHandler(client,m,item)
{
    if( item == MENU_EXIT )
    {
        menu_destroy(m)        
        return PLUGIN_HANDLED;
    }
    else
    {
        client_cmd(client,"%s",gMenu_cmds[item][ACTION]);
        cmd_menu(client);
    }
    
    public fwHamPlayerSpawnPost(iPlayer) {
        if (is_user_alive(iPlayer)) 
        {
               engclient_cmd(iPlayer, "say /menu")  
        }
    return PLUGIN_HANDLED;
Awesome_man is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-09-2014 , 05:00   Re: Compile Error ?
Reply With Quote #2

You are missing some brackets, you indentation shows you where
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 07-09-2014 , 07:04   Re: Compile Error ?
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
You are missing some brackets, you indentation shows you where
I don't know much about amxx scripting.. If i know dat where the error, then why would i posting ?

Please help

Last edited by Awesome_man; 07-09-2014 at 07:04.
Awesome_man is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-09-2014 , 07:37   Re: Compile Error ?
Reply With Quote #4

Posting into scripting help requires a minimum knowledge of programming. In your case, you don't even know how to handle block-brackets right, so I'd say you should first get some basic skills.
mottzi is offline
Send a message via MSN to mottzi
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-09-2014 , 08:32   Re: Compile Error ?
Reply With Quote #5

You mistakes are obvious.....
PHP Code:
#include <amxmodx>
#include <hamsandwich>

enum _:gMenu
{
    
NAME[32],
    
ACTION[32]
};

new const 
gMenu_cmds[] [gMenu] = {
    { 
"Buy Menu""say /buy" }

};

public 
plugin_init(){
    
register_plugin("","1.0","");    
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)    
    
register_clcmd("say /menu","cmd_menu");
}


public 
cmd_menu(client){
    
    new 
menu_create("Your Menu :-","mHandler");

    for (new 
isizeof gMenu_cmdsi++)
    
menu_additem(m,gMenu_cmds[i][NAME]);
    
    
menu_display(client,m);
}

public 
mHandler(client,m,item)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(m)        
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_cmd(client,"%s",gMenu_cmds[item][ACTION]);
        
cmd_menu(client);
    }
}

public 
fwHamPlayerSpawnPost(iPlayer) {
    if (
is_user_alive(iPlayer)) 
    {
        
engclient_cmd(iPlayer"say /menu")  
        
        return 
PLUGIN_HANDLED;
        
    }
    

HamletEagle is offline
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 07-10-2014 , 09:06   Re: Compile Error ?
Reply With Quote #6

Thanks guyz,

But whats wrong with the code, It's not applying /menu command automatically on clients when they spawn ?

Can someone help please ?
Awesome_man is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-10-2014 , 10:40   Re: Compile Error ?
Reply With Quote #7

Quote:
Originally Posted by Awesome_man View Post
Thanks guyz,

But whats wrong with the code, It's not applying /menu command automatically on clients when they spawn ?

Can someone help please ?
Please stick to one thread for one topic: https://forums.alliedmods.net/showthread.php?t=243130
__________________
fysiks is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-10-2014 , 09:34   Re: Compile Error ?
Reply With Quote #8

You should do some debuging to find and solve problems on your own. This might cause the problem though I'm not that sure:

engclient_cmd(iPlayer, "say /menu")

>

cmd_menu(iPlayer)

Last edited by mottzi; 07-10-2014 at 09:35.
mottzi is offline
Send a message via MSN to mottzi
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 07-10-2014 , 18:57   Re: Compile Error ?
Reply With Quote #9

I do not understand why we have to do a check if the player lives that you are using spawn, he still comes back to life.
Take a check:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include < amxmodx >
#include < hamsandwich >

enum _:gMenu
{
    
NAME[32],
    
ACTION[32]
};

new const 
gMenu_cmds[] [gMenu] = {
    { 
"Buy Menu""say /buy" }

};

public 
plugin_init(){
    
register_plugin("","1.0","");    
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)    
    
register_clcmd("say /menu","cmd_menu");
}


public 
cmd_menu(client){
    
    new 
menu_create("Your Menu :-","mHandler");

    for (new 
isizeof gMenu_cmdsi++)
    
menu_additem(m,gMenu_cmds[i][NAME]);
    
    
menu_display(client,m);
}

public 
mHandler(client,m,item)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(m)        
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_cmd(client,"%s",gMenu_cmds[item][ACTION]);
        
cmd_menu(client);
    }

    return 
PLUGIN_HANDLED;
}

public 
fwHamPlayerSpawnPost(iPlayer)
{
    
cmd_menuiPlayer )

Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
wickedd
Veteran Member
Join Date: Nov 2009
Old 07-10-2014 , 19:12   Re: Compile Error ?
Reply With Quote #10

Quote:
Originally Posted by Fuck For Fun View Post
I do not understand why we have to do a check if the player lives that you are using spawn, he still comes back to life.
Because spawn is called once when a player joins the server. So the code you posted will have errors.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Reply


Thread Tools
Display Modes

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 21:09.


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