ssj4gogeta 发表于 2005-8-25 09:52:09

【求助】插件高手进来帮忙,我修改插件遇到困难了

我想自己修改一个插件,以前有求过别人,但都没人帮我做!

所一我看了一点点基础想自己修改一下!

我需要改sprites_show插件!
我想把CLCMD的权限设为0,然后把sprite命令的目标设置成命令发起者,然后去掉unsprite命令,并且修改sprite命令使得spr出现后在几秒后自动消失!!!

不过上述的东西我实现很困难!
有谁可一教我?

Enigmaya 发表于 2005-8-25 17:19:03

你问的问题。。。要你自己修改,可是一开始就不知道怎么进行?

那我们还能说什么。。。

先多看看amxx的教程
,能有c或c++的基础最好。


ps:那个插件传上来吧,我想看看。

ssj4gogeta 发表于 2005-8-25 18:04:53

这是代码
/*

Plugin: Sprites Show (Show funny sprites above players' head)
Version: 1.5
Author: KRoTaL (Based on the original admin show plugin by StuD|MaN)

1.0 Release
1.1 new sprite : camper2
1.2 optimization, works better
1.3 you can now precache and use your own sprites
1.4 bug fix (hopefully)
1.5 sprites stay on player's head until you remove them with amx_unsprite (it can stay a whole map now)
    + sprites_show_players.txt file added (see below for more details)

Commands:

   amx_sprite <name|id|@CT|@TERRORIST|*(all)> <name of sprite>   -   Shows sprite above player's head.
   amx_unsprite <name|id|@CT|@TERRORIST|*(all)>          -   Removes sprite(s).

Default sprites are :

camper
camper2 (bigger sprite)
fag
idiot
sexy
shoot
grass_01
ic4
ihostage
iplayerc4
ledglow
sniper_scope

You can use your own sprites by simply :

1) writing their names in the "sprites_show.txt" file located in addons/amxx/configs (this file is included in the zip,
   with the names of the default sprites inside).
   Use this format (names without .spr) :
   camper
   asskicker
   banned
2) putting your sprites in the "sprites" folder of your game (ex: cstrike/sprites), sprites must be named
   like what you wrote in sprites_show.txt
   camper.spr
   asskicker.spr
   banned.spr       

You can associate a SteamId with a sprite in the "sprites_show_players.txt" file located in addons/amxx/configs.
Each time a player connects, if his steamid is in this file with a valid sprite written after, the sprite will appear
on his head when he enters the game (and the sprite will remain until you amx_unsprite him).
Use this format in the "sprites_show_players.txt" file :
STEAM_0:0:481540,idiot
STEAM_0:1:7412,camper


Examples :

amx_sprite Player idiot
amx_sprite @CT sexy
amx_sprite @TERRORIST shoot
amx_sprite * fag

amx_unsprite Player
amx_unsprite @CT
amx_unsprite *

If you want to use more than 25 sprites, you must set MAX_SPRITES to the maximum number of sprites wanted, and then
compile the source file.

*/

#define MAX_SPRITES 25










//----------------------------------------------------------------------------------------------
#include <amxmodx>
#include <amxmisc>

new spritew
new sprite_name
new sprite_precached
new nbr_sprites=0
new SpriteFlag


