|
楼主 |
发表于 2013-5-14 20:16:10
|
显示全部楼层
来自 中国–河北–保定
本帖最后由 刘半仙【仙】 于 2013-5-14 20:42 编辑
特提供源码:
望批评指正
渣作勿喷
版权保留- /*---------------------
- 半仙出品
- 1.模型替换为开局替换,玩家选择后不是立即替换
- 2.替换模型为一组,即一组模型对于CT 和T 2个模型
- 3.判别模型方法, 存取选择对于的T模型文件名字 判断玩家为CT将T模型文件+"C" 转换
-
- ----------------------*/
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #define PLUGIN_NAME "modchoose"
- #define PLUGIN_VERSION "2.2.1"
- #define PLUGIN_AUTHOR "kyo"
- new playermod[32][32],alreadyChoose[32],bool:Is_choosed[33],bool:Round_choosed[33]
- //模型准备名字
- new menuitem[4][] = {"草薙京兄弟","黑白精灵MM","中国特警队","换原始模型"} //3套替换模型 修改前3项名字即可
- new prepmod[3][] = {"1_T","2_T","4_T"} // 模型mdl文件名字 ,T模型的名字 CT模型名字为T模型名字+“C”
- public plugin_init()
- {
- register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
- server_print("^n^t==========================================================^n^t %s %s, Copyright (C) 2012 by %s^n^t==========================================================^n",PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_AUTHOR);
- register_clcmd("say skin","selecmenu")
- register_event("ResetHUD", "resetModel", "b")
- }
- /*---------------------
- 模型加载
- 备注: CT的模型为 T模型名字加一个C
-
- ----------------------*/
- public plugin_precache() {
- //第一组 - 草薙京兄弟
- precache_model("models/player/1_T/1_T.mdl")
- precache_model("models/player/1_TC/1_TC.mdl")
- //黑白精灵MM
- precache_model("models/player/2_T/2_T.mdl")
- precache_model("models/player/2_TC/2_TC.mdl")
- //中国特警队
- precache_model("models/player/4_T/4_T.mdl")
- precache_model("models/player/4_TC/4_TC.mdl")
- return PLUGIN_CONTINUE
- }
- /*---------------------
- 菜单区
- ----------------------*/
- public selecmenu(id)
- {
- new Message[126]
- if(get_user_flags(id) & ADMIN_LEVEL_F)
- {
- new menu = menu_create("\r模型菜单", "Select");
- /* 菜单选项*/
- for(new a = 0;a<4;a++)
- { new tmp[126],num[5]
- num_to_str(a+1, num, 4);
- if(a == alreadyChoose[id]){
- format(tmp,125,"\d%s(\r已选择\d)",menuitem[a])
- }
- else{
- format(tmp,125,"\w%s",menuitem[a])
- }
- menu_additem(menu, tmp, num, 0);
- }
- /*end*/
- menu_setprop(menu, MPROP_EXITNAME, "\y退出菜单");
- if(Round_choosed[id] == true)
- {
- format(Message, 125, "^x04|灬FourKing灬|提示:^x01____一局只能选择一次");
- client_color(id, id,Message)
- }
- else{
- menu_display(id, menu, 0);
- }
- }
- else
- {
- format(Message, 125, "^x04|灬FourKing灬|提示:^x01你没有这个权限,群号:37061111");
- client_color(id, id,Message)
- }
- return PLUGIN_HANDLED;
- }
- public Select(id, menu, item)
- {
- new szMessage[256],name[32]
- get_user_name(id,name,31)
- new data[9], iName[64];
- new access, callback;
-
- menu_item_getinfo(menu, item, access, data,9, iName, 63, callback);
- new key = str_to_num(data);
- switch(key)
- {
- case 4:
- {
- if(Is_choosed[id]){
- Is_choosed[id] = false
- alreadyChoose[id]= -1
- format(szMessage, 255, "^x04|灬FourKing灬|:^x01^x03%s^x01^x04更换为^x03原始模型",name);
- client_color(0, id,szMessage)
- }
- else
- {
- format(szMessage, 255, "^x04|灬FourKing灬|:^x01没有选择皮肤,^x03%s^x01^x04不用更换",name);
- client_color(id, id,szMessage)
- }
-
- }
- default:
- { new chooseitem = key - 1 //转换为数组索引
- if(alreadyChoose[id] == chooseitem){
- menu_display(id, menu, 0);
- }
- else{
- if(chooseitem <3 && chooseitem >=0){
- alreadyChoose[id] = chooseitem
- // 准备模型
- new modname[16]
- format(modname,15,"%s",prepmod[chooseitem])
- playermod[id] = modname
- Is_choosed[id] = true
- Round_choosed[id] = true
- format(szMessage, 255, "^x04|灬FourKing灬|:^x01^x03%s^x01^x04更换模型为^x03|%s|",name,menuitem[chooseitem]);
- client_color(0, id,szMessage)
- }
- else{
- log_amx("[modchoose]准备数组超出索引范围")
- }
- }
- }
-
- }
-
-
- }
- /*---------------------
- 模型置换(开局)
- ----------------------*/
- public resetModel(id, level, cid) {
- if (get_user_flags(id) & ADMIN_LEVEL_F)
- {
- new CsTeams:userTeam = cs_get_user_team(id)
- if (Is_choosed[id] == true && userTeam == CS_TEAM_T)
- {
- cs_set_user_model(id, playermod[id])
- }
- else if (Is_choosed[id] == true && userTeam == CS_TEAM_CT)
- {
- new tmp[32]
- format(tmp,31,"%sC", playermod[id]) // 转换为CT需要的模型字符 +“c”
- cs_set_user_model(id, tmp)
- }
- else
- {
- cs_reset_user_model(id)
- }
- }
- else
- {
- cs_reset_user_model(id)
- }
-
- if(Round_choosed[id])
- {
- Round_choosed[id] = false;
- }
- return PLUGIN_CONTINUE
- }
- /*---------------------
- 其他
- ----------------------*/
- public client_authorized(id)
- {
-
- Is_choosed[id] = false;
- Round_choosed[id] = false;
- alreadyChoose[id] = -1
- }
- public client_disconnect(id)
- {
- if(Is_choosed[id])
- Is_choosed[id] = false;
- if(Round_choosed[id])
- Round_choosed[id] = false;
- if(alreadyChoose[id] != -1)
- alreadyChoose[id] = -1;
- }
- public client_color(playerid, colorid, msg[]){
- message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),{0,0,0},playerid)
- write_byte(colorid)
- write_string(msg)
- message_end()
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注个册吧
×
|