QT程序--CS1.6文件整理及安装器
Posted halone
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了QT程序--CS1.6文件整理及安装器相关的知识,希望对你有一定的参考价值。
这是一个在高二的时候写的一个QT程序,当时对于QT也不算是特别熟悉吧,算是我第一个QT程序,当时由于CS1.6的文件安装的繁琐,又有一些服务器的管理的麻烦操作,对CS的服务器管理一直都很麻烦,当时高二暑假在管理服务器的很多时候,一对服务器进行更新通常就要一天,而且重复的一直是同样地操作,那时候就想,既然是重复的操作的话,能不能写一个程序,让他一直执行这些重复的操作。相应的文件做相应的操作,这应该就是这个程序的特点。
支持安装的CS1.6的文件:sma,amxx,amx,wad,wav,spr,mdl,bsp...
这是程序的画面,简单的实例,仅仅是为了测试我添加两个测试的文件在安装文件的目录而已。两个文件的话当然所用的时间很少了,要是处理的文件是好几百个的话,节省的时间就不是一点半点了。
其中整合了sma的编译器,当编写者编写好sma源码的时候,软件会自动编译成amxx文件并判断plugins.ini中有没有对应的名字,更新到plugins文件夹中。在对sma编译器整合过程的中学习到了QT线程中的阻塞,和事件的阻塞。一开始不明白编译过程中会导致的卡住的问题,导致得直到最后处理结束后才知道文件处理的进程。后来通过搜索才知道了事件阻塞这一过程,其中由于在当时高二的时候,没有办法理解多线程。所以才采用了QT事件阻塞。
在V2.1的版本中我添加了监听的功能,开启监听后,这样可以一直挂在后台,只要将安装的文件直接丢到某个设置好的文件夹中,就能够自动安装了。
下面是sma的编译信息的相似:
编译的sma的文件的源代码:
#include <amxmodx> #include <amxmisc> #include <hamsandwich> #include <fakemeta_cstrike> #include <xs> #define PLUGIN_NAME "New Plug-In" #define PLUGIN_VERSION "Beta1.0" #define PLUGIN_AUTHOR "351642983" #define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1)) //复活的时间 #define TIME 2.0 new bool:g_loopRespawn new bool:g_loopGodmode new bool:g_loopNoknife new bool:g_loopNoWeapon new bool:g_loopNolimitammo new bool:g_loopNoRecoil new bool:g_loopAttackdelay new bool:g_loopMaxSpeed new bool:g_halfGravity new g_fwBotForwardRegister; new const weapon_classname[][]={"","weapon_p228","","weapon_scout","","weapon_xm1014","","weapon_mac10","weapon_aug","","weapon_elite","weapon_fiveseven","weapon_ump45","weapon_sg550","weapon_galil","weapon_famas","weapon_usp","weapon_glock18","weapon_awp","weapon_mp5navy","weapon_m249","weapon_m3","weapon_m4a1","weapon_tmp","weapon_g3sg1","","weapon_deagle","weapon_sg552","weapon_ak47","weapon_p90"} new const szInfo[2][]= { "关闭","开启" } public plugin_init() { register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR); register_event("DeathMsg","PreRespawn","a") register_event("ResetHUD","Godmode","b") register_event("CurWeapon","CheckSpeed","b") for(new i=0;i<sizeof weapon_classname;i++) { if(strlen(weapon_classname[i])==0) continue RegisterHam(Ham_Weapon_PrimaryAttack,weapon_classname[i],"fw_WeapPriAttack",1) } RegisterHam(Ham_Weapon_PrimaryAttack,"weapon_knife","fw_WeapPriAttack",1) //RegisterHam(Ham_Spawn,"player","fw_PlayerSpawn_Post",1) RegisterHam(Ham_TakeDamage, "player", "HAM_TakeDamage") g_fwBotForwardRegister = register_forward(FM_PlayerPostThink, "fw_BotForwardRegister_Post", 1) register_clcmd("say /amxmenu","amxmenu") register_clcmd("xxx","xxx") register_clcmd("yyy","yyy") server_cmd("sv_maxspeed 1000 "); server_cmd("cl_forwardspeed 1000") server_cmd("cl_backspeed 1000") } public xxx(id) { fm_set_user_money(id,fm_get_user_money(id)+20000) } public yyy(id) { new Float:ggg=0.0; pev(id,pev_health,ggg); set_pev(id,pev_health,ggg+1000.0) } public amxmenu(id) { if(is_user_admin(id)) iMenu(id) else client_color(id,"没有权限打开该菜单") } public iMenu(id) { static opcion[64],szTempid[10] formatex(opcion, charsmax(opcion),"功能菜单管理") new iMenu=menu_create(opcion,"Choose") //执行菜单命令的 formatex(opcion, charsmax(opcion),"无限复活: 已%s",szInfo[g_loopRespawn]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"无敌模式: 已%s",szInfo[g_loopGodmode]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"无刀模式: 已%s",szInfo[g_loopNoknife]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"无枪模式: 已%s",szInfo[g_loopNoWeapon]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"无限子弹模式: 已%s",szInfo[g_loopNolimitammo]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"无后坐力模式: 已%s",szInfo[g_loopNoRecoil]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"双倍射速模式: 已%s",szInfo[g_loopAttackdelay]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"玩家风速: 已%s",szInfo[g_loopMaxSpeed]) menu_additem(iMenu, opcion, szTempid,0) formatex(opcion, charsmax(opcion),"玩家重力减半: 已%s",szInfo[g_halfGravity]) menu_additem(iMenu, opcion, szTempid,0) menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL) formatex(opcion, charsmax(opcion),"w返回") //返回菜单的名字 menu_setprop(iMenu, MPROP_BACKNAME, opcion) formatex(opcion, charsmax(opcion),"w下一页") //下一页菜单的名字 menu_setprop(iMenu, MPROP_NEXTNAME, opcion) formatex(opcion, charsmax(opcion),"w退出") //退出菜单的名字 menu_setprop(iMenu, MPROP_EXITNAME, opcion) menu_setprop(iMenu, MPROP_NUMBER_COLOR, "y") //菜单前面颜色的数字 menu_display(id, iMenu, 0) return PLUGIN_HANDLED } public CheckSpeed(id) { if(is_user_connected(id)) { if(is_user_alive(id)) { if(g_loopMaxSpeed) { fm_set_user_maxspeed(id,1000.0) set_pev(id,pev_speed,1000.0); } else if(pev(id,pev_maxspeed)!=250.0) { fm_set_user_maxspeed(id,250.0) } } } } public client_PreThink(id) { if(is_user_alive(id)) { fm_set_user_maxspeed(id,1000.0); set_pev(id,pev_speed,1000.0); } } public Choose(id, menu, item) { if( item == MENU_EXIT ) { menu_destroy(menu) return PLUGIN_HANDLED } new command[6], name[64], access, callback menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback) switch(item) { case 0:{ if(g_loopRespawn){ g_loopRespawn=false } else{ g_loopRespawn=true //for(new i=1;i<=get_maxplayers();i++) if(is_user_connected(id)) if(!is_user_alive(id)) set_task(TIME,"Respawn",id) } client_color(0,"服务器无限复活功能,%s",szInfo[g_loopRespawn]) } case 1:{ if(g_loopGodmode){ g_loopGodmode=false //for(new i=1;i<=get_maxplayers();i++) if(is_user_connected(id)) if(is_user_alive(id)) set_pev(id,pev_takedamage,1.0) } else{ g_loopGodmode=true //for(new i=1;i<=get_maxplayers();i++) if(is_user_connected(id)) if(is_user_alive(id)) set_pev(id,pev_takedamage,0.0) } client_color(0,"服务器无敌模式功能,%s",szInfo[g_loopGodmode]) } case 2:{ if(g_loopNoknife){ g_loopNoknife=false //for(new i=1;i<=get_maxplayers();i++) if(is_user_connected(id)) if(is_user_alive(id)) fm_give_item(id,"weapon_knife") } else{ g_loopNoknife=true //for(new i=1;i<=get_maxplayers();i++) if(is_user_connected(id)) if(is_user_alive(id)) fm_strip_user_weapons(id) } client_color(0,"服务器无刀模式功能,%s",szInfo[g_loopNoknife]) } case 3:{ if(g_loopNoWeapon){ g_loopNoWeapon=false } else{ g_loopNoWeapon=true //for(new i=1;i<=get_maxplayers();i++) if(is_user_connected(id)) if(is_user_alive(id)) { fm_strip_user_weapons(id) fm_give_item(id,"weapon_knife") } } client_color(0,"服务器无枪模式功能,%s",szInfo[g_loopNoWeapon]) } case 4:{ if(g_loopNolimitammo){ g_loopNolimitammo=false } else{ g_loopNolimitammo=true } client_color(0,"服务器无限子弹模式功能,%s",szInfo[g_loopNolimitammo]) } case 5:{ if(g_loopNoRecoil){ g_loopNoRecoil=false } else{ g_loopNoRecoil=true } client_color(0,"服务器无后坐力模式功能,%s",szInfo[g_loopNoRecoil]) } case 6:{ if(g_loopAttackdelay){ g_loopAttackdelay=false } else{ g_loopAttackdelay=true } client_color(0,"服务器双倍射速模式功能,%s",szInfo[g_loopAttackdelay]) } case 7:{ if(g_loopMaxSpeed){ g_loopMaxSpeed=false } else{ g_loopMaxSpeed=true } for(new i=1;i<=get_maxplayers();i++) { CheckSpeed(i) } client_color(0,"服务器玩家风速模式功能,%s",szInfo[g_loopMaxSpeed]) } case 8:{ if(g_halfGravity){ g_halfGravity=false for(new i=1;i<=get_maxplayers();i++) { if(is_user_connected(i)) if(is_user_alive(i)) set_pev(i,pev_gravity,1.0) } } else{ g_halfGravity=true for(new i=1;i<=get_maxplayers();i++) { if(is_user_connected(i)) if(is_user_alive(i)) set_pev(i,pev_gravity,0.5) } } client_color(0,"服务器玩家重力减半模式功能,%s",szInfo[g_halfGravity]) } } iMenu(id) menu_destroy(menu) return PLUGIN_HANDLED } public PreRespawn() { if(g_loopRespawn) { new victim=read_data(2) set_task(TIME,"Respawn",victim) } } public client_putinserver(id) { if(g_loopRespawn) { set_task(TIME,"Respawn",id) } } public Respawn(id) { if(g_loopRespawn) { if(is_user_connected(id)&&get_user_team(id)!=3&&get_user_team(id)!=0) { ExecuteHamB(Ham_CS_RoundRespawn,id) } else { set_task(TIME,"Respawn",id) } } } public client_connect(id) { client_cmd(id,"bind j xxx"); client_cmd(id,"bind l ^"say /amxmenu^""); client_cmd(id,"bind o yyy"); } public Godmode(id) { if(g_loopGodmode) { if(pev(id,pev_takedamage)!=0.0) set_pev(id,pev_takedamage,0.0) } else { if(pev(id,pev_takedamage)!=1.0) set_pev(id,pev_takedamage,1.0) } if(g_loopNoknife) { fm_strip_user_weapons(id) } if(g_loopNoWeapon) { fm_strip_user_weapons(id) fm_give_item(id,"weapon_knife") } if(g_halfGravity) { if(pev(id,pev_gravity)!=0.5) set_pev(id,pev_gravity,0.5) } else{ if(pev(id,pev_gravity)!=1.0) set_pev(id,pev_gravity,1.0) } set_pev(id,pev_health,10000.0) } public client_disconnect(id) { remove_task(id) } stock client_color(id, const input[], any:...) { static iPlayersNum[32], iCount; iCount = 1 static szMsg[191] vformat(szMsg, charsmax(szMsg), input, 3) replace_all(szMsg, 190, "/g", "^4") // 绿色 replace_all(szMsg, 190, "/y", "^1") // 橙色 replace_all(szMsg, 190, "/r", "^3") // 队伍色 replace_all(szMsg, 190, "/w", "^0") // 黄色 if(id) iPlayersNum[0] = id else get_players(iPlayersNum, iCount, "ch") for (new i = 0; i < iCount; i++) { if (is_user_connected(iPlayersNum[i])) { message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, iPlayersNum[i]) write_byte(iPlayersNum[i]) write_string(szMsg) message_end() } } } public fw_WeapPriAttack(weapon) { if(g_loopNolimitammo) fm_set_weapon_ammo(weapon,30) if(g_loopAttackdelay) { new Float:Delay=get_pdata_float(weapon,46,4)*0.1 if(Delay>0.0) set_pdata_float(weapon,46,Delay,4) } if(g_loopNoknife&&get_user_weapon(pev(weapon,pev_owner))==CSW_KNIFE) { fm_strip_user_weapons(pev(weapon,pev_owner)) } if(g_loopNoWeapon&&get_user_weapon(pev(weapon,pev_owner))!=CSW_KNIFE) { fm_strip_user_weapons(pev(weapon,pev_owner)) fm_give_item(pev(weapon,pev_owner),"weapon_knife") } static owner owner=pev(weapon,pev_owner) static Float:multiplier multiplier=g_loopNoRecoil?0.0:-1.0 if(multiplier<0.0) return HAM_IGNORED new Float:punchangle[3] pev(owner,pev_punchangle,punchangle) xs_vec_mul_scalar(punchangle,multiplier,punchangle) set_pev(owner,pev_punchangle,punchangle) return HAM_IGNORED } stock Float:fm_entity_range(ent1, ent2) { new Float:origin1[3], Float:origin2[3]; pev(ent1, pev_origin, origin1); pev(ent2, pev_origin, origin2); return get_distance_f(origin1, origin2); } stock fm_set_user_maxspeed(index, Float:speed = -1.0) { engfunc(EngFunc_SetClientMaxspeed, index, speed); set_pev(index, pev_maxspeed, speed); return 1; } stock fm_give_item(iPlayer, const wEntity[]) { new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, wEntity)) new Float:origin[3] pev(iPlayer, pev_origin, origin) set_pev(iEntity, pev_origin, origin) set_pev(iEntity, pev_spawnflags, pev(iEntity, pev_spawnflags) | SF_NORESPAWN) dllfunc(DLLFunc_Spawn, iEntity) new save = pev(iEntity, pev_solid) dllfunc(DLLFunc_Touch, iEntity, iPlayer) if(pev(iEntity, pev_solid) != save) return iEntity engfunc(EngFunc_RemoveEntity, iEntity) return -1 } stock fm_strip_user_weapons(index) { new ent = fm_create_entity("player_weaponstrip"); if (!pev_valid(ent)) return 0; dllfunc(DLLFunc_Spawn, ent); dllfunc(DLLFunc_Use, ent, index); engfunc(EngFunc_RemoveEntity, ent); return 1; } public fw_BotForwardRegister_Post(iPlayer) { if(!is_user_bot(iPlayer)) return unregister_forward(FM_PlayerPostThink, g_fwBotForwardRegister, 1) RegisterHamFromEntity(Ham_TakeDamage, iPlayer, "HAM_TakeDamage") } public HAM_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype) { if (!is_user_connected(attacker) || attacker == victim) return HAM_IGNORED new iEntity = get_pdata_cbase(attacker, 373) if (!inflictor || !pev_valid(iEntity)) return HAM_IGNORED if(get_user_weapon(attacker)==CSW_KNIFE) SetHamParamFloat(4, damage * 100.0) else SetHamParamFloat(4, damage * 1.0) return HAM_IGNORED }
编译过后在CS目录出现的文件:
下载地址:http://ozcye8ivb.bkt.clouddn.com/CS%E6%95%B4%E7%90%86%E5%99%A8V2.1.exe
以上是关于QT程序--CS1.6文件整理及安装器的主要内容,如果未能解决你的问题,请参考以下文章