//----------------------------------------------------------------------------------------------
public sprite(id, level, cid) {
   if(!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED

   new arg1
   read_argv(1, arg1, 31)
   read_argv(2, spritew, 31)

   new test=0
   new id_sprite
   new valid_sprites

   for(new i = 0 ; i<nbr_sprites-1 ; i++)
   {
      if(equal(spritew,sprite_name))
      {
         test++
         id_sprite=i
      }       
      if(i>0)
         add(valid_sprites, 127, ",")
      add(valid_sprites, 127, sprite_name)
   }
   if(test==0)
   {
      console_print(id, "%s 不是一个有效的标记.", spritew)
      console_print(id, "有效的标记是 :")
      console_print(id, "%s", valid_sprites)
      return PLUGIN_HANDLED
   }   

   if(arg1 == '@') {
      new users, inum
      get_players(users, inum, "ae", arg1)
      if(inum == 0) {
              console_print(id, "在这个队伍没有这名字的玩家")
              return PLUGIN_HANDLED
      }

      for(new i = 0; i < inum; ++i) {
                message_begin(MSG_ALL,SVC_TEMPENTITY)
                write_byte(125)
                write_byte(users)
                message_end()
                new parm
                parm = users
                SpriteFlag] = id_sprite
                set_task(0.1,"showS",481,parm,1)
      }
   }
   else if(arg1 == '*')
   {
      new users, inum
      get_players(users, inum, "a")
      if(inum == 0) {
              console_print(id, "在这个队伍没有这名字的玩家")
              return PLUGIN_HANDLED
      }        

      for(new i = 0; i < inum; ++i) {
                message_begin(MSG_ALL,SVC_TEMPENTITY)
                write_byte(125)
                write_byte(users)
                message_end()
                new parm
                parm = users
                SpriteFlag] = id_sprite
                set_task(0.1,"showS",481,parm,1)

      }
   }
   else {
        new uid = cmd_target(id, arg1, 5)
        if(!uid) return PLUGIN_HANDLED
        if(SpriteFlag != -1)
        {
                message_begin(MSG_ALL,SVC_TEMPENTITY)
                write_byte(125)
                write_byte(uid)
                message_end()
        }                       
        new parm
        parm = uid
        SpriteFlag = id_sprite
        set_task(0.1,"showS",481,parm,1)
   }
   if(task_exists(4810))
      remove_task(4810)
   set_task(5.0,"showS_loop",4810,"",0,"b")

   return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public unsprite(id, level, cid) {
   if(!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED

   new arg
   read_argv(1, arg, 31)

   if(arg == '@') {
      new users, inum
      get_players(users, inum, "e", arg)
      if(inum == 0) {
              console_print(id, "在这个队伍没有这名字的玩家")
              return PLUGIN_HANDLED
      }

      for(new i = 0; i < inum; ++i) {
                message_begin(MSG_ALL,SVC_TEMPENTITY)
                write_byte(125)
                write_byte(users)
                message_end()
                SpriteFlag] = -1
      }
   }
   else if(arg == '*')
   {
      new users, inum
      get_players(users, inum)
      if(inum == 0) {
              console_print(id, "在这个队伍没有这名字的玩家")
              return PLUGIN_HANDLED
      }        

      for(new i = 0; i < inum; ++i) {
                message_begin(MSG_ALL,SVC_TEMPENTITY)
                write_byte(125)
                write_byte(users)
                message_end()
                SpriteFlag] = -1
      }
      if(task_exists(4810))
            remove_task(4810)
   }
   else {
        new uid = cmd_target(id, arg, 5)
        if(!uid) return PLUGIN_HANDLED
        message_begin(MSG_ALL,SVC_TEMPENTITY)
        write_byte(125)
        write_byte(uid)
        message_end()
        SpriteFlag = -1
   }
   return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public showS(parm[])
{       
        new id = parm
        if(is_user_alive(id))
        {
                if(SpriteFlag != -1)
                {
                        message_begin(MSG_ALL,SVC_TEMPENTITY)
                        write_byte(124)
                        write_byte(id)
                        write_coord(65)
                        write_short(sprite_precached])
                        write_short(32767)
                        message_end()
                }
        }
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public showS_loop()
{       
        new players, pl_num=0
        get_players(players,pl_num,"a")
        for (new i=0;i<pl_num;i++)
        {
                if(SpriteFlag] != -1)
                {
                        message_begin(MSG_ALL,SVC_TEMPENTITY)
                        write_byte(124)
                        write_byte(players)
                        write_coord(65)
                        write_short(sprite_precached]])
                        write_short(32767)
                        message_end()
                }
        }
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
        SpriteFlag = -1
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public client_disconnect(id)
{
        message_begin(MSG_ALL,SVC_TEMPENTITY)
        write_byte(125)
        write_byte(id)
        message_end()
        SpriteFlag = -1
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public client_authorized(id)
{
        new authid
        get_user_authid(id,authid,32)

        new text
        new len
        new pos=0
        new textblock
        new sprite_config
        get_configsdir(sprite_config, 63)
        format(sprite_config, 63, "%s/sprites_show_players.txt", sprite_config)

        if (file_exists(sprite_config))
        {
                while(read_file(sprite_config,pos++,text,63,len))
                {
                        len = contain(text,",")
                        if(len == -1) return -1
                        copyc(textblock,strlen(text),text,',')
                        if(equali(textblock,authid))
                        {
                                replace(text,63,textblock,"")
                                replace(text,63,",","")
                                   for(new i = 0 ; i<nbr_sprites-1 ; i++)
                                   {
                                      if(equal(text,sprite_name))
                                                SpriteFlag=i
                                }
                        }
                }
        }
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public death_event()
{
        new dead = read_data(2)
        message_begin(MSG_ALL,SVC_TEMPENTITY)
        write_byte(125)
        write_byte(dead)
        message_end()
        set_task(1.0,"death_clear",dead)
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public death_clear(dead)
{
        message_begin(MSG_ALL,SVC_TEMPENTITY)
        write_byte(125)
        write_byte(dead)
        message_end()
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public reset_hud(id)
{
        new parm
        parm=id
        message_begin(MSG_ALL,SVC_TEMPENTITY)
        write_byte(125)
        write_byte(id)
        message_end()
        set_task(0.5,"showS",481,parm,1)
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
        new sprite_file
        new sprite_config
        get_configsdir(sprite_config, 63)
        format(sprite_config, 63, "%s/sprites_show.txt", sprite_config)
        new spr_temp
        new length

        if (file_exists(sprite_config))
        {
                while(read_file(sprite_config,nbr_sprites++,sprite_file,sizeof(sprite_file),length))
                {
                        format(spr_temp,sizeof(spr_temp),"sprites/%s.spr",sprite_file)
                        format(sprite_name,sizeof(sprite_name),"%s",sprite_file)
                        if (file_exists(spr_temp))
                        {
                                sprite_precached=precache_model(spr_temp)
                        }
                }
        }
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public plugin_init() {
   register_plugin("标记玩家", "1.5", " China")
   register_clcmd("amx_sprite", "sprite", ADMIN_SLAY, "<name/id/wonid/@CT/@TERRORIST/*(all)> <sprite> - shows sprite above player's head")
   register_clcmd("amx_unsprite", "unsprite", ADMIN_SLAY, "<name/id/wonid/@CT/@TERRORIST/*(all)> - removes sprite(s)")
   register_event("DeathMsg", "death_event", "a")
   register_event("ResetHUD", "reset_hud", "be")
   return PLUGIN_CONTINUE
}
是论坛大大修改的版本,原版我没有。。。。。

Enigmaya 发表于 2005-8-26 22:25:14

按我理解的改了,你看看吧,我没测试。。

输入的命令 也改为 amx_spriteidiot直接跟spr的名字


另外等级那个不太确定。。。

ssj4gogeta 发表于 2005-8-26 22:33:23

哦,谢了,学习学习!

ssj4gogeta 发表于 2005-8-26 22:34:28


register_clcmd("amx_sprite", "sprite", ADMIN_LEVEL_H , " <sprite> - shows sprite above player's head")
换成
register_clcmd("amx_sprite", "sprite", 0 , " <sprite> - shows sprite above player's head")
不可以么?

ssj4gogeta 发表于 2005-8-26 22:36:15

另外,这个也是读取sprites_show.txt么?

Enigmaya 发表于 2005-8-26 22:39:25

又改了,你再下来看吧

至于改成0,我也不确定。我也是才研究不到10天而已。。。

Enigmaya 发表于 2005-8-26 22:42:15

Post by ssj4gogeta
另外,这个也是读取sprites_show.txt么?

当然,只照着你要的改的,其他的没动

ssj4gogeta 发表于 2005-8-26 22:47:48

麻烦你了!
页: [1] 2
查看完整版本: 【求助】插件高手进来帮忙,我修改插件遇到困难了