Raised This Month: $51 Target: $400
 12% 

How to fix these plugin errors?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
2389736818
Member
Join Date: Jul 2014
Location: China
Old 12-10-2018 , 04:08   How to fix these plugin errors?
Reply With Quote #1

code
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <tinyxml>
#include <SteamWorks>

bool IsClientJoinTeam[MAXPLAYERS+1] = {false,...};
char s_ip[MAXPLAYERS+1][32];

#define VERSION "1.0"

public Plugin myinfo 
{
    
name "Easy IP Query",
    
author "2389736818",
    
description "",
    
version "1.0",
    
url "www.sourcemod.net"
}

public 
OnPluginStart()
{
    
CreateConVar("ipfinder_online"VERSION"Easy IP Query"FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
HookEvent("player_team"Event_PlayerTeamEventHookMode_Pre);
}

public 
void OnClientConnected(int client)
{
    if(!
IsFakeClient(client))
    {
        
IsClientJoinTeam[client] = false;
    }
}

public 
void Event_PlayerTeam(Handle eventchar[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
    if(
IsClientValid(client) && !IsClientJoinTeam[client])
    {
        
IsClientJoinTeam[client] = true;
        
CreateTimer(1.0,TimerFindIP,client,TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action TimerFindIP(Handle Timerany client

    if(
IsClientValid(client))
    {
        
        if(
GetClientIP(clients_ip[client], sizeof(s_ip[])))
        {
            
GetTrackValue(client,s_ip[client]);
        }    
        
    }
}

public 
int OnTransferComplete(Handle hRequestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeint client)
{
    if (!
bFailure && bRequestSuccessful && eStatusCode == k_EHTTPStatusCode200OK)
    {
        
SteamWorks_GetHTTPResponseBodyCallback(hRequestCMD_GetTrack,client);
    }
    
    
delete(hRequest);
}

public 
int CMD_GetTrack(int clientint args)
{
    
char sip[255];
    
GetTrackValue("ip"sipsizeof(sip));

    
char scity[255];
    
GetTrackValue("city"scitysizeof(scity));

    
char sregion[255];
    
GetTrackValue("region"sregionsizeof(sregion));

    
char scountry[255];
    
GetTrackValue("country"scountrysizeof(scountry));

    
char scountry_name[255];
    
GetTrackValue("country_name"scountry_namesizeof(scountry_name));

    
char sorg[255];
    
GetTrackValue("org"sorgsizeof(sorg));

    
PrintToServer(" \x02[Easy IP Query]\x01 Player \x04%N--%s\x01 \x05 Come From: [%s-%s] %s %s ISP: %s",client,s_ip,scountry,scountry_name,sregion,scity,sorg);
}

void GetTrackValue(int client, const char[] tagchar[] sResult, const char[] sipmaxlength)
{
    
char sRequest[256];
    if (
sRequest[0] == '\0')
    {
        
FormatEx(sRequestsizeof(sRequest), "https://ipapi.co/%s/xml",sip);
    }
    
    
Handle hRequest SteamWorks_CreateHTTPRequest(k_EHTTPMethodGETsRequest);
    if (!
hRequest || !SteamWorks_SetHTTPCallbacks(hRequestOnTransferComplete) || !SteamWorks_SetHTTPRequestContextValue(hRequestclient) || !SteamWorks_SendHTTPRequest(hRequest))
    {
        
delete(hRequest);
    }
    
    
Handle hDoc TinyXml_CreateDocument();
    
//TinyXml_LoadFile(hDoc, "https://ipapi.co/%s/xml");

    
Handle hRoot TinyXml_RootElement(hDoc); // <tracks>

    
if(hRoot == INVALID_HANDLE)
    {
        
CloseHandle(hDoc);
        return 
false;
    }

    
bool bResult false;
    
// Get the first <track> inside of <tracks>
    
Handle hTrack TinyXml_FirstChildElement(hRoot"track"); // <track>
    
if(hTrack != INVALID_HANDLE)
    {
        
Handle hEntry TinyXml_FirstChildElement(hTrack);

        
// Iterate over all elements of the <track> element.
        
while(hEntry != INVALID_HANDLE)
        {
            
decl String:sKey[128];
            
TinyXml_Value(hEntrysKeysizeof(sKey));

            
// if the key matches "tag", return it.
            
if(StrEqual(sKeytag))
            {
                
TinyXml_GetText(hEntrysResultmaxlength);
                
bResult true;
                break;
            }

            
hEntry TinyXml_NextSiblingElement(hEntry);
        }

        
CloseHandle(hEntry);
        
CloseHandle(hTrack);
    }

    
CloseHandle(hRoot);
    
CloseHandle(hDoc);
    return 
bResult;
}

int String_GetStringFromPosion(const char[] sourceint source_sizeint pos_start 0int pos_end 0char[] resultint result_size)
{
    
int iCount;
    for(
int i 0source_sizei++)
    {
        if(
>= pos_end)
            break;
        else if(
< (pos_start 1))
            continue;
        else
        {
            
char buffer[1];
            
buffer[0] = source[i];
            
//TrimString(buffer);
            
StrCat(resultresult_sizebuffer);
            
iCount++;
        }
    }
    return 
iCount;
}

int String_GetPosion(const char[] source, const int source_size, const char[] search, const int posion_start 1)
{
    if(
posion_start == 1)
    {
        return 
StrContains(sourcesearchtrue);
    }
    
int pos = -1;
    
int size source_size posion_start;
    if(
size 0){
        
char[] buffer = new char[size];
        for(
int i 0source_sizei++)
        {
            if(
> (posion_start 1))
            {
                
StrCat(buffersizesource[i]);
            }
        }
        
pos StrContains(buffersearchtrue) + posion_start;
    }
    return 
pos;
}

stock bool IsClientValid(int client)
{
    if(
client && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client))
    {
        return 
true;
    }
    return 
false;

Attached Thumbnails
Click image for larger version

Name:	1812101704_1.png
Views:	103
Size:	33.0 KB
ID:	172702  
__________________
2389736818 is offline
poachedegg
Junior Member
Join Date: Nov 2018
Location: China
Old 12-11-2018 , 09:11   Re: How to fix these plugin errors?
Reply With Quote #2

The console tell you all the things. You Missed param1 'client' and param3 'sResult' by using function 'GetTrackValue'.

eg. line 71:
'GetTrackValue("ip", sip, sizeof(sip));' to 'GetTrackValue(client, "ip", sResult, sip, sizeof(sip));'

Last edited by poachedegg; 12-11-2018 at 09:31.
poachedegg is offline
poachedegg
Junior Member
Join Date: Nov 2018
Location: China
Old 12-11-2018 , 09:14   Re: How to fix these plugin errors?
Reply With Quote #3

error 2
you can't return false or true in void function. delete ruturn true/false; or change 'void GetTrackValue' to 'bool GetTrackValue'


same as line 62.
function SteamWorks_GetHTTPResponseBodyCallback 's param2 'CMD_GetTrack' has a wrong type.
PHP Code:
funcenum SteamWorksHTTPBodyCallback
{
    public(const 
String:sData[]),
    public(const 
String:sData[], any:value),
    public(const 
data[], any:valuedatalen)
}; 
Your callback function should match the one of the three. Such as 'public CMD_GetTrack(const String:sData[], any:value)' the param2 'any:value' can be any type you want.

Last edited by poachedegg; 12-11-2018 at 09:30.
poachedegg is offline
poachedegg
Junior Member
Join Date: Nov 2018
Location: China
Old 12-11-2018 , 09:31   Re: How to fix these plugin errors?
Reply With Quote #4

oic. You request a http and get it's body. Then used it in GetTrackValue. So your CMD_GetTrack should like:
public CMD_GetTrack(const String:sResult[], client)

then you use GetTrackValue like:
GetTrackValue(client, "ip", sResult, sip, sizeof(sip));
poachedegg is offline
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 11:53.


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