求教:死后复活保留上局武器

Home Home
引用 | 編輯 gkf478
2012-01-07 10:22
樓主
推文 x0
这个是非CSDM类插件。玩家死后只要有一定的权限和一定数额的游戏币,那么输入命令即可复活。但现在有个问题,复活后手里的武器不再是死前所持武器,而是插件设置好的CT为usp和m4,T为glock18和ak。
我想把这个复活后所持有的武器修改为死前的武器,就是说玩家死亡的时候携带的什么武器复活后还是携带什么武器。如果本局内玩家没有复活,等到下局新开始时依旧需要买枪。
麻烦达达们给帮忙改下。谢谢了。
[code][/code]#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#if defined USE_SQL
#include <dbi>
new Sql:mysql,Result:res,host[32],user[32],pass[32],error[128]
//为了不跟其他插件有冲突,数据库名及表名,在这自行定义.
new table[]="bank" //银行插件的数据表名,根据实际情况更改
new db[]="amx"   //银行插件的数据表所在的库名,根据实际情况更改
#else
#if defined unlimited_money
#include <unlimited_money>
#endif
#endif
#define PLUGIN_NAME "Team Respawn"
#define PLUGIN_VERSION "1.1"
#define PLUGIN_AUTHOR "zwfgdlc-zhw"

#define MONEY 8000  //执行个人复活所需的金钱,请自行修改,默认5000
public plugin_init()
{
 register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
 register_clcmd("amx_teamrespawn","team_spawn",ADMIN_LEVEL_G,"Players resurrection")
 #if defined USE_SQL
 set_task(1.0,"sqlinit")
 #endif
 
}
public team_spawn(id,level)
{
 if (!access(id,level))
 {
  client_print(id,print_center,"【服务器提示】你没有【个人复活卡】!")
  console_print(id,"【服务器提示】你没有【个人复活卡】!")
  return PLUGIN_CONTINUE
 }
 if(get_user_team(id)==3)
 {
  client_print(id,print_chat,"【服务器提示】你当前的队伍为观察者,不能使用个人复活功能!")
  client_print(id,print_center,"【服务器提示】你当前的队伍为观察者,不能使用个人复活功能!")
  return PLUGIN_HANDLED;
 }
 if (is_user_alive(id))
 {
  client_print(id, print_chat, "【服务器提示】你还没有牺牲,不需要复活!")
  client_print(id, print_center, "【服务器提示】你还没有牺牲,不需要复活!")
  return PLUGIN_HANDLED;
 }
 
 #if defined USE_SQL
  
 new name[32],deposit
 get_user_name(id,name,31)
 res=dbi_query(mysql,"select amount from `%s` where sid=^"%s^"",table,name);
 
 if(res==RESULT_NONE)
 {
  client_print(id,print_chat,"【服务器提示】你没有银行账户,不能复活!")
  client_print(id,print_center,"【服务器提示】你没有银行账户,不能复活!")
  dbi_free_result(res)
  return PLUGIN_HANDLED;
 }
 
 deposit=dbi_field(res,1)
 if(deposit<MONEY)
 {
  client_print(id,print_chat,"【服务器提示】你的银行存款不足%d元,不能复活!",MONEY)
                client_print(id,print_center,"【服务器提示】你的银行存款不足%d元,不能复活!",MONEY)
  dbi_free_result(res)
  return PLUGIN_HANDLED
 }else{
  dbi_query(mysql,"update `%s` set amount=%d where sid=^"%s^"",table,deposit-MONEY,name)
  dbi_free_result(res)
 }
 #else
 #if defined unlimited_money
 if(cs_get_user_money2(id)<MONEY)
 {
  client_print(id,print_chat,"【服务器提示】你当前的资金不足%d元,不能复活!",MONEY)
  client_print(id,print_center,"【服务器提示】你当前的资金不足%d元,不能复活!",MONEY)
  return PLUGIN_HANDLED;
 }else{
  cs_set_user_money2(id,cs_get_user_money2(id)-MONEY,1)
 }
 #else
 if(cs_get_user_money(id)<MONEY)
 {
  client_print(id,print_chat,"【服务器提示】你当前的资金不足%d元,不能复活!",MONEY)
  client_print(id,print_center,"【服务器提示】你当前的资金不足%d元,不能复活!",MONEY)
  return PLUGIN_HANDLED;
 }else{
  cs_set_user_money(id,cs_get_user_money(id)-MONEY,1)
 }
 #endif
 #endif
 
 spawn(id)
        set_task(0.5,"spawn_player",id)
 new name[32];
 get_user_name(id,name,31);
 set_hudmessage ( 0, 255, 0, 0.29, 0.59, 2, 0.02, 10.0, 0.01, 0.2, -1 );     show_hudmessage (0,"【服务器提示】 %s 使用【个人复活卡】复活了自己!",name);
 client_print(0,print_chat,"【服务器提示】 %s 使用【个人复活卡】复活了自己!",name)
        return PLUGIN_HANDLED
}
public spawn_player(id)
{
 
 ExecuteHam(Ham_CS_RoundRespawn,id);
 give_item(id,"weapon_knife")
 switch(get_user_team(id))
 {
  case 1:
  {
   give_item(id,"weapon_glock18")
   give_item(id,"weapon_ak47")
   cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
   cs_set_user_bpammo(id,CSW_AK47,90)
  }
  case 2 :
  {
   give_item(id,"weapon_usp")
   cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
   give_item(id,"weapon_m4a1")
   cs_set_user_bpammo(id,CSW_M4A1,90)
  }
 }
}
#if defined USE_SQL
public sqlinit()
{
 get_cvar_string("amx_sql_host",host,31)
 get_cvar_string("amx_sql_user",user,31)
 get_cvar_string("amx_sql_pass",pass,31) 
 mysql=dbi_connect(host,user,pass,db,error,127)
 if(mysql==SQL_FAILED)
 {
  server_print("^xCA^xFD^xBE^xDD^xBF^xE2^xC1^xAC^xBD^xD3^xCA^xA7^xB0^xDC^x2C^xC7^xEB^xBC^xEC^xB2^xE9^xC9^xE8^xD6^xC3^xB2^xCE^xCA^xFD^xBB^xF2^xBC^xEC^xB2^xE9^xCD^xF8^xC2^xE7^xC1^xAC^xBD^xD3")
  pause("ad")
 } 
}
public plugin_end()
{
 if(mysql==SQL_OK)
 dbi_close(mysql);
}
#endif

獻花 x0
引用 | 編輯 gkf478
2012-01-07 15:33
1樓
  
顶一顶,期待达人...

獻花 x0
引用 | 編輯 gkf478
2012-01-09 19:44
2樓
  
這問題米人會弄?

獻花 x0