Raised This Month: $ Target: $400
 0% 

Fix the HLTV Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 03-12-2013 , 10:54   Fix the HLTV Plugin
Reply With Quote #1

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

new p_Address;
new 
p_Password;

public 
plugin_init()
{
    
register_plugin("HLTV Rcon",AMXX_VERSION_STR,"SmileY");
    
    
p_Address     register_cvar("hltv_address","127.0.0.1:27020",FCVAR_PROTECTED);
    
p_Password     register_cvar("hltv_password","PASSWORD",FCVAR_PROTECTED);
    
    
register_concmd("hltv_rcon","HLTV_Rcon",ADMIN_RCON,"hltv_rcon <COMANDO>");
}

public 
HLTV_Rcon(id,level,cid)
{
    if(!
cmd_access(id,level,cid,2)) return PLUGIN_HANDLED;
    
    new 
szAddress[32];
    
get_pcvar_string(p_Address,szAddress,charsmax(szAddress));
    
    new 
szIP[17],szPort[7];
    
strtok(szAddress,szIP,charsmax(szIP),szPort,charsmax(szPort),':');
    
    new 
szPassword[32];
    
get_pcvar_string(p_Password,szPassword,charsmax(szPassword));
    
    new 
szCommand[128];
    
read_args(szCommand,charsmax(szCommand));
    
remove_quotes(szCommand);
    
    new 
szSend[256],szString[256],szRcon[32],szNone[64];
    
    new 
iError;
    new 
iSock socket_open(szIP,str_to_num(szPort),SOCKET_UDP,iError);
    
    if(
iError)
    {
        
socket_close(iSock);
        
        
console_print(id,"[HLTV] Erro de Conexao: %d",iError);
        
        return 
PLUGIN_HANDLED;
    }
    
formatex(szSend,charsmax(szSend),"%c%c%c%cchallenge rcon",255,255,255,255);
    
socket_send2(iSock,szSend,charsmax(szSend));
    
    if(!
socket_change(iSock,1000000))
    {
        
socket_close(iSock);
        
        
console_print(id,"[HLTV] Nenhuma resposta de ^"%s^"",szAddress);
        
        return 
PLUGIN_HANDLED;
    }
    
socket_recv(iSock,szString,charsmax(szString));
    
parse(szString,szNone,charsmax(szNone),szNone,charsmax(szNone),szRcon,charsmax(szRcon));
    
    
formatex(szString,charsmax(szString),"%c%c%c%crcon %s ^"%s^" %s",255,255,255,255,szRcon,szPassword,szCommand);
    
socket_send2(iSock,szString,charsmax(szString));
    
    if(
socket_change(iSock))
    {
        new 
szBuffer[2048];
        
socket_recv(iSock,szBuffer,charsmax(szBuffer));
        
        
console_print(id,"[HLTV] %s",szBuffer[5]);
    }
    
socket_close(iSock);
    
    return 
PLUGIN_HANDLED;

I need to fix this plugin, isn't recive any response from HLTV server in linux.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 03-12-2013 at 10:55. Reason: Wrong code
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 21:43.


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