AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help me pls with this plugin (compile error) (https://forums.alliedmods.net/showthread.php?t=82475)

cs1.7 12-23-2008 23:15

help me pls with this plugin (compile error)
 
this plugin gives #1 ranked player:

votemapmenu
votekickmenu
votebanmenu
amx_slapmenu



all these menus can be used only every 30 minutes or 60 minutes to prevent overuse/ abuse.

please take a look at the code and see what's wrong there. right now the compile error is:

Code:

//// top1_admin.sma
// C:\Program Files\Valve\HLServer\cstrike\addons\amxmodx\scripting\top1_admin.s
ma(99) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\HLServer\cstrike\addons\amxmodx\scripting\top1_admin.s
ma(99) : error 017: undefined symbol "i"
// C:\Program Files\Valve\HLServer\cstrike\addons\amxmodx\scripting\top1_admin.s
ma(99) : error 017: undefined symbol "j"
// C:\Program Files\Valve\HLServer\cstrike\addons\amxmodx\scripting\top1_admin.s
ma(99) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
// Could not locate output file C:\Program Files\Valve\HLServer\cstrike\addons\a
mxmodx\scripting\compiled\top1_admin.amx (compile failed).
//
// Compilation Time: 0,11 sec
// ----------------------------------------

Press enter to exit ...




the plugin:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>

#pragma semicolon 1

#define MAP 0
#define SLAP 1
#define KICK 2
#define BAN 3
    
#define MENU_SIZE    256
#define MENU_PLAYERS 7

new g_iMenuPosition;
new 
g_iMenuPlayers[32];
new 
g_iMenuOption[32];
new 
g_iMenuSettings[32];

new 
pcvars[4];

public 
plugin_init()
{
    
register_plugin("rank 1 limited admin""1.0""author");
    
    
register_clcmd("say ivotemap""cmdVoteMapMenu"ADMIN_ALL);
    
register_clcmd("say islap""cmdSlapMenu"ADMIN_ALL);
    
    
register_clcmd("say ikick","cmdVoteKickMenu",ADMIN_ALL,"- displays vote kick menu");
    
register_clcmd("say iban","cmdVoteBanMenu",ADMIN_ALL,"- displays vote ban menu");
    
    
register_menucmd(register_menuid("\rVoteKick Menu:"),1023,"VoteKickMenu");
    
register_menucmd(register_menuid("\rVoteBan Menu:"),1023,"VoteBanMenu");
    
    
pcvars[MAP] = register_cvar("amx_votemap_usage""60");
    
pcvars[SLAP] = register_cvar("amx_slap_usage""30");
    
pcvars[KICK] = register_cvar("amx_votekick_usage""60");
    
pcvars[BAN] = register_cvar("amx_voteban_usage""120");
}

public 
cmdVoteMapMenu(idaccessLevel)
{
    return 
get_user_flags(id) & accessLevel canUseCommand(idMAP) : PLUGIN_CONTINUE;
}

public 
cmdSlapMenu(idaccessLevel)
{
    return 
get_user_flags(id) & accessLevel canUseCommand(idSLAP) : PLUGIN_CONTINUE;
}


canUseCommand(idcommandIssued)
{
    static 
lastUseTime[33][4];
    
    new 
currentTime get_systime();
    new 
nextUse lastUseTime[id][commandIssued] - currentTime get_pcvar_num(pcvars[commandIssued]);
    
    if(
nextUse 0)
    {
        
client_print(idprint_chat"Error: You cannot use this command for another %d second%s.",
            
nextUsenextUse "s" "");
            
        return 
PLUGIN_HANDLED;
    }
    
    new 
osef[8];
    if(
get_user_stats(idosefosef) > 1)
    {
    
client_print(id print_chat "**Server: This MENU is only for top1 player! (ADMIN!)");
    return 
PLUGIN_HANDLED;
    }  
    
    
lastUseTime[id][commandIssued] = currentTime;
    
    return 
PLUGIN_CONTINUE;
}


/*   ------------  Vote KICK Menu  -------------------  */

public cmdVoteKickMenuidlvlcid )
{
    if( 
cmd_accessidlvlcid) )
    {
        
g_iMenuOption[id] = 0;
        
g_iMenuSettings[id] = 0;

        
showVoteKickMenuidg_iMenuPosition );
    }
    return 
get_user_flags(id) & lvl canUseCommand(idKICK) : PLUGIN_CONTINUE;
}

public 
showVoteKickMenuidpos )
{
    if( 
pos ) return

    new 
ij
    
new szMenuBody[MENU_SIZE]
    new 
iCurrKey 0
    
new szUserName[32]
    new 
iStart pos MENU_PLAYERS
    
new iNum

    get_players
g_iMenuPlayersiNum )

    if( 
iStart >= iNum )
        
