AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   fix this plugin pls.. (https://forums.alliedmods.net/showthread.php?t=231559)

nikeboy648 12-16-2013 08:25

fix this plugin pls..
 
this is the errors:

Error: Symbol already defined: "get_datadir" on line 128
Warning: Symbol is never used: "HandleSay" on line 130

this is the plugin:

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define USE_COLORCHAT        ""

#define PLUGIN_TAG        "Song"
#define MAX_QUESTIONS        64

#if defined USE_COLORCHAT
#include <colorchat>
#endif

#pragma semicolon        1

new g_file[ MAX_QUESTIONS ];

new Questions[ 64 ][ MAX_QUESTIONS ];
new Answers[ 64 ][ MAX_QUESTIONS ];

new RandomAsked;

new bool:QuestionAsked;

public plugin_init( )
{
        new dir[ 64 ];
        get_datadir( dir, charsmax( dir ) );
       
        formatex( g_file, charsmax( g_file ), "%s/Song.ini", dir );
       
        register_clcmd( "say", "HandleSay" );
        register_clcmd( "say_team", "HandleSay" );
       
        QuestionAsked = false;
}

new endsound[ ][ ] =
{
"TxP/SongEvent1.mp3",
}



; HandleSay( client )
{
        new arg[ 10 ];
       
        read_argv( client, arg, charsmax( arg ) );
        client_cmd( 0, "mp3 play ^"sound/%s^"", endsound[ random( sizeof( endsound ) ) ] );
       
        if ( equali( arg, "/song" ) || equali( arg, "!song" ) )
        {
                if ( get_user_flags( client ) & ADMIN_ACCESS )
                {
                        if ( !QuestionAsked )
                        {
                                Trivia( client );
                        }
                        else
                        {
                                #if defined USE_COLORCHAT
                                        ColorChat( client, TEAM_COLOR, "^4[ %s ] The^4 Event^1 is already^4 Enabled.", PLUGIN_TAG );
                                #else
                                        client_print( client, print_chat, "The Event is already Enabled." );
                                #endif
                        }
                }
                else
                {
                        #if defined USE_COLORCHAT
                                ColorChat( client, TEAM_COLOR, "^4[ %s ] You dont have access to this^4 Command.", PLUGIN_TAG );
                        #else
                                client_print( client, print_chat, "You dont have access to this Command." );
                        #endif
                }
        }
        else if ( QuestionAsked )
        {
                if ( equali( arg, Answers[ RandomAsked ] ) )
                {
                        new NameSz[ 32 ];
                       
                        get_user_name( client, NameSz, charsmax( NameSz ) );
                       
                        #if defined USE_COLORCHAT
                                ColorChat( client, TEAM_COLOR, "^4[ %s ]^3 %s^1 Answered Correct:^4 ''%s''", PLUGIN_TAG, NameSz, arg );
                        #else
                                client_print( client, print_chat, "^4%s Answered Correct: ''%s''^3", NameSz, arg );
                        #endif
                       
                        QuestionAsked = false;
                       
                        return PLUGIN_HANDLED;
                }
        }
        return PLUGIN_CONTINUE;
}
               
public Trivia( client )
{       
        new file = fopen( g_file, "rt" );
        new data[ 128 ];
        new question[ MAX_QUESTIONS ];
        new answer[ MAX_QUESTIONS ];
       
        new i = 0;
       
        while ( !feof( file ) )
        {
                i++;
               
                fgets( file, data, charsmax( data ) );
                parse( data, question, 31, answer, 31 );
               
                formatex( Questions[ i ], charsmax( Questions ), question );
                formatex( Answers[ i ], charsmax( Answers ), answer );
               
                replace_all( Questions[ i ], charsmax( Questions ), "_", " " );
        }
       
        RandomAsked = random_num( 1, i );
        QuestionAsked = true;
}

stock get_datadir( name[ ],len )
{
        return get_localinfo( "amxx_datadir", name, len );
}

Fix it please!

YamiKaitou 12-16-2013 08:41

Re: fix this plugin pls..
 
Remove the semicolon in front of HandleSay(client)
Remove the get_datadir stock

nikeboy648 12-16-2013 09:30

Re: fix this plugin pls..
 
Quote:

Originally Posted by YamiKaitou (Post 2072684)
Remove the semicolon in front of HandleSay(client)
Remove the get_datadir stock

now I got this errors:

Error: Expected token: ";", but found "public" on line 44
Error: Undefined symbol "ADMIN_ACCESS" on line 53

CODE:

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define USE_COLORCHAT        ""

#define PLUGIN_TAG        "Song"
#define MAX_QUESTIONS        64

#if defined USE_COLORCHAT
#include <colorchat>
#endif

#pragma semicolon        1

new g_file[ MAX_QUESTIONS ];

new Questions[ 64 ][ MAX_QUESTIONS ];
new Answers[ 64 ][ MAX_QUESTIONS ];

new RandomAsked;

new bool:QuestionAsked;

public plugin_init( )
{
        new dir[ 64 ];
        get_datadir( dir, charsmax( dir ) );
       
        formatex( g_file, charsmax( g_file ), "%s/Song.ini", dir );
       
        register_clcmd( "say", "HandleSay" );
        register_clcmd( "say_team", "HandleSay" );
       
        QuestionAsked = false;
}

new endsound[ ][ ] =
{
"TxP/SongEvent1.mp3"
}

public HandleSay( client )
{
        new arg[ 10 ];
       
        read_argv( client, arg, charsmax( arg ) );
        client_cmd( 0, "mp3 play ^"sound/%s^"", endsound[ random( sizeof( endsound ) ) ] );
       
        if ( equali( arg, "/song" ) || equali( arg, "!song" ) )
        {
                if ( get_user_flags( client ) & ADMIN_ACCESS )
                {
                        if ( !QuestionAsked )
                        {
                                Trivia( client );
                        }
                        else
                        {
                                #if defined USE_COLORCHAT
                                        ColorChat( client, TEAM_COLOR, "^4[ %s ] The^4 Event^1 is already^4 Enabled.", PLUGIN_TAG );
                                #else
                                        client_print( client, print_chat, "The Event is already Enabled." );
                                #endif
                        }
                }
                else
                {
                        #if defined USE_COLORCHAT
                                ColorChat( client, TEAM_COLOR, "^4[ %s ] You dont have access to this^4 Command.", PLUGIN_TAG );
                        #else
                                client_print( client, print_chat, "You dont have access to this Command." );
                        #endif
                }
        }
        else if ( QuestionAsked )
        {
                if ( equali( arg, Answers[ RandomAsked ] ) )
                {
                        new NameSz[ 32 ];
                       
                        get_user_name( client, NameSz, charsmax( NameSz ) );
                       
                        #if defined USE_COLORCHAT
                                ColorChat( client, TEAM_COLOR, "^4[ %s ]^3 %s^1 Answered Correct:^4 ''%s''", PLUGIN_TAG, NameSz, arg );
                        #else
                                client_print( client, print_chat, "^4%s Answered Correct: ''%s''^3", NameSz, arg );
                        #endif
                       
                        QuestionAsked = false;
                       
                        return PLUGIN_HANDLED;
                }
        }
        return PLUGIN_CONTINUE;
}
               
public Trivia( client )
{       
        new file = fopen( g_file, "rt" );
        new data[ 128 ];
        new question[ MAX_QUESTIONS ];
        new answer[ MAX_QUESTIONS ];
       
        new i = 0;
       
        while ( !feof( file ) )
        {
                i++;
               
                fgets( file, data, charsmax( data ) );
                parse( data, question, 31, answer, 31 );
               
                formatex( Questions[ i ], charsmax( Questions ), question );
                formatex( Answers[ i ], charsmax( Answers ), answer );
               
                replace_all( Questions[ i ], charsmax( Questions ), "_", " " );
        }
       
        RandomAsked = random_num( 1, i );
        QuestionAsked = true;
}


Fuck For Fun 12-16-2013 18:44

Re: fix this plugin pls..
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define USE_COLORCHAT    ""

#define PLUGIN_TAG     "Song"
#define MAX_QUESTIONS    64

#if defined USE_COLORCHAT
#include <colorchat>
#endif

#pragma semicolon     1

new g_fileMAX_QUESTIONS ];

