Raised This Month: $ Target: $400
 0% 

Can anyone help me fix some codes?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
etet
Junior Member
Join Date: Aug 2008
Old 05-19-2011 , 07:23   Can anyone help me fix some codes?
Reply With Quote #1

sorry for my poor english,i want to native other ip address modules for plugin
i try to change some code,but cannot compile.

original code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <li_geoip>
#include <ms>

#define PLUGIN_NAME           "Spectator"

new giSpectator[MAX_PLAYER][4];

public 
plugin_modules() {
    
require_module("amxmodx");
    
require_module("amxmisc");
    
require_module("cstrike");
    
require_module("li_geoip");
    
require_module("ms");
}

public 
plugin_init() {
    
register_plugin(PLUGIN_NAME,MS_VERSION,MS_AUTHOR);
    
register_dictionary("ms.txt");

    
register_event("TextMsg","ms_client_setspectatormode","bd","2&ec_Mod");
    
register_event("StatusValue","ms_client_displayinfomation","bd","1=2");

    
register_cvar("ms_module_spectator","1");
    
register_cvar("ms_hud_show_flag","63");
    
register_cvar("ms_hud_s_flag","1");
    
register_cvar("ms_hud_s_style","0");
    
register_cvar("ms_hud_s_fight","1");
    
register_cvar("ms_hud_s_color","0 255 0");
    
register_cvar("ms_hud_s_x","0.7");
    
register_cvar("ms_hud_s_y","0.5");
    
register_cvar("ms_hud_s_type","0");
    
register_cvar("ms_hud_s_time","6.0");
    
register_cvar("ms_hud_s_channel","3");
}

public 
plugin_cfg() {
    
set_cvar_num("ms_module_spectator",1);
}

public 
plugin_end() {
    
set_cvar_num("ms_module_spectator",0);
}

public 
plugin_natives() {
    
set_native_filter("native_filter");
    
register_native("ms_get_user_spectator","native_get_user_spectator",1);
}

public 
native_filter(const name[],index,trap)
{
    
//server_print("[MS Test] native_filter: native function not found [%s]",name);
    
if(!trap)return PLUGIN_HANDLED;
    return 
PLUGIN_CONTINUE;
}

public 
client_putinserver(id) {
    
giSpectator[id][0]=0;
    
giSpectator[id][1]=0;
    
giSpectator[id][2]=0;
    
giSpectator[id][3]=MS_MAP;
}

public 
Float:ms_method_apb(a,b,m) {
    if(
b==0)return 0.0;
    return 
1.0*a/b*m;
}

public 
ms_weapon_format(id,iw,cText[64]) {
    new 
cWName[MAX_NAME_LENGTH+1],iClip,iAmmo;
    
get_user_ammo(id,iw,iClip,iAmmo);
    
get_weaponname(iw,cWName,MAX_NAME_LENGTH);
    
replace_all(cWName,MAX_NAME_LENGTH,"weapon_","");
    if(
iw==CSW_HEGRENADE||iw==CSW_C4||iw==CSW_SMOKEGRENADE||iw==CSW_KNIFE)
        
formatex(cText,63,"%s",cWName);
    else if(
iw==CSW_FLASHBANG)
        
formatex(cText,63,"%s(%d)",cWName,iAmmo);
    else
        
formatex(cText,63,"%s(%d|%d)",cWName,iClip,iAmmo);
    return 
cText;
}

public 
ms_client_setspectatormode(id) {
    new 
arg[12];
    
read_data(2,arg,11);
    
giSpectator[id][0]=(arg[10]=='4');
}

