下面是引用 Rubbish-Nec 於 2009-12-29 01:10 發表的 又是請大大看看我的sma:
請看看吧
#include <amxmodx> #include <cstrike> new g_mac_cost public plugin_init() { register_plugin ("Buy Mac" , "1.0" , "Rubbish.Nec") register_clcmd ( "say /buymac" , "buy_mac" ) g_mac_cost = register_cvar ( "amx_mac_cost" , "16000" ) } public buy_mac(id) { if (!is_user_alive (id) || !is_user_connected (id)) { new money = cs_get_user_money(id) if (money < g_mac_cost) { give_item( id , "weapon_mac10" ) cs_set_user_money ( id , money - g_mac_cost ) } else { client_print( id , print_chat , "你不夠錢。" ) } } } [/pre]
我怎麼覺得你邏輯條件假設相反了…?
我是改這樣:
#include <amxmodx>
#include <cstrike>
new g_mac_cost
public plugin_init()
{
register_plugin ("Buy Mac" , "1.0" , "Rubbish.Nec")
register_clcmd ( "say /buymac" , "buy_mac" )
g_mac_cost = register_cvar ( "amx_mac_cost" , "16000" )
}
public buy_mac(id)
{
if (!is_user_alive (id) || !is_user_connected (id))
{
new money = cs_get_user_money(id)
if (money <
get_pcvar_num(g_mac_cost
))
{
client_print( id , print_chat , "你不夠錢。" )
return;
}
give_item( id , "weapon_mac10" )
cs_set_user_money ( id , money -
get_pcvar_num(g_mac_cost
) )
}
}
話說…乾脆問插件能不能像槍模一樣開個研究區算了…
感覺插件的語法都還要跑來提問區問…
搞不好開個「插件研究區」後yymmychat大就能教一些很好用的語法呢~