|
此插件作用为ucstats1.0统计loggs文件,用于amx下,但最近想把amx变成amxx,由于没法转变,自己也不太会C++语言,希望高人把此插件变成amxx下使用,多谢了!! :burn: :burn: :too_sad:
此插件有两个文件,ucstats_cstrike.sma和ucstats_live.sma,在amxx下ucstats_cstrike.sma可以通过编辑,但ucstats_live.sma出现问题了.
C:\Documents and Settings\Administrator\桌面\amxmodx_v1.01_cn_win\amxmodx\script
ing>amxxsc.exe ucstats_live.sma
Welcome to the AMX Mod X 1.00-272 Compiler.
Copyright (c) 1997-2004 ITB CompuPhase, AMX Mod X Team
ucstats_live.sma(21) : fatal error 100: cannot read from file: "udp"
Compilation aborted.
1 Error.
Could not locate output file ucstats_live.amx (compile failed).
插件名:ucstats_live.sma
源代码:
- /*
- * AMXMOD script.
- * (ucstats_live.sma)
- * by mike_cao <mike@mikecao.com>
- * This file is provided as is (no warranties).
- *
- * Provides a live server feed to UCStats.
- * You need to add the following cvars to your AMX config:
- *
- * ucstats_live_ip <ip>
- * ucstats_live_port <port>
- *
- * These cvars specify the ip and port of your live feed
- * daemon. This is the address the data will be sent to.
- *
- *
- */
- #include <amxmod>
- #include <amxmisc>
- #include <udp>
- #define MAX_NAME_LENGTH 32
- #define MAX_VAR_LENGTH 64
- #define MAX_PLAYERS 32
- #define MAX_WEAPONS 32
- #define MAX_TEXT_LENGTH 512
- #define MAX_UDP_LENGTH 1024
- #define MAX_CVARS 16
- #define MIN_PLAYTIME 60
- // Admin access level
- #define ACCESS_LEVEL ADMIN_LEVEL_A
- // Globals
- new gIP[MAX_NAME_LENGTH]
- new gPort = 0
- new gConnect = 0
- new gSender = 0
- new gScoreT = 0
- new gScoreCT = 0
- new gMapCycle[MAX_TEXT_LENGTH]
- new gNetAddress[MAX_NAME_LENGTH]
- new gCvars[MAX_CVARS][] = {"mp_timelimit","mp_autokick","mp_autoteambalance","mp_c4timer",
- "mp_flashlight","mp_footsteps","mp_forcechasecam","mp_freezetime",
- "mp_friendlyfire","mp_hostagepenalty","mp_roundtime","mp_startmoney",
- "sv_aim","sv_cheats","sv_maxrate","sv_minrate"}
- /************************************************************
- * UDP FUNCTIONS
- ************************************************************/
- // UDP Sender
- public udp_send_msg(msg[])
- {
- new sUDPMsg[MAX_UDP_LENGTH]
- format(sUDPMsg,MAX_UDP_LENGTH,"%s^"%s",gNetAddress,msg)
- if (gSender == 0) {
- get_cvar_string("ucstats_live_ip",gIP,MAX_NAME_LENGTH)
- gPort = get_cvar_num("ucstats_live_port")
- gSender = set_iaddress(gIP,gPort)
- }
- if (send_udp_msg(gSender,sUDPMsg)) {
- server_print("[UCStats] UDP SEND: <%s:%i>: %s",gIP,gPort,sUDPMsg)
- }
- else {
- server_print("[UCStats] UDP FAILED: <%s:%i>: %s",gIP,gPort,sUDPMsg)
- }
- }
- public admin_livefeed(id,level,cid)
- {
- if (!cmd_access(id,level,cid,0)) return PLUGIN_HANDLED
- new iPlayers[MAX_PLAYERS], iNumPlayers, iMaxPlayers
- new sMsg[MAX_UDP_LENGTH], sName[MAX_NAME_LENGTH], sIP[MAX_NAME_LENGTH]
- new sMap[MAX_NAME_LENGTH], sNextMap[MAX_VAR_LENGTH], sServer[MAX_NAME_LENGTH], sAddress[MAX_NAME_LENGTH], sServerTime[MAX_NAME_LENGTH]
- new iIndex, iPing, iLoss, iKills, iDeaths, iTeam, iUserTime, iAlive
- new sAuthid[MAX_NAME_LENGTH]
-
- // Get list of players
- get_players(iPlayers,iNumPlayers)
-
- // Send server info
- get_mapname(sMap,MAX_NAME_LENGTH)
- get_cvar_string("hostname",sServer,MAX_NAME_LENGTH)
- get_cvar_string("net_address",sAddress,MAX_NAME_LENGTH)
- get_cvar_string("amx_nextmap",sNextMap,MAX_VAR_LENGTH)
-
- if (!is_map_valid(sNextMap)) {
- copy(sNextMap,MAX_VAR_LENGTH,"[UNKNOWN]")
- }
- get_time("%m/%d/%Y - %H:%M:%S",sServerTime,MAX_NAME_LENGTH)
-
- iMaxPlayers = get_maxplayers()
- if (iMaxPlayers > get_cvar_num("sv_visiblemaxplayers") && get_cvar_num("sv_visiblemaxplayers") > 0) {
- iMaxPlayers = get_cvar_num("sv_visiblemaxplayers")
- }
- // Send package header
- udp_send_msg("LIVEFEED^"BEGIN")
-
- // Format message
- // LIVEFEED"SERVER"name"address"numplayers"maxplayers"map"maptime"timeleft"connects"tscore"ctscore"server_time
- format(sMsg,MAX_UDP_LENGTH,"LIVEFEED^"SERVER^"%s^"%s^"%i^"%i^"%s^"%i^"%i^"%i^"%i^"%i^"%s^"%s",
- sServer,sAddress,iNumPlayers,iMaxPlayers,sMap,get_cvar_num("mp_timelimit"),(get_timeleft()/60),gConnect,gScoreT,gScoreCT,sServerTime,sNextMap)
- udp_send_msg(sMsg)
- // Send status of every player
- for (new i = 0; i < iNumPlayers; i++) {
- // Get data
- iIndex = iPlayers[i]
- get_user_name(iIndex,sName,MAX_NAME_LENGTH)
- if (is_user_bot(iIndex)) {
- format(sAuthid,MAX_NAME_LENGTH,"%s","BOT")
- }
- else {
- get_user_authid(iIndex,sAuthid,MAX_NAME_LENGTH)
- }
- iKills = get_user_frags(iIndex)
- iDeaths = get_user_deaths(iIndex)
- iTeam = get_user_team(iIndex)
- iAlive = is_user_alive(iIndex)
- iUserTime = get_user_time(iIndex,1)
- get_user_ip(iIndex,sIP,MAX_NAME_LENGTH,1)
- get_user_ping(iIndex,iPing,iLoss)
-
- // Format message and send
- // LIVEFEED"PLAYER"index"name"authid"kills"deaths"team"alive"ping"playingtime"ip
- format(sMsg,MAX_UDP_LENGTH,"LIVEFEED^"PLAYER^"%i^"%s^"%s^"%i^"%i^"%i^"%i^"%i^"%i^"%s",
- iIndex,sName,sAuthid,iKills,iDeaths,iTeam,iAlive,iPing,iUserTime,sIP)
- udp_send_msg(sMsg)
- }
-
- // Send list of cvars
- // Format message and send
- // CVAR"name"value
- for (new i = 0; i < MAX_CVARS; i++) {
- format(sMsg,MAX_UDP_LENGTH,"LIVEFEED^"CVAR^"%s^"%i",gCvars[i],get_cvar_num(gCvars[i]))
- udp_send_msg(sMsg)
- }
- // Send mapcycle
- // MAPCYCLE"map"map"map
- format(sMsg,MAX_UDP_LENGTH,"LIVEFEED^"MAPCYCLE^"%s",gMapCycle)
- udp_send_msg(sMsg)
-
- // Send package footer
- udp_send_msg("LIVEFEED^"END")
-
- return PLUGIN_CONTINUE
- }
- public admin_livechat(id,level,cid)
- {
- if (!cmd_access(id,level,cid,3)) return PLUGIN_HANDLED
- // Get parameters
- new sArg1[MAX_NAME_LENGTH]
- new sArg2[MAX_TEXT_LENGTH]
- read_argv(1,sArg1,MAX_NAME_LENGTH)
- read_argv(2,sArg2,MAX_TEXT_LENGTH)
- new iPlayer, iPlayers[MAX_PLAYERS], iNumPlayers
- get_players(iPlayers,iNumPlayers,"c")
- for (new i = 0; i < iNumPlayers; i++) {
- iPlayer = iPlayers[i]
- client_print(iPlayer,print_chat, "(WEB) %s : %s",sArg1,sArg2)
- }
- console_print(id,"[UCStats] LIVECHAT: %s: %s",sArg1,sArg2)
- // Make sure it comes back
- new sMsg[MAX_UDP_LENGTH]
- // Format and send
- // LIVECHAT,say,player,team,message
- format(sMsg,MAX_UDP_LENGTH,"LIVECHAT^"%s^"%s^"%i^"%s","WEB",sArg1,0,sArg2)
- udp_send_msg(sMsg)
- return PLUGIN_CONTINUE
- }
- public bool:is_alpha(c)
- {
- return ((c>='a'&&c<='z')||(c>='A'&&c<='Z')) ? true : false
- }
- public get_mapcycle()
- {
- new iLen, iIndex = 0
- new sFilename[MAX_VAR_LENGTH], sBuffer[MAX_VAR_LENGTH]
- get_cvar_string("mapcyclefile",sFilename,MAX_VAR_LENGTH)
- if (file_exists(sFilename)) {
- while(read_file(sFilename,iIndex++,sBuffer,MAX_VAR_LENGTH,iLen)) {
- if (is_alpha(sBuffer[0]) && is_map_valid(sBuffer)) {
- add(gMapCycle,MAX_TEXT_LENGTH,sBuffer,MAX_VAR_LENGTH)
- add(gMapCycle,MAX_TEXT_LENGTH,"^"",1)
- }
- }
- }
- }
- public send_mapchange()
- {
- new sMsg[MAX_UDP_LENGTH]
-
- // Format and send
- // LIVEEVENT,MAPCHANGE
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"MAPCHANGE")
- udp_send_msg(sMsg)
- }
- /************************************************************
- * EVENT FUNCTIONS
- ************************************************************/
- public event_death() {
- new iKiller = read_data(1)
- new iVictim = read_data(2)
- new iHeadshot = read_data(3)
- new sMsg[MAX_UDP_LENGTH]
- new sKiller[MAX_NAME_LENGTH], sVictim[MAX_NAME_LENGTH], sWeapon[MAX_NAME_LENGTH]
- new iKillerTeam, iVictimTeam
- new iWeapon, iBody
- get_user_attacker(iVictim,iWeapon,iBody)
- get_weaponname(iWeapon,sWeapon,MAX_NAME_LENGTH)
-
- get_user_name(iKiller,sKiller,MAX_NAME_LENGTH)
- get_user_name(iVictim,sVictim,MAX_NAME_LENGTH)
- iKillerTeam = get_user_team(iKiller)
- iVictimTeam = get_user_team(iVictim)
-
- // Format and send
- // LIVEEVENT,KILL,killer,team,victim,team,weapon,headshot
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"KILL^"%s^"%i^"%s^"%i^"%s^"%i",
- sKiller,iKillerTeam,sVictim,iVictimTeam,sWeapon,iHeadshot)
- udp_send_msg(sMsg)
-
- return PLUGIN_CONTINUE
- }
- public event_world_action()
- {
- new sMsg[MAX_UDP_LENGTH]
- new sAction[MAX_NAME_LENGTH]
- read_logargv(1,sAction,MAX_VAR_LENGTH)
-
- // Format and send
- // LIVEEVENT,WORLD,event
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"WORLD^"%s",sAction)
- udp_send_msg(sMsg)
-
- return PLUGIN_CONTINUE
- }
- public event_player_action()
- {
- new iUserId
- new sArg[MAX_VAR_LENGTH]
- new sName[MAX_NAME_LENGTH]
- new sAction[MAX_NAME_LENGTH]
-
- read_logargv(0,sArg,MAX_VAR_LENGTH)
- read_logargv(2,sAction,MAX_VAR_LENGTH)
- parse_loguser(sArg,sName,MAX_NAME_LENGTH,iUserId)
- new sMsg[MAX_UDP_LENGTH]
- new sAuthid[MAX_NAME_LENGTH]
- new iTeam
-
- if (is_user_bot(iUserId)) {
- format(sAuthid,MAX_NAME_LENGTH,"%s","BOT")
- }
- else {
- get_user_authid(iUserId,sAuthid,MAX_NAME_LENGTH)
- }
- iTeam = get_user_team(iUserId)
-
- // Format and send
- // LIVEEVENT,ACTION,name,team,action
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"ACTION^"%s^"%i^"%s^"%s",sName,iTeam,sAction)
- udp_send_msg(sMsg)
-
- return PLUGIN_CONTINUE
- }
- public event_say(id)
- {
- new sMsg[MAX_UDP_LENGTH]
- new sName[MAX_NAME_LENGTH]
- new sCommand[MAX_NAME_LENGTH]
- new sMessage[MAX_TEXT_LENGTH]
- new iTeam
- read_argv(0,sCommand,MAX_TEXT_LENGTH)
- read_argv(1,sMessage,MAX_TEXT_LENGTH)
- get_user_name(id,sName,MAX_NAME_LENGTH)
- iTeam = get_user_team(id)
-
- // Format and send
- // LIVECHAT,say,name,team,message
- format(sMsg,MAX_UDP_LENGTH,"LIVECHAT^"%s^"%s^"%i^"%s",sCommand,sName,iTeam,sMessage)
- udp_send_msg(sMsg)
-
- return PLUGIN_CONTINUE
- }
- public event_team_score(id)
- {
- new sTeam[MAX_NAME_LENGTH]
- read_data(1,sTeam,MAX_NAME_LENGTH)
- if (equal(sTeam,"CT")) {
- gScoreCT = read_data(2)
- }
- else {
- gScoreT = read_data(2)
- }
-
- return PLUGIN_CONTINUE
- }
- /************************************************************
- * PLUGIN FUNCTIONS
- ************************************************************/
- public plugin_end()
- {
- send_mapchange()
- return PLUGIN_CONTINUE
- }
- public client_putinserver(id)
- {
- new sMsg[MAX_UDP_LENGTH]
- new sName[MAX_NAME_LENGTH]
- new sIP[MAX_NAME_LENGTH]
- new sAuthid[MAX_TEXT_LENGTH]
- new sMap[MAX_NAME_LENGTH], iNumPlayers, iMaxPlayers
- get_user_name(id,sName,MAX_NAME_LENGTH)
- if (is_user_bot(id)) {
- format(sAuthid,MAX_NAME_LENGTH,"%s","BOT")
- }
- else {
- get_user_authid(id,sAuthid,MAX_NAME_LENGTH)
- }
- get_user_ip(id,sIP,MAX_NAME_LENGTH,1)
-
- // Format and send
- // LIVEEVENT,JOINED,player,id,ip
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"JOINED^"%s^"%s^"%s",sName,sAuthid,sIP)
- udp_send_msg(sMsg)
-
- get_mapname(sMap,MAX_NAME_LENGTH)
- iNumPlayers = get_playersnum()
- iMaxPlayers = get_maxplayers()
- if (iMaxPlayers > get_cvar_num("sv_visiblemaxplayers") && get_cvar_num("sv_visiblemaxplayers") > 0) {
- iMaxPlayers = get_cvar_num("sv_visiblemaxplayers")
- }
-
- // LIVEEVENT,MAPSTATUS,map,numplayers,maxplayers
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"MAPSTATUS^"%s^"%i^"%i",sMap,iNumPlayers,iMaxPlayers)
- udp_send_msg(sMsg)
-
- return PLUGIN_CONTINUE
- }
- public client_connect(id)
- {
- if (!is_user_bot(id)) {
- gConnect += 1
- }
- return PLUGIN_CONTINUE
- }
- public client_disconnect(id)
- {
- new sMsg[MAX_UDP_LENGTH]
- new sName[MAX_NAME_LENGTH]
- new sIP[MAX_NAME_LENGTH]
- new sAuthid[MAX_TEXT_LENGTH]
- new sMap[MAX_NAME_LENGTH], iNumPlayers, iMaxPlayers
- get_user_name(id,sName,MAX_NAME_LENGTH)
- if (is_user_bot(id)) {
- format(sAuthid,MAX_NAME_LENGTH,"%s","BOT")
- }
- else {
- get_user_authid(id,sAuthid,MAX_NAME_LENGTH)
- }
- get_user_ip(id,sIP,MAX_NAME_LENGTH,1)
-
- // Format and send
- // LIVEEVENT,JOINED,player,id,ip
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"LEFT^"%s^"%s^"%s",sName,sAuthid,sIP)
- udp_send_msg(sMsg)
-
- get_mapname(sMap,MAX_NAME_LENGTH)
- iNumPlayers = get_playersnum()-1
- iMaxPlayers = get_maxplayers()
- if (iMaxPlayers > get_cvar_num("sv_visiblemaxplayers") && get_cvar_num("sv_visiblemaxplayers") > 0) {
- iMaxPlayers = get_cvar_num("sv_visiblemaxplayers")
- }
-
- // LIVEEVENT,MAPSTATUS,map,numplayers,maxplayers
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"MAPSTATUS^"%s^"%i^"%i",sMap,iNumPlayers,iMaxPlayers)
- udp_send_msg(sMsg)
- return PLUGIN_CONTINUE
- }
- public client_infochanged(id)
- {
- new sMsg[MAX_UDP_LENGTH]
- new sName[MAX_TEXT_LENGTH], sNewName[MAX_TEXT_LENGTH]
- get_user_name(id,sName,MAX_TEXT_LENGTH)
- get_user_info(id,"name",sNewName,MAX_TEXT_LENGTH)
- if (!equal(sName,sNewName) && !equal(sName,"") && !equal(sName,"(null)")) {
- // Format and send
- // LIVEEVENT,NAMECHANGE,name,newname
- format(sMsg,MAX_UDP_LENGTH,"LIVEEVENT^"NAMECHANGE^"%s^"%s",sName,sNewName)
- udp_send_msg(sMsg)
- }
- return PLUGIN_CONTINUE
- }
- public plugin_init() {
- register_plugin("Plugin UCStats (live)","1.0","mike_cao")
- register_srvcmd("amx_livefeed","admin_livefeed",ACCESS_LEVEL,"amx_livefeed")
- register_srvcmd("amx_livechat","admin_livechat",ACCESS_LEVEL,"amx_livechat <name> <message>")
-
- register_event("DeathMsg","event_death","a")
- register_event("TeamScore","event_team_score","a")
-
- register_logevent("event_player_action",3,"1=triggered")
- register_logevent("event_world_action",2,"0=World triggered")
- register_cvar("ucstats_live_ip","")
- register_cvar("ucstats_live_port","")
- // Init
- set_task(1.0,"send_mapchange")
- set_task(2.0,"get_mapcycle")
-
- // Register say
- register_clcmd("say","event_say")
- register_clcmd("say_team","event_say")
- get_cvar_string("net_address",gNetAddress,MAX_NAME_LENGTH)
- if (strlen(gNetAddress) == 0) {
- format(gNetAddress,MAX_NAME_LENGTH,"%s","127.0.0.1");
- }
-
- // Initialize UDP session
- if (get_udp_status()) {
- server_print("[UCStats] UDP initialized successfully.")
- }
- else {
- server_print("[UCSstats] Failed to initialize UDP.")
- }
-
- return PLUGIN_CONTINUE
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注个册吧
×
|