public 
ms_client_displayinfomation(id) {
    if(
giSpectator[id][0])
    {
        new 
iPlayer=read_data(2),iTime=get_systime();
        if(
iPlayer==0)return;
        if(
giSpectator[id][1]==iPlayer&&iTime-giSpectator[id][2]<3)return;
        
giSpectator[id][1]=iPlayer;
        
giSpectator[id][2]=iTime;
        if(
is_user_connected(iPlayer)&&get_cvar_num("ms_hud_s_flag"))
        {
            new 
iLen,Float:fScore;
            new 
cText[1024],cName[MAX_NAME_LENGTH+1],cLName[MAX_NAME_LENGTH+1];
            new 
cIPAddress[16],cCountry[64],cArea[256];
            new 
iweapon[WEAPON_INDEX];
            new 
cColor[16],cColorR[4],cColorG[4],cColorB[4],iColorR,iColorG,iColorB;
            new 
flag=get_cvar_num("ms_hud_show_flag")&get_cvar_num("ms_syn_flag");
            new 
im=giSpectator[id][3];

            
get_user_name(iPlayer,cName,31);
            
get_user_ip(iPlayer,cIPAddress,15,1);
            
geoip_info(cIPAddress,cCountry,cArea,63,255);
            
fScore=ms_get_user_score(im,iPlayer);

            
iLen=0;
            switch(
im)
            {
                case 
MS_DAILY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_DAILY");
                case 
MS_WEEKLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_WEEKLY");
                case 
MS_MONTHLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_MONTHLY");
                case 
MS_QUARTERLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_QUARTERLY");
                case 
MS_YEARLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_YEARLY");
                case 
MS_ALL:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_ALL");
                case 
MS_MAP:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_MAP");
            }

            if(
get_cvar_num("ms_module_level"))
            {
                
ms_get_level(fScore,1,cLName);
                
iLen+=formatex(cText[iLen],1023-iLen,"[%s] %s^n",cLName,cName);
            }
            else
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s^n",LANG_PLAYER,"NAME",cName);

            
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %d/%d [%L] %.2f^n",LANG_PLAYER,"RANK",ms_get_user_rank(im,iPlayer),ms_get_user_count0(im),LANG_PLAYER,"SCORE",fScore);

            
ms_get_user_weaponstats(im,iPlayer,0,iweapon);

            if(
get_cvar_num("ms_hud_s_style"))
            {
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %L%.2f%%%% %L%.2f%%%% %L %.2f^n",LANG_PLAYER,"FIGHT",LANG_PLAYER,"HEADSHOTRATE",ms_method_apb(iweapon[WEAPON_HEADSHOT],iweapon[WEAPON_KILL],100),LANG_PLAYER,"HITRATE",ms_method_apb(iweapon[WEAPON_HIT],iweapon[WEAPON_SHOOT],100),LANG_PLAYER,"KD",ms_method_apb(iweapon[WEAPON_KILL],iweapon[WEAPON_DEATH],1));
            }
            else
            {
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %L(%d)/%L(%d) -> %.2f%%%%^n",LANG_PLAYER,"FIGHT",LANG_PLAYER,"HEADSHOT",iweapon[WEAPON_HEADSHOT],LANG_PLAYER,"KILL",iweapon[WEAPON_KILL],ms_method_apb(iweapon[WEAPON_HEADSHOT],iweapon[WEAPON_KILL],100));
                
iLen+=formatex(cText[iLen],1023-iLen,"          %L(%d)/%L(%d) -> %.2f%%%%^n",LANG_PLAYER,"HIT",iweapon[WEAPON_HIT],LANG_PLAYER,"SHOOT",iweapon[WEAPON_SHOOT],ms_method_apb(iweapon[WEAPON_HIT],iweapon[WEAPON_SHOOT],100));
                
iLen+=formatex(cText[iLen],1023-iLen,"          %L(%d):%L(%d) -> %.2f^n",LANG_PLAYER,"KILL",iweapon[WEAPON_KILL],LANG_PLAYER,"DEATH",iweapon[WEAPON_DEATH],ms_method_apb(iweapon[WEAPON_KILL],iweapon[WEAPON_DEATH],1));
            }

            if(
get_cvar_num("ms_hud_s_fight"))
            {
                new 
iLife,iArmor,CsArmorType:iArmorType;
                
iLife=get_user_health(iPlayer);
                
iArmor=cs_get_user_armor(iPlayer,iArmorType);
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %d|%d^n",LANG_PLAYER,"LIFE",iLife,iArmor);

                new 
iw,iWeapon[32],iCount=0,iNow,cTemp[64];
                
iNow=get_user_weapon(iPlayer);
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s^n",LANG_PLAYER,"WEAPON",ms_weapon_format(iPlayer,iNow,cTemp));
                
get_user_weapons(iPlayer,iWeapon,iCount);
                for(new 
i=0;i<iCount;i++)
                {
                    
iw=iWeapon[i];
                    if(
iw==iNow||iw==CSW_KNIFE)continue;
                    
iLen+=formatex(cText[iLen],1023-iLen,"          %s^n",ms_weapon_format(iPlayer,iw,cTemp));
                }
                if(
cs_get_user_defuse(iPlayer))iLen+=formatex(cText[iLen],1023-iLen,"          Defuse Kit^n");
            }

            
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s%s^n",LANG_PLAYER,"LOCATION",cCountry,cArea);

            if(
get_cvar_num("ms_module_signature"))
            {
                new 
cSignature[MAX_SIGNATURE_LENGTH+1];
                
ms_get_user_signature(iPlayer,cSignature);
                if(
equal(cSignature,""))
                    
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %L",LANG_PLAYER,"SIGNATURE",LANG_PLAYER,"SIGNATUREHINT");
                else
                    
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s",LANG_PLAYER,"SIGNATURE",cSignature);
            }

            
get_cvar_string("ms_hud_s_color",cColor,15);
            
parse(cColor,cColorR,3,cColorG,3,cColorB,3);
            
iColorR=str_to_num(cColorR)%256;
            
iColorG=str_to_num(cColorG)%256;
            
iColorB=str_to_num(cColorB)%256;

            
set_hudmessage(iColorR,iColorG,iColorB,get_cvar_float("ms_hud_s_x"),get_cvar_float("ms_hud_s_y"),get_cvar_num("ms_hud_s_type"),get_cvar_float("ms_hud_s_time"),_,_,_,get_cvar_num("ms_hud_s_channel"));
            
show_hudmessage(id,cText);
            if(
im==MS_MAP)im=-1;
            for(
im++;im<MS_MAP;im++)
            {
                if(
flag&(1<<im))break;
            }
            
giSpectator[id][3]=im;
        }
    }
}

public 
native_get_user_spectator(id) {
    return 
giSpectator[id][1];


after edit
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <ipseeker>
#include <ms>

#define PLUGIN_NAME           "Spectator"

new giSpectator[MAX_PLAYER][4];

public 
plugin_modules() {
    
require_module("amxmodx");
    
require_module("amxmisc");
    
require_module("cstrike");
    
require_module("ipseeker");
    
require_module("ms");
}

public 
plugin_init() {
    
register_plugin(PLUGIN_NAME,MS_VERSION,MS_AUTHOR);
    
register_dictionary("ms.txt");

    
register_event("TextMsg","ms_client_setspectatormode","bd","2&ec_Mod");
    
register_event("StatusValue","ms_client_displayinfomation","bd","1=2");

    
register_cvar("ms_module_spectator","1");
    
register_cvar("ms_hud_show_flag","63");
    
register_cvar("ms_hud_s_flag","1");
    
register_cvar("ms_hud_s_style","0");
    
register_cvar("ms_hud_s_fight","1");
    
register_cvar("ms_hud_s_color","0 255 0");
    
register_cvar("ms_hud_s_x","0.7");
    
register_cvar("ms_hud_s_y","0.5");
    
register_cvar("ms_hud_s_type","0");
    
register_cvar("ms_hud_s_time","6.0");
    
register_cvar("ms_hud_s_channel","3");
}

public 
plugin_cfg() {
    
set_cvar_num("ms_module_spectator",1);
}

public 
plugin_end() {
    
set_cvar_num("ms_module_spectator",0);
}

public 
plugin_natives() {
    
set_native_filter("native_filter");
    
register_native("ms_get_user_spectator","native_get_user_spectator",1);
}

public 
native_filter(const name[],index,trap)
{
    
//server_print("[MS Test] native_filter: native function not found [%s]",name);
    
if(!trap)return PLUGIN_HANDLED;
    return 
PLUGIN_CONTINUE;
}

public 
client_putinserver(id) {
    
giSpectator[id][0]=0;
    
giSpectator[id][1]=0;
    
giSpectator[id][2]=0;
    
giSpectator[id][3]=MS_MAP;
}

public 
Float:ms_method_apb(a,b,m) {
    if(
b==0)return 0.0;
    return 
1.0*a/b*m;
}

public 
ms_weapon_format(id,iw,cText[64]) {
    new 
cWName[MAX_NAME_LENGTH+1],iClip,iAmmo;
    
get_user_ammo(id,iw,iClip,iAmmo);
    
get_weaponname(iw,cWName,MAX_NAME_LENGTH);
    
replace_all(cWName,MAX_NAME_LENGTH,"weapon_","");
    if(
iw==CSW_HEGRENADE||iw==CSW_C4||iw==CSW_SMOKEGRENADE||iw==CSW_KNIFE)
        
formatex(cText,63,"%s",cWName);
    else if(
iw==CSW_FLASHBANG)
        
formatex(cText,63,"%s(%d)",cWName,iAmmo);
    else
        
formatex(cText,63,"%s(%d|%d)",cWName,iClip,iAmmo);
    return 
cText;
}

public 
ms_client_setspectatormode(id) {
    new 
arg[12];
    
read_data(2,arg,11);
    
giSpectator[id][0]=(arg[10]=='4');
}

public 
ms_client_displayinfomation(id) {
    if(
giSpectator[id][0])
    {
        new 
iPlayer=read_data(2),iTime=get_systime();
        if(
iPlayer==0)return;
        if(
giSpectator[id][1]==iPlayer&&iTime-giSpectator[id][2]<3)return;
        
giSpectator[id][1]=iPlayer;
        
giSpectator[id][2]=iTime;
        if(
is_user_connected(iPlayer)&&get_cvar_num("ms_hud_s_flag"))
        {
            new 
iLen,Float:fScore;
            new 
cText[1024],cName[MAX_NAME_LENGTH+1],cLName[MAX_NAME_LENGTH+1];
            new 
ip[16],address[64],area[256];
            new 
iweapon[WEAPON_INDEX];
            new 
cColor[16],cColorR[4],cColorG[4],cColorB[4],iColorR,iColorG,iColorB;
            new 
flag=get_cvar_num("ms_hud_show_flag")&get_cvar_num("ms_syn_flag");
            new 
im=giSpectator[id][3];

            
get_user_name(iPlayer,cName,31);
            
get_user_ip(iPlayer,ip,15,1);
            
ipseeker(ip,address,area,63,255);
            
fScore=ms_get_user_score(im,iPlayer);

            
iLen=0;
            switch(
im)
            {
                case 
MS_DAILY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_DAILY");
                case 
MS_WEEKLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_WEEKLY");
                case 
MS_MONTHLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_MONTHLY");
                case 
MS_QUARTERLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_QUARTERLY");
                case 
MS_YEARLY:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_YEARLY");
                case 
MS_ALL:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_ALL");
                case 
MS_MAP:iLen+=formatex(cText[iLen],1023-iLen,"[%L]^n",LANG_PLAYER,"MS_MAP");
            }

            if(
get_cvar_num("ms_module_level"))
            {
                
ms_get_level(fScore,1,cLName);
                
iLen+=formatex(cText[iLen],1023-iLen,"[%s] %s^n",cLName,cName);
            }
            else
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s^n",LANG_PLAYER,"NAME",cName);

            
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %d/%d [%L] %.2f^n",LANG_PLAYER,"RANK",ms_get_user_rank(im,iPlayer),ms_get_user_count0(im),LANG_PLAYER,"SCORE",fScore);

            
ms_get_user_weaponstats(im,iPlayer,0,iweapon);

            if(
get_cvar_num("ms_hud_s_style"))
            {
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %L%.2f%%%% %L%.2f%%%% %L %.2f^n",LANG_PLAYER,"FIGHT",LANG_PLAYER,"HEADSHOTRATE",ms_method_apb(iweapon[WEAPON_HEADSHOT],iweapon[WEAPON_KILL],100),LANG_PLAYER,"HITRATE",ms_method_apb(iweapon[WEAPON_HIT],iweapon[WEAPON_SHOOT],100),LANG_PLAYER,"KD",ms_method_apb(iweapon[WEAPON_KILL],iweapon[WEAPON_DEATH],1));
            }
            else
            {
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %L(%d)/%L(%d) -> %.2f%%%%^n",LANG_PLAYER,"FIGHT",LANG_PLAYER,"HEADSHOT",iweapon[WEAPON_HEADSHOT],LANG_PLAYER,"KILL",iweapon[WEAPON_KILL],ms_method_apb(iweapon[WEAPON_HEADSHOT],iweapon[WEAPON_KILL],100));
                
iLen+=formatex(cText[iLen],1023-iLen,"          %L(%d)/%L(%d) -> %.2f%%%%^n",LANG_PLAYER,"HIT",iweapon[WEAPON_HIT],LANG_PLAYER,"SHOOT",iweapon[WEAPON_SHOOT],ms_method_apb(iweapon[WEAPON_HIT],iweapon[WEAPON_SHOOT],100));
                
iLen+=formatex(cText[iLen],1023-iLen,"          %L(%d):%L(%d) -> %.2f^n",LANG_PLAYER,"KILL",iweapon[WEAPON_KILL],LANG_PLAYER,"DEATH",iweapon[WEAPON_DEATH],ms_method_apb(iweapon[WEAPON_KILL],iweapon[WEAPON_DEATH],1));
            }

            if(
get_cvar_num("ms_hud_s_fight"))
            {
                new 
iLife,iArmor,CsArmorType:iArmorType;
                
iLife=get_user_health(iPlayer);
                
iArmor=cs_get_user_armor(iPlayer,iArmorType);
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %d|%d^n",LANG_PLAYER,"LIFE",iLife,iArmor);

                new 
iw,iWeapon[32],iCount=0,iNow,cTemp[64];
                
iNow=get_user_weapon(iPlayer);
                
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s^n",LANG_PLAYER,"WEAPON",ms_weapon_format(iPlayer,iNow,cTemp));
                
get_user_weapons(iPlayer,iWeapon,iCount);
                for(new 
i=0;i<iCount;i++)
                {
                    
iw=iWeapon[i];
                    if(
iw==iNow||iw==CSW_KNIFE)continue;
                    
iLen+=formatex(cText[iLen],1023-iLen,"          %s^n",ms_weapon_format(iPlayer,iw,cTemp));
                }
                if(
cs_get_user_defuse(iPlayer))iLen+=formatex(cText[iLen],1023-iLen,"          Defuse Kit^n");
            }

            
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s%s^n",LANG_PLAYER,"LOCATION",address,area);

            if(
get_cvar_num("ms_module_signature"))
            {
                new 
cSignature[MAX_SIGNATURE_LENGTH+1];
                
ms_get_user_signature(iPlayer,cSignature);
                if(
equal(cSignature,""))
                    
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %L",LANG_PLAYER,"SIGNATURE",LANG_PLAYER,"SIGNATUREHINT");
                else
                    
iLen+=formatex(cText[iLen],1023-iLen,"[%L] %s",LANG_PLAYER,"SIGNATURE",cSignature);
            }

            
get_cvar_string("ms_hud_s_color",cColor,15);
            
parse(cColor,cColorR,3,cColorG,3,cColorB,3);
            
iColorR=str_to_num(cColorR)%256;
            
iColorG=str_to_num(cColorG)%256;
            
iColorB=str_to_num(cColorB)%256;

            
set_hudmessage(iColorR,iColorG,iColorB,get_cvar_float("ms_hud_s_x"),get_cvar_float("ms_hud_s_y"),get_cvar_num("ms_hud_s_type"),get_cvar_float("ms_hud_s_time"),_,_,_,get_cvar_num("ms_hud_s_channel"));
            
show_hudmessage(id,cText);
            if(
im==MS_MAP)im=-1;
            for(
im++;im<MS_MAP;im++)
            {
                if(
flag&(1<<im))break;
            }
            
giSpectator[id][3]=im;
        }
    }
}

public 
native_get_user_spectator(id) {
    return 
giSpectator[id][1];

include ipseeker:
PHP Code:
#if defined _IPSEEKER_included
    #endinput
#endif
#define _IPSEEKER_included

#if AMXX_VERSION_NUM >= 175
 #pragma reqlib ipseeker
 #if !defined AMXMODX_NOAUTOLOAD
  #pragma loadlib ipseeker
 #endif
#else
 #pragma library ipseeker
#endif

enum {
    
ipseek_all,
    
ipseek_country,
    
ipseek_area,
}; 
//ipseak_type

// get an IP's address with ipseek_type.
// if use_UTF8 is 0, the output will be in ANSI code page; 
//   else , the output will be in UTF-8 code page.
native ipseeker(ip[], ipseek_type ipseek_allout_address[], addr_lenuse_UTF8 0);

// get an IP's country , area
// if use_UTF8 is 0, the output will be in ANSI code page; 
//   else , the output will be in UTF-8 code page.
native ipseeker2(ip[], out_country[], country_lencountry_use_UTF8out_area[], area_lenarea_use_UTF8); 
etet is offline
 



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 20:14.


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