變數怎麼設? 還有運用?

Home Home
引用 | 編輯 m8966338
2013-02-27 22:15
樓主
推文 x0
#include <amxmodx>
#include <amxmisc>


new PLUGIN[] = "test"
new AUTHOR[] = "Lexus"
new VERSION[] = "1.0.0"
new red_win[] = "1"


public plugin_init()
{
 register_clcmd( "/test","ExtraMenu");
 register_plugin(PLUGIN, VERSION, AUTHOR)
}


public ExtraMenu(id)
{
red_win ++ //這加的方式不知道正不正確
set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 12.0)
show_hudmessage(id, red_win) //這邊我不知道對不對,不過我要把它帶入HUD中
}
困擾好久
自己亂弄也弄不好
拜託高手幫幫


順便教我一下如何設一個變數且是全部插件可用的?

獻花 x0
引用 | 編輯 觀眾甲
2013-02-27 22:26
1樓
  
new red_win[33]

red_win[id] ++

show_hudmessage(id, "%d", red_win[id])

獻花 x0
引用 | 編輯 m8966338
2013-02-27 23:31
2樓
  
下面是引用 觀眾甲 於 2013-02-27 22:26 發表的 : 到引言文
new red_win[33]

red_win[id] ++

show_hudmessage(id, "%d", red_win[id])

[id]是指使用指令的玩家?
能否讓它變成全伺服器

獻花 x0
引用 | 編輯 烈Gama英仙座
2013-02-28 07:53
3樓
  
下面是引用 m8966338 於 2013-02-27 23:31 發表的 : 到引言文


[id]是指使用指令的玩家?
能否讓它變成全伺服器



去掉後面[33]


(應該吧??)


有錯請指正

獻花 x0
引用 | 編輯 Nailaz
2013-02-28 08:27
4樓
  
應該是[0]吧
不然就用for迴圈代進去

獻花 x0
引用 | 編輯 八云の橙貓
2013-02-28 12:27
5樓
  
下面是引用 鄭柏昇 於 2013-02-28 08:27 發表的 : 到引言文
應該是[0]吧
不然就用for迴圈代進去



記得好像要讓伺服器共用的話只需要在開頭宣告變數就行了
複製程式
new red_win


之後在已宣告的函數裡增加它即可


*以樓主的示範
複製程式
public ExtraMenu(id)
{
red_win ++ //樓主的增加方式是正確的
set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 12.0)
show_hudmessage(id, "變數當前的值: %d", red_win) 
}


獻花 x0
引用 | 編輯 絕影華
2013-02-28 17:15
6樓
  
複製程式
#include <amxmodx>
#include <amxmisc>


new PLUGIN[] = "test";
new AUTHOR[] = "Lexus";
new VERSION[] = "1.0.0";
new red_win = 1;




public plugin_init() 
{
 register_clcmd( "/test","ExtraMenu");
 register_plugin(PLUGIN, VERSION, AUTHOR);
}




public ExtraMenu(id)
{
 red_win ++;
 set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 12.0);
 how_hudmessage(id, "%i", red_win);
}


獻花 x2