new 
Questions64 ][ MAX_QUESTIONS ];
new 
Answers64 ][ MAX_QUESTIONS ];

new 
RandomAsked;

new 
bool:QuestionAsked;

public 
plugin_init( )
{
    new 
dir64 ];
    
get_datadirdircharsmaxdir ) );
    
    
formatexg_filecharsmaxg_file ), "%s/Song.ini"dir );
    
    
register_clcmd"say""HandleSay" );
    
register_clcmd"say_team""HandleSay" );
    
    
QuestionAsked false;
}

new 
endsound[ ][ ] =
{
    
"TxP/SongEvent1.mp3"
};

public 
HandleSayclient )
{
    new 
arg10 ];
    
    
read_argvclientargcharsmaxarg ) );
    
client_cmd0"mp3 play ^"sound/%s^""endsoundrandomsizeofendsound ) ) ] );
    
    if ( 
equaliarg"/song" ) || equaliarg"!song" ) )
    {
        if ( 
get_user_flagsclient ) & ADMIN_KICK )
        {
            if ( !
QuestionAsked )
            {
                
Triviaclient );
            }
            else
            {
                
#if defined USE_COLORCHAT
                    
ColorChatclientTEAM_COLOR"^4[ %s ] The^4 Event^1 is already^4 Enabled."PLUGIN_TAG );
                
