Angr
Известный
- 291
- 99
Описание: enum в мире Lua, а то много делают страшных вещей в коде и сами путаются
Пример использования:
Lua:
function enum( name )
return function( array )
for i, v in ipairs( array ) do
_G[ v ] = i
end
end
end
Lua:
enum "dialogStyles" {
"DIALOG_STYLE_MSGBOX",
"DIALOG_STYLE_INPUT",
"DIALOG_STYLE_LIST",
"DIALOG_STYLE_PASSWORD",
"DIALOG_STYLE_TABLIST",
"DIALOG_STYLE_TABLIST_HEADERS",
}
local type = sampGetCurrentDialogType()
if type == DIALOG_STYLE_LIST then
-- TODO: ...
end
-- Пример 2
enum "adminRights" {
"PLAYER_KICK",
"PLAYER_BAN",
"PLAYER_MUTE",
"PLAYER_FREEZE",
"PLAYER_SHOUT",
"PLAYER_SET_HEALTH",
"PLAYER_SET_ARMOUR",
"PLAYER_SET_SKIN",
"PLAYER_SET_MONEY",
"PLAYER_SET_STAT",
"PLAYER_SET_TEAM",
"PLAYER_SET_INTERIOR",
"PLAYER_SET_DIMENSION",
"PLAYER_JETPACK",
"PLAYER_SET_GROUP",
"PLAYER_GIVE_VEHICLE",
"PLAYER_GIVE_WEAPON",
"PLAYER_SLAP",
"PLAYER_WARP",
"PLAYER_WARP_TO"
}
print( PLAYER_WARP_TO ) -- выведет 20
Последнее редактирование: