|
楼主 |
发表于 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[32]
- new sprite_name[MAX_SPRITES+1][32]
- new sprite_precached[MAX_SPRITES+1]
- new nbr_sprites=0
- new SpriteFlag[33]
- //----------------------------------------------------------------------------------------------
- public sprite(id, level, cid) {
- if(!cmd_access(id, level, cid, 2))
- return PLUGIN_HANDLED
- new arg1[32]
- read_argv(1, arg1, 31)
- read_argv(2, spritew, 31)
- new test=0
- new id_sprite
- new valid_sprites[128]
- for(new i = 0 ; i<nbr_sprites-1 ; i++)
- {
- if(equal(spritew,sprite_name[i]))
- {
- test++
- id_sprite=i
- }
- if(i>0)
- add(valid_sprites, 127, ",")
- add(valid_sprites, 127, sprite_name[i])
- }
- if(test==0)
- {
- console_print(id, "%s 不是一个有效的标记.", spritew)
- console_print(id, "有效的标记是 :")
- console_print(id, "%s", valid_sprites)
- return PLUGIN_HANDLED
- }
- if(arg1[0] == '@') {
- new users[32], inum
- get_players(users, inum, "ae", arg1[1])
- 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[i])
- message_end()
- new parm[1]
- parm[0] = users[i]
- SpriteFlag[users[i]] = id_sprite
- set_task(0.1,"showS",481,parm,1)
- }
- }
- else if(arg1[0] == '*')
- {
- new users[32], 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[i])
- message_end()
- new parm[1]
- parm[0] = users[i]
- SpriteFlag[users[i]] = 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[uid] != -1)
- {
- message_begin(MSG_ALL,SVC_TEMPENTITY)
- write_byte(125)
- write_byte(uid)
- message_end()
- }
- new parm[1]
- parm[0] = uid
- SpriteFlag[uid] = 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[32]
- read_argv(1, arg, 31)
- if(arg[0] == '@') {
- new users[32], inum
- get_players(users, inum, "e", arg[1])
- 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[i])
- message_end()
- SpriteFlag[users[i]] = -1
- }
- }
- else if(arg[0] == '*')
- {
- new users[32], 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[i])
- message_end()
- SpriteFlag[users[i]] = -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[uid] = -1
- }
- return PLUGIN_HANDLED
- }
- //----------------------------------------------------------------------------------------------
- public showS(parm[])
- {
- new id = parm[0]
- if(is_user_alive(id))
- {
- if(SpriteFlag[id] != -1)
- {
- message_begin(MSG_ALL,SVC_TEMPENTITY)
- write_byte(124)
- write_byte(id)
- write_coord(65)
- write_short(sprite_precached[SpriteFlag[id]])
- write_short(32767)
- message_end()
- }
- }
- return PLUGIN_CONTINUE
- }
- //----------------------------------------------------------------------------------------------
- public showS_loop()
- {
- new players[32], pl_num=0
- get_players(players,pl_num,"a")
- for (new i=0;i<pl_num;i++)
- {
- if(SpriteFlag[players[i]] != -1)
- {
- message_begin(MSG_ALL,SVC_TEMPENTITY)
- write_byte(124)
- write_byte(players[i])
- write_coord(65)
- write_short(sprite_precached[SpriteFlag[players[i]]])
- write_short(32767)
- message_end()
- }
- }
- return PLUGIN_CONTINUE
- }
- //----------------------------------------------------------------------------------------------
- public client_connect(id)
- {
- SpriteFlag[id] = -1
- return PLUGIN_CONTINUE
- }
- //----------------------------------------------------------------------------------------------
- public client_disconnect(id)
- {
- message_begin(MSG_ALL,SVC_TEMPENTITY)
- write_byte(125)
- write_byte(id)
- message_end()
- SpriteFlag[id] = -1
- return PLUGIN_CONTINUE
- }
- //----------------------------------------------------------------------------------------------
- public client_authorized(id)
- {
- new authid[33]
- get_user_authid(id,authid,32)
- new text[64]
- new len
- new pos=0
- new textblock[33]
- new sprite_config[64]
- 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[i]))
- SpriteFlag[id]=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[1]
- parm[0]=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[32]
- new sprite_config[64]
- get_configsdir(sprite_config, 63)
- format(sprite_config, 63, "%s/sprites_show.txt", sprite_config)
- new spr_temp[50]
- 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[nbr_sprites-1],sizeof(sprite_name),"%s",sprite_file)
- if (file_exists(spr_temp))
- {
- sprite_precached[nbr_sprites-1]=precache_model(spr_temp)
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- //----------------------------------------------------------------------------------------------
- public plugin_init() {
- register_plugin("标记玩家", "1.5", "[BenZ] 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
- }
复制代码
是论坛大大修改的版本,原版我没有。。。。。 |
|