iStart pos g_iMenuPosition 0

    
new iLen formatszMenuBodyMENU_SIZE-1"\rVote Kick Menu:\R%d/%d^n\w^n"pos+1, (iNum MENU_PLAYERS + ((iNum MENU_PLAYERS) ? )) )
    new 
iEnd iStart MENU_PLAYERS
    
new iKeys = (1<<9|1<<7)

    if( 
iEnd iNum )
        
iEnd iNum

    
for( iStartiEndi++ )
    {
        
g_iMenuPlayers[i]
        
get_user_namejszUserName31 )
        
        
//Check if the player has immunity
        
if( (get_user_flags(j) & ADMIN_IMMUNITY) )
        {
            
iCurrKey++
            
iLen += formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "\d%d. %s^n\w"iCurrKeyszUserName )
        }else
        {
            
iKeys |= (1<<iCurrKey++)
            
iLen += formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n"iCurrKeyszUserName )
        }
    }
    
//Check if it is kick or ban (DELETED!!)
        
iLen += formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "^n8. Vote Kick^n" )

    
//Cheack if there is more players left
    
if( iEnd != iNum )
    {
        
formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s"pos "Back" "Exit" )
        
iKeys |= (1<<8)
    }
    else
        
formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s"pos "Back" "Exit" )

    
show_menuidiKeysszMenuBody, -)

    return
}

public 
actionVoteKickMenuidkey )
{
    switch( 
key )
    {
        case 
7g_iMenuSettings[id] = 0    //kick
            
}     
            
showVoteKickMenuidg_iMenuPosition )
        }
        case 
8showVoteKickMenuid, ++g_iMenuPosition // More Option
        
case 9showVoteKickMenuid, --g_iMenuPosition // Back Option

        // Chose a Player
        
default:
        {
            new 
player g_iMenuPlayers[g_iMenuPosition MENU_PLAYERS key]

            
//Get user info

            
new authid[32]
            
get_user_authid(player,authid,31)

            new 
userid get_user_userid(player)

            
//Exec the command

            
if (equal("4294967295",authid)) { /* check if it is a lan */
                
new ipa[32]
                
get_user_ip(player,ipa,31,1)
                
server_cmd("addip 2.0 %s;writeip",ipa/* no need to vote on lan, or? */
            
}
            else {
                
server_cmd("amx_votekick #%d",userid)
                }
            }            
            
server_exec()
        }
    }
    return 
PLUGIN_HANDLED
}


/*   ------------  Vote BAN Menu  -------------------  */

/* Vote Menu */
public cmdVoteBanMenuidlvlcid )
{
    if( 
cmd_accessidlvlcid) )
    {
        
g_iMenuOption[id] = 0;
        
g_iMenuSettings[id] = 0;

        
showVoteBanMenuidg_iMenuPosition )
    }
    return 
get_user_flags(id) & lvl canUseCommand(idBAN) : PLUGIN_CONTINUE;
}

public 
showVoteBanMenuidpos )
{
    if( 
pos ) return

    new 
ij
    
new szMenuBody[MENU_SIZE]
    new 
iCurrKey 0
    
new szUserName[32]
    new 
iStart pos MENU_PLAYERS
    
new iNum

    get_players
g_iMenuPlayersiNum )

    if( 
iStart >= iNum )
        
iStart pos g_iMenuPosition 0

    
new iLen formatszMenuBodyMENU_SIZE-1"\rVote Ban Menu:\R%d/%d^n\w^n"pos+1, (iNum MENU_PLAYERS + ((iNum MENU_PLAYERS) ? )) )
    new 
iEnd iStart MENU_PLAYERS
    
new iKeys = (1<<9|1<<7)

    if( 
iEnd iNum )
        
iEnd iNum

    
for( iStartiEndi++ )
    {
        
g_iMenuPlayers[i]
        
get_user_namejszUserName31 )
        
        
//Check if the player has immunity
        
if( (get_user_flags(j) & ADMIN_IMMUNITY) )
        {
            
iCurrKey++
            
iLen += formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "\d%d. %s^n\w"iCurrKeyszUserName )
        }else
        {
            
iKeys |= (1<<iCurrKey++)
            
iLen += formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n"iCurrKeyszUserName )
        }
    }
    
//Check if it is kick or ban (DELETED!!)
        
iLen += formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "^n8. Vote Ban^n" )

    
//Cheack if there is more players left
    
if( iEnd != iNum )
    {
        
formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s"pos "Back" "Exit" )
        
iKeys |= (1<<8)
    }
    else
        
formatszMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s"pos "Back" "Exit" )

    
show_menuidiKeysszMenuBody, -)

    return
}

public 
actionVoteMenuidkey )
{
    switch( 
key )
    {
        case 
7g_iMenuSettings[id] = 1    //ban
            
}     
            
showVoteBanMenuidg_iMenuPosition )
        }
        case 
8showVoteBanMenuid, ++g_iMenuPosition // More Option
        
case 9showVoteBanMenuid, --g_iMenuPosition // Back Option

        // Chose a Player
        
default:
        {
            new 
player g_iMenuPlayers[g_iMenuPosition MENU_PLAYERS key]

            
//Get user info

            
new authid[32]
            
get_user_authid(player,authid,31)

            new 
userid get_user_userid(player)

            
//Exec the command

            
if (equal("4294967295",authid)) { /* check if it is a lan */
                
new ipa[32]
                
get_user_ip(player,ipa,31,1)
                
server_cmd("addip 0.0 %s;writeip",ipa/* no need to vote on lan, or? */
            
}
            else {
            
server_cmd("amx_voteban #%d kick;writeid",userid)
                }
            }            
            
server_exec()
        }
    }
    return 
PLUGIN_HANDLED



Exolent[jNr] 12-24-2008 01:28

Re: how correctly add "rank check" in this code?
 
PHP Code:

#include <amxmodx>
#include <csx>

#pragma semicolon 1

#define MAP 0
#define SLAP 1
#define SLAY 2
#define KICK 3
#define BAN 4

new pcvars[5];

public 
plugin_init()
{
    
register_plugin("Command Limits""1.0""Lee");
    
    
register_clcmd("amx_votemap""cmdVoteMapMenu"ADMIN_ALL);
    
register_clcmd("amx_slap""cmdSlap"ADMIN_ALL);
    
register_clcmd("amx_slay""cmdSlay"ADMIN_ALL);
    
register_clcmd("amx_votekickmenu""cmdVoteKickMenu"ADMIN_ALL);
    
register_clcmd("amx_votebanmenu""cmdVoteBanMenu"ADMIN_ALL);
    
    
pcvars[MAP] = register_cvar("amx_votemap_usage""60");
    
pcvars[SLAP] = register_cvar("amx_slap_usage""15");
    
pcvars[SLAY] = register_cvar("amx_slay_usage""30");
    
pcvars[KICK] = register_cvar("amx_votekick_usage""60");
    
pcvars[BAN] = register_cvar("amx_voteban_usage""120");
}

public 
cmdVoteMapMenu(playerIDaccessLevel)
{
    return 
canUseCommand(playerIDaccessLevelMAP);
}

public 
cmdSlap(playerIDaccessLevel)
{
    return 
canUseCommand(playerIDaccessLevelSLAP);
}

public 
cmdSlay(playerIDaccessLevel)
{
    return 
canUseCommand(playerIDaccessLevelSLAY);
}

public 
cmdVoteKickMenu(playerIDaccessLevel)
{
    return 
canUseCommand(playerIDaccessLevelKICK);
}

public 
cmdVoteBanMenu(playerIDaccessLevel)
{
    return 
canUseCommand(playerIDaccessLevelBAN);
}

canUseCommand(playerIDaccessLevelcommandIssued)
{
    static 
lastUseTime[33][4], trash[8];
    
    if( !
access(playerIDaccessLevel) && get_user_stats(playerIDtrashtrash) != )
    {
        
console_print(playerID"Error: Only #1 ranked players can use this command!");
        return 
PLUGIN_HANDLED;
    }
    
    new 
currentTime get_systime();
    new 
nextUse lastUseTime[playerID][commandIssued] - currentTime get_pcvar_num(pcvars[commandIssued]);
    
    if(
nextUse 0)
    {
        
console_print(playerID"Error: You cannot use this command for another %d second%s.",
            
nextUsenextUse "s" "");
            
        return 
PLUGIN_HANDLED;
    }
    
    
lastUseTime[playerID][commandIssued] = currentTime;
    
    return 
PLUGIN_CONTINUE;


EDIT:

lol, you edit your post while I'm posting how to fix it.

cs1.7 12-24-2008 01:35

Re: help me pls with this plugin (compile error)
 
+karma.:)

take a look at the code pls. it's pretty simple but i have some errors in it.

anakin_cstrike 12-24-2008 17:50

Re: help me pls with this plugin (compile error)
 
Put ; at the end of every line or statement.

Exolent[jNr] 12-24-2008 23:26

Re: help me pls with this plugin (compile error)
 
Or, remove "#pragma semicolon 1" at the top.


All times are GMT -4. The time now is 09:04.

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