AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Nvualt to Mysql (https://forums.alliedmods.net/showthread.php?t=20550)

joka69 11-11-2005 13:07

Nvualt to Mysql
 
Is it possible to make this use mysql insted ov nvualt :?: If so could someone help me a bit please :)
Code:
/* Amx Mod X Script   Chat Ban by $uicid3 --------------------------------  Functionality:     Used to ban people from chatting. You can ban for a number of minutes or permanently.  Uses nVault module so it is required. ---------------------------------  Commands:     amx_chatban - Ban a player from chatting for defined minutes or permanently.     amx_unchatban - Give a player thier chatting rights. ---------------------------------  Credits:     joka69 - Suggesting this. Im sure hes not the first but hes the one i made it for. ---------------------------------*/ #include <amxmodx> #include <amxmisc> #include <nvault> new VaultName; new bool:boolBanned[33] = false; new bool:boolBlock[33] = false; new bool:boolStop[33] = false; public plugin_init() {     register_plugin("Chat Ban","1.1","$uicid3");     register_concmd("amx_chatban" , "ChatBan" , ADMIN_KICK , "<nick , userid , #playerid> <minutes>|<0 for permanent>");     register_concmd("amx_unchatban" , "UnChatBan" , ADMIN_KICK ,  "<nick , userid , #playerid>");     register_cvar("amx_cban_prefix" , "*GaG*");     VaultName = nvault_open( "ChatBan" ); } public ChatBan(id , level , cid) {     if( !cmd_access(id , level , cid , 3) )         return PLUGIN_HANDLED     new szArg1[36] , szArg2[12], szName[36] , szAdmin[36];     new szAuth[36] , tID , tsVault , tsCurrent, szTime[26] , Float:RemoveTime;     read_argv(1 , szArg1 , 35);     read_argv(2 , szArg2 , 11);     tID = cmd_target( id , szArg1 , 10);     if(!tID)     return PLUGIN_HANDLED     get_user_authid( tID , szAuth , 35);     get_user_name( tID , szName , 35);     get_user_name( id , szAdmin , 35);     tsCurrent = get_systime(); //Get timestamp     tsVault = (tsCurrent + (str_to_num(szArg2) * 60) ); //Add the number of minutes supplied     if( !str_to_num(szArg2) )     {         nvault_set( VaultName , szAuth , "-1");         console_print(id , "[Chat Ban] Player '%s' has been permanently chat banned.",szName);         switch(get_cvar_num("amx_show_activity") )         {             case 1: client_print( 0 , print_chat , "[Chat Ban] %s has been banned from chatting permanently.", szName);             case 2: client_print( 0 , print_chat , "[Chat Ban] Admin has banned %s from chatting permanently.", szName);             default: client_print( 0 , print_chat , "[Chat Ban] Admin %s has banned %s from chatting permanently." , szAdmin, szName);         }         AddPrefix( tID );         return PLUGIN_HANDLED;     }     else     {         num_to_str( tsVault , szTime , 25);         nvault_set( VaultName , szAuth , szTime);         console_print(id , "[Chat Ban] Player '%s' has been chat banned for %s minutes.",szName, szArg2);         switch(get_cvar_num("amx_show_activity") )         {             case 1: client_print( 0 , print_chat , "[Chat Ban] %s has been banned from chatting for %s minutes.", szName , szArg2);             case 2: client_print( 0 , print_chat , "[Chat Ban] Admin has banned %s from chatting  for %s minutes.", szName , szArg2);             default: client_print( 0 , print_chat , "[Chat Ban] Admin %s has banned %s from chatting  for %s minutes." , szAdmin , szName , szArg2);         }     }     RemoveTime = float( tsVault - tsCurrent);     if( (tsVault - tsCurrent) < get_timeleft() )         set_task( RemoveTime , "RemoveBan", tID);     AddPrefix( tID );     return PLUGIN_HANDLED } public UnChatBan(id , level , cid) {     if( !cmd_access(id , level ,cid , 2) )         return PLUGIN_HANDLED;     new szAuth[46] , szTime[26] , tsVault;     new szArg[36] , tID , szName[36] , szAdmin[36];     read_argv(1 , szArg , 35);     tID = cmd_target(id , szArg , 10);     if( !tID)         return PLUGIN_HANDLED     get_user_authid(tID , szAuth , 35);     get_user_name(tID , szName , 35);     get_user_name( id , szAdmin , 35);     if( !nvault_lookup( VaultName , szAuth , szTime , 35 , tsVault) )     {         console_print( id , "[Chat Ban] '%s' is NOT currently chat banned.",szName);         return PLUGIN_HANDLED;     }     nvault_prune( VaultName , (tsVault - 1) , (tsVault + 1 ) ); //remove any entrys that were entered when this was(unique basically)     boolBanned[tID] = false;     RemovePrefix( tID );     switch(get_cvar_num("amx_show_activity") )     {         case 1: client_print( 0 , print_chat , "[Chat Ban] %s are no longer banned from chatting." , szName );         case 2: client_print( 0 , print_chat , "[Chat Ban] Admin has given %s chatting rights again." , szName );         default: client_print( 0 , print_chat , "[Chat Ban] Admin %s has given %s chatting rights again.", szAdmin , szName );     }     if(task_exists( tID , 0) )         remove_task( tID , 0);     return PLUGIN_HANDLED; } public client_putinserver( id ) {     boolBanned[id] = false;     set_task(4.0 , "CheckBanned", id ); } public client_disconnect( id ) {     boolBanned[id] = false;     if( task_exists( id , 0) )         remove_task( id , 0 ); } public CheckBanned( id ) {     new szAuth[36] , szTime[26] , tsVault , tsCurrent = get_systime() , tsStored;     get_user_authid( id , szAuth , 35);     if( !nvault_lookup( VaultName , szAuth , szTime , 25 , tsVault) )         return ;     tsStored = str_to_num(szTime);     if( tsStored == -1)     {         AddPrefix( id );         return ;     }     else if( ( tsStored - tsCurrent ) < get_timeleft() )     {         if( (tsStored - tsCurrent) <= 0)             set_task( 0.1 , "RemoveBan", id);         else             set_task( float(tsStored - tsCurrent) , "RemoveBan" , id);         AddPrefix( id );     }     return ; } public RemoveBan( id ) {     new szAuth[36], szTime[26] , tsVault , szName[36];     get_user_authid( id , szAuth , 35);     get_user_name( id , szName , 35);     nvault_lookup( VaultName , szAuth , szTime , 25 , tsVault);     nvault_prune( VaultName , (tsVault - 1) , (tsVault + 1 ) );     boolBanned[id] = false;     if(task_exists( id , 0) )         remove_task( id , 0);     RemovePrefix( id );     client_print( id , print_chat , "[Chat Ban] %s have served their time and are now able to chat again." , szName );     return; } public client_command( id ) {     new szCmd[10];     read_argv( 0 , szCmd , 9);     if( (equali( szCmd , "say") || equali( szCmd , "say_team")) && boolBanned[id])  //If they are trying to chat and are banned     {         client_print(id , print_chat , "[Chat Ban] You have been chat banned. You can NOT chat!");         return PLUGIN_HANDLED;     }     return PLUGIN_CONTINUE; } public AddPrefix( id ) {     boolBanned[id] = true;     new szName[36] , szNewName[46] , Cmd[56];     get_user_name( id , szName , 35);     get_cvar_string( "amx_cban_prefix" , szNewName , 45);     if( equal(szName , szNewName , strlen(szNewName) ) )         return PLUGIN_CONTINUE;     add( szNewName , 45 , szName );     format(Cmd , 55 , "name ^"%s^"",szNewName);     client_cmd( id , Cmd);     set_user_info( id , "name" , szNewName);     set_task(1.0 , "BlockName",id);     return PLUGIN_CONTINUE; } //---- Remove all instances of name----- public RemovePrefix( id ) {     new szName[46] , szPrefix[26] , Cmd[46];     get_cvar_string( "amx_cban_prefix" , szPrefix , 25);     get_user_name( id , szName , 45);     while( replace( szName , 45 , szPrefix , "") ) { }     format(Cmd , 45 , "name ^"%s^"",szName);     client_cmd( id , Cmd);     set_user_info( id , "name" , szName);     return PLUGIN_CONTINUE; } public BlockName( id ) {     boolBlock[id] = true;     return PLUGIN_CONTINUE; } public client_infochanged( id ) {     if( !boolBanned[id] )         return PLUGIN_CONTINUE;     if( !boolBlock[id])         return PLUGIN_CONTINUE;     if( boolStop[id] )         boolStop[id] = false;     new szOldName[36] , szNewName[36] , szPrefix[26] , Cmd[46];     get_user_name( id , szOldName , 35);     get_user_info( id , "name" , szNewName , 35);     get_cvar_string( "amx_cban_prefix" , szPrefix , 25);     //Allow name change if they kept the prefix at the beginning of thier name     if(equal(szNewName , szPrefix , strlen(szPrefix) ) )         return PLUGIN_CONTINUE;     //If it doesnt start with prefix add it.     format(szOldName , 35 , szPrefix);     add(szOldName , 35 , szNewName);     format(Cmd , 45 , "name ^"%s^"" , szOldName);     boolStop[id] = true;     set_user_info( id , "name" , szOldName);     boolStop[id] = true;     client_cmd( id , Cmd);     return PLUGIN_CONTINUE; }


All times are GMT -4. The time now is 23:41.

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