[Open]
[Close]
AMXX教學 - 第二章-hello!amxx world(聖誕一日一篇amxx教學)
在前一章說到,我們可以利用#define定義一樣野 並俾佢一個的特別既值
我們亦可以利用register_plugin( const plugin_name[], const version[], const author[] )來註冊個plugin,即係填上資料
今日, 我地將會教你如何係cs的遊戲畫面上顯示字體
以字體黎講,係cs入邊分別有兩種模式顯示 , 一個係原始字字體 , 一種係HUD(即係發光個隻)
我地就可以用例子示範:
我地首先講原始字體
============================================script======================================================
#include <amxmodx>
#define PLUGIN "djai_tutor2"
#define VERSION "2.0"
#define AUTHOR "CReate d ` djai"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd( "say hello","hello_world", ADMIN_ALL, "有hello amxx world 出左黎" )
}
public hello_world(id)
{
client_print( id, print_chat, "hello amxx world")
client_print( id, print_console, "hello amxx world")
client_print( id, print_center, "hello amxx world")
return PLUGIN_HANDLED
}
===================================================script===============================================
解釋:
#include姐係講緊個script入邊要有啲咩, 例如我想食屎, 你首先要#include一個patpat
register_clcmd係註冊一個cmd , 簡單黎講 , 姐係玩家打左個舊野 , 有樣野就會發生
係我地個register_clcmd( "say hello","hello_world", ADMIN_ALL, "有hello amxx world 出左黎" )
只要玩家禁y打hello , 就會有一樣叫hello_world發生(<<個名可以改)
假如唔係"say hello" , 係hello?say其實就係禁y禁解, 如果無左y既話, 禁你就要係console(即係~)到打hello
你會見到係第三個格位("say hello"係第一個, 用豆號分開),即係ADMIN_ALL,你會問, 佢係咩黎?
咁樣講啦,第三個格位係講緊咩人講左hello先會發生野,ADMIN_ALL姐係所有人
A權:ADMIN_IMMUNITY
B權:ADMIN_RESERVATION
我會有個表比你地睇
D仔,但係我唔係剩係俾A權既人用,想俾埋B權既人用
D仔:好簡單,咁你要打ADMIN_IMMUNITY | ADMIN_RESERVATION , 如果你想俾更加多人用
你可以打 ADMIN_IMMUNITY | ADMIN_RESERVATION | 人 | 人 | 人 | 人 | 人 | 人 | 人 | 人 ..........
總之記住用 | 黎分開 , | = AND = 同埋
至於"有hello amxx world 出左黎",佢係一個俾寫插件果條友記寫啲description,總之記住quote住佢就得啦, quote = 引號 = ""
好,跟住
你會見到
public hello_world(id)
{
client_print( id, print_chat, "hello amxx world")
client_print( id, print_console, "hello amxx world")
client_print( id, print_center, "hello amxx world")
return PLUGIN_HANDLED
}
係頭先 , 我地set左發生個樣野叫做 hello_world
所以我地打public hello_world(id)
至於點解係咁 , 無得解, 背左佢唔該(public ????(id))
你會問public plugin_init()同public hello_world(id),點解public hello_world(id)多左個id
問得好,id其實係 = 玩家編號 = index , 玩家入ser個陣時就會自動被分派一個編號 , 例如peter入左ser, 未入前係15/16, 入左後,佢既編號係 15 = id(16/16) ,假如john發脾氣, 走ser, 咁而家就係 15/16 , peter既index = 14(15/16)
你會問 , 點16/16既時 peter係15? 唔係16咩?
其實係amxx入邊 , id = 0-31, 姐係32條友 , 算唔識講 ,你由0-31數手指 ,你睇下最後你舉左幾多隻手指
所以public hello_world(id) = 當假如peter打左hello,hello_world發生左(public hello_world), 個amxx 檢查佢個id(id), 跟住開始發生要發生既野!
發生既野:
client_print( id, print_chat, "hello amxx world")
client_print( id, print_console, "hello amxx world")
client_print( id, print_center, "hello amxx world")
return PLUGIN_HANDLED
client_print係show原始字體俾個玩家睇
第一個格位: id = 頭先知道左係peter打hello = id = peter既編號
第一個格位係講緊係邊個人身上做e個動作, id = 指定一條人, 0= 所有人
第二個格位:print_chat = 顯示既位置 = cs左下講野個位
print_console = 係~到
print_center = 係中間
第三個格位:hello amxx world" = 講既內容 = 記住quote住佢
return PLUGIN_HANDLED = 暫停
return PLUGIN_CONTINUE = 繼續
係我地e個教學上佢無咩特別 , 但係寫到其他野上 ,如hamsandwich , 佢十分重要!!!!!!!!!!!!!
講完 , 頂打咁_多, 打_死我
amx官網解釋:
ADMIN_ALL 0 //Everyone
ADMIN_IMMUNITY 1 //Flag "a", immunity
ADMIN_RESERVATION 2 //Flag "b", reservation
ADMIN_KICK 4 //Flag "c", kick
ADMIN_BAN 8 //Flag "d", ban
ADMIN_SLAY 16 //Flag "e", slay
ADMIN_MAP 32 //Flag "f", map change
ADMIN_CVAR 64 //Flag "g", cvar change
ADMIN_CFG 128 //Flag "h", config execution
ADMIN_CHAT 256 //Flag "i", chat
ADMIN_VOTE 512 //Flag "j", vote
ADMIN_PASSWORD 1024 //Flag "k", sv_password
ADMIN_RCON 2048 //Flag "l", rcon access
ADMIN_LEVEL_A 4096 //Flag "m", custom
ADMIN_LEVEL_B 8192 //Flag "n", custom
ADMIN_LEVEL_C 16384 //Flag "o", custom
ADMIN_LEVEL_D 32768 //Flag "p", custom
ADMIN_LEVEL_E 65536 //Flag "q", custom
ADMIN_LEVEL_F 131072 //Flag "r", custom
ADMIN_LEVEL_G 262144 //Flag "s", custom
ADMIN_LEVEL_H 524288 //Flag "t", custom
ADMIN_MENU 1048576 //Flag "u", menus
ADMIN_ADMIN 16777216 //Flag "y", default admin
ADMIN_USER 33554432 //Flag "z", default user
睇唔明英文自己查字典 , 不過學amxx , 英文唔好 ,會學得好辛苦 , e度啲英文已經係最簡單
=========================================================================================================
register_clcmd - Registers function which will be called from client console
Syntax:
register_clcmd( const client_cmd[],const function[],flags=-1, info[]="" )
Type:
Native
=========================================================================================================
client_print - Sends a message to a player.
Syntax:
client_print( index, type, const message[], ... )
Type:
Native
Notes:
id is a player index from 1 to 32.(雖然話係0-31,但係去到amx中心到會自己轉番1-32) If 0, the message will be sent to all players.
The type is one of three types:
print_chat - chat text
print_console - console message
print_notify - console in dev mode
print_center - center say
打得好辛苦呀頂!(tony唔好del前一篇,因為我想一連串教學俾人睇)
[ 本帖最後由 davidto1995 於 2010-12-23 13:42 編輯 ]