#else
                    
client_printclientprint_chat"The Event is already Enabled." );
                
#endif
            
}
        }
        else
        {
            
#if defined USE_COLORCHAT
                
ColorChatclientTEAM_COLOR"^4[ %s ] You dont have access to this^4 Command."PLUGIN_TAG );
            
#else
                
client_printclientprint_chat"You dont have access to this Command." );
            
#endif
        
}
    }
    else if ( 
QuestionAsked )
    {
        if ( 
equaliargAnswersRandomAsked ] ) )
        {
            new 
NameSz32 ];
            
            
get_user_nameclientNameSzcharsmaxNameSz ) );
            
            
#if defined USE_COLORCHAT
                
ColorChatclientTEAM_COLOR"^4[ %s ]^3 %s^1 Answered Correct:^4 ''%s''"PLUGIN_TAGNameSzarg );
            
#else
                
client_printclientprint_chat"^4%s Answered Correct: ''%s''^3"NameSzarg );
            
#endif
            
            
QuestionAsked false;
            
            return 
PLUGIN_HANDLED;
        }
    }
    
    return 
PLUGIN_CONTINUE;
}
        
public 
Triviaclient )
{    
    new 
file fopeng_file"rt" );
    new 
data128 ];
    new 
questionMAX_QUESTIONS ];
    new 
answerMAX_QUESTIONS ];
    
    new 
0;
    
    while ( !
feoffile ) )
    {
        
i++;
        
        
fgetsfiledatacharsmaxdata ) );
        
parsedataquestion31answer31 );
        
        
formatexQuestions], charsmaxQuestions ), question );
        
formatexAnswers], charsmaxAnswers ), answer );
        
        
replace_allQuestions], charsmaxQuestions ), "_"" " );
    }
    
    
RandomAsked random_num1);
    
QuestionAsked true;


If you want to change the admin access, so that here
PHP Code:

if ( get_user_flagsclient ) & ADMIN_KICK 



All times are GMT -4. The time now is 20:39.

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