Cに投稿されたコード一覧

C sdl_sample

function sdl_sample()
{
	local s = sdl_window_create("SDL from Squirrel")
	local rect = {x = 80, y = 40, w = 640, h = 480}
	sdl_window_rect_set(s, rect)
	sdl_window_show(s)
	while(sdl_vsync_wait(s) == false);
	sdl_window_destroy(s)
}

C sdlbase.c

#include <assert.h>
#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <squirrel.h>
#include "squirrel_wrap.h"

#define sqfunc_argment_test(V, NUM) \
	if(sq_gettop(V) != ((NUM) + 1)){ \
		sq_throwerror(v, "arguments num is must be " #NUM); \
		sq_settop(v, 1); \
		return SQ_ERROR; \
	}

struct sdl_member{
	SDL_Window *w;
	SDL_Renderer *r;
};
static SQInteger sq_sdl_init(HSQUIRRELVM v)
{
	SDL_SetMainReady();
	SDL_Init(SDL_INIT_VIDEO);
	return 0;
}

static SQInteger sq_sdl_quit(HSQUIRRELVM v)
{
	SDL_Quit();
	return 0;
}

static SQInteger sq_sdl_window_create(HSQUIRRELVM v)
{
	SQInteger top = sq_gettop(v);
	const SQChar *windowname = "SDL window";
	if(top > 3){
		sq_throwerror(v, "arguments num is must be 1 or 2");
		return SQ_ERROR;
	}
	if(top == 2){
		if(qr_string_get(v, 2, &windowname) == SQFalse){
			return SQ_ERROR;
		}
	}
	SDL_Window *w = SDL_CreateWindow(windowname, 100, 100, 100, 100, SDL_WINDOW_HIDDEN);
	SDL_Renderer *r = SDL_CreateRenderer(w, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
	SDL_SetRenderDrawBlendMode(r, SDL_BLENDMODE_BLEND);
	if(w == NULL || r == NULL){
		sq_throwerror(v, "SDL window initial error");
		return SQ_ERROR;
	}
	struct sdl_member *t = malloc(sizeof(struct sdl_member));
	t->w = w;
	t->r = r;
	sq_pushuserpointer(v, t);
	return 1;
}
static struct sdl_member *sdl_member_userpointer_get(HSQUIRRELVM v)
{
	SQUserPointer w;
	if(SQ_FAILED(sq_getuserpointer(v, -1, &w))){
		return NULL;
	}
	sq_pop(v, 1);
	struct sdl_member *s = w;
	return s;
}

static SQInteger sq_sdl_window_destroy(HSQUIRRELVM v)
{
	sqfunc_argment_test(v, 1);
	struct sdl_member *t = sdl_member_userpointer_get(v);
	SDL_DestroyRenderer(t->r);
	SDL_DestroyWindow(t->w);
	free(t);

	return 0;
}
static SQInteger sq_sdl_window_show(HSQUIRRELVM v)
{
	struct sdl_member *t = sdl_member_userpointer_get(v);
	SDL_ShowWindow(t->w);
	return 0;
}
static SQInteger sq_sdl_window_hide(HSQUIRRELVM v)
{
	struct sdl_member *t = sdl_member_userpointer_get(v);
	SDL_HideWindow(t->w);
	return 0;
}

static void table_member_int_set(HSQUIRRELVM v, const SQChar *name, SQInteger val)
{
	sq_pushstring(v, name, -1);
	sq_pushinteger(v, val);
	sq_newslot(v, -3, SQFalse);
}

static SQInteger sq_sdl_window_rect_get(HSQUIRRELVM v)
{
	sqfunc_argment_test(v, 1);
	struct sdl_member *t = sdl_member_userpointer_get(v);
	int x, y, w, h;
	SDL_GetWindowPosition(t->w, &x, &y);
	SDL_GetWindowSize(t->w, &w, &h);
	sq_newtable(v);

	table_member_int_set(v, "x", x);
	table_member_int_set(v, "y", y);
	table_member_int_set(v, "w", w);
	table_member_int_set(v, "h", h);
	return 1;
}
static SQInteger sq_sdl_window_rect_set(HSQUIRRELVM v)
{
	sqfunc_argment_test(v, 2);
	int x, y, w, h;
	if(qr_member_int_get(v, "x", &x) == SQFalse){
		sq_throwerror(v, "table x get error");
		return SQ_ERROR;
	}
	if(qr_member_int_get(v, "y", &y) == SQFalse){
		sq_throwerror(v, "table y get error");
		return SQ_ERROR;
	}
	if(qr_member_int_get(v, "w", &w) == SQFalse){
		sq_throwerror(v, "table w get error");
		return SQ_ERROR;
	}
	if(qr_member_int_get(v, "h", &h) == SQFalse){
		sq_throwerror(v, "table h get error");
		return SQ_ERROR;
	}
	sq_pop(v, 1);
	struct sdl_member *t = sdl_member_userpointer_get(v);
	assert(t != NULL);
	SDL_SetWindowPosition(t->w, x, y);
	SDL_SetWindowSize(t->w, w, h);
	return 0;
}
static SQInteger sq_sdl_vsync_wait(HSQUIRRELVM v)
{
	SDL_Event e;
	SQBool eend = SQFalse;
	while(SDL_PollEvent(&e) != 0){
		if(e.type == SDL_QUIT || (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_q)){
			eend = SQTrue;
		}
		//ここどうしましょう
/*		if(e.type == SDL_KEYDOWN){
			switch(e.key.keysym.sym){
			case SDLK_r:
				plot_redraw = 1;
				break;
			}
		}*/
	}
	sq_pushbool(v, eend);
	return 1;
}
static SQInteger sq_sdl_mainscreen_update(HSQUIRRELVM v)
{
	sqfunc_argment_test(v, 3);
	struct sdl_member *t = sdl_member_userpointer_get(v);
	int n = SDL_SetRenderTarget(t->r, NULL);
	assert(n == 0);
/*	if(n < 0){
		puts(SDL_GetError());
		assert(0);
		break;
	}*/
	//atode kesu
	SDL_SetRenderDrawColor(t->r, 0, 0x3f, 0x3f, 0xff);
	SDL_RenderClear(t->r);
	if(sq_gettype(v, -1) != OT_ARRAY){
		sq_pop(v, 1);
		sq_throwerror(v, "texture is not array");
		return SQ_ERROR;
	}
	SQBool bb = SQFalse;
	for(SQInteger i = 0; i < sq_getsize(v, -1); i++){
		sq_pushinteger(v, i);
		if(SQ_FAILED(sq_get(v, -2))){
			bb = SQTrue;
			break;
		}
		SQUserPointer w;
		if(SQ_FAILED(sq_getuserpointer(v, -1, &w))){
			bb = SQTrue;
			break;
		}
		sq_pop(v, 1);

		SDL_RenderCopy(t->r, (SDL_Texture *) w, NULL, NULL);
	}
	sq_pop(v, 1);
	if(bb == SQTrue){
		sq_throwerror(v, "texture is not userpointer");
		return SQ_ERROR;
	}
	SDL_RenderPresent(t->r);
	return 0;
}
const struct sq_funclist sdl_function[] = {
	{sq_sdl_init, "sdl_init"},
	{sq_sdl_quit, "sdl_quit"},
	{sq_sdl_window_create, "sdl_window_create"},
	{sq_sdl_window_destroy, "sdl_window_destroy"},
	{sq_sdl_window_rect_get, "sdl_window_rect_get"},
	{sq_sdl_window_rect_set, "sdl_window_rect_set"},
	{sq_sdl_window_show, "sdl_window_show"},
	{sq_sdl_window_hide, "sdl_window_hide"},
	{sq_sdl_vsync_wait, "sdl_vsync_wait"},
	{sq_sdl_mainscreen_update, "sdl_mainscreen_update"},
	{NULL, NULL}
};

C s

/*
Super Real Marjong P3 static video emulator
*/
class p3_sprite_1 extends raster_image{
	m_visible_area = {x = 511, y = 28 - 1, width = 384 + 1, height = 224 + 1}
	m_charcter = null; m_map = null; m_color = null;
	function map_init(vram, charbank){
		local map = []
		for(local i = 0; i < 0x200; i++){
			local attr = {y_pos = 0, y_flip = 0, x_pos = 0, x_flip = 0, color = 0, charcter = 0, bank = 0}
			attr.y_pos = vram[i] ^ 0xff
			attr.charcter = vram[0x1000 + i]
			attr.x_pos = vram[0x1200 + i]
			attr.x_flip = vram[0x3000 + i] & 0x80 ? 0x1ff : 0
			attr.y_flip = vram[0x3000 + i] & 0x40 ? 0xff : 0
			attr.bank = onebit_move(vram[0x3000 + i], 5, 0)
			attr.charcter = attr.charcter | ((vram[0x3000 + i] & 0x1f) << 8)
			if(attr.bank != 0){
				attr.charcter = attr.charcter | ((charbank +1) << 13)
			}
			attr.color = vram[0x3200 + i] >>> 3
			attr.x_pos = attr.x_pos | onebit_move(vram[0x3200 + i], 0, 8)
			map.append(attr)
		}
		map.reverse() //render higher -> lower address
		return map
	}

	function color_init(rom){
		local color = []
		foreach(v in rom){
			local r = (v & 0x1f) << 3
			v = v >>> 5
			local g = (v & 0x1f) << 3
			v = v >>> 5
			local b = (v & 0x1f) << 3
			color.append(0xff000000 | (r << 16) | (g << 8) | b)
		}
		return color
	}
	constructor(pal, charcter, m, charbank){
		image_init(1<<9, 1<<8, 0x7f7f7f7f);
		transback_draw(0x7f3f3f3f)
		m_map = map_init(m, charbank)
		m_color = color_init(pal)
		m_charcter = charcter
	}
	function render16x16(s){
		for(local y = 0, d = 0; y < 16; y++){
		for(local x = 0; x < 16; x++){
			if(x == 0 || x == 8){
				d = m_charcter[s.charcter]
				s.charcter += 1
			}
			d = (d << 4) | (d >>> 28)
			if((d & 0xf) != 0){
				put(
					(s.x_pos + (x ^ s.x_flip)) & 0x1ff,
					(s.y_pos + (y ^ s.y_flip)) & 0xff,
					m_color[s.color | (d & 0xf)]
				)
			}
		}}
	}
	function render(){
		foreach(attr in m_map){
			local s = clone attr
			s.charcter = s.charcter << (3 + 2)
			s.color = s.color << 4
			render16x16(s)
		}
		rect_draw(m_visible_area)
	}
}
/*
pseudo nametable style sprite.

- 横2x縦16個のスプライトを並べて描画する。
- 描画開始番号から0までを順番に描画する。
- 描画座標は1単位で1つ設定し、他のスプライトは順番に並べる。
- バンクは設定できないらしい。
並べる順番:
 0  1
 2  3
 4  5
 (中略)
30 31

b200h + (unit number) << 4
7:0 描画単位開始 position x bit 7:0

b204h + (unit number) << 4
7:0 描画単位開始 position y bit 7:0

b301h
3:0 描画単位開始番号 (1:15, 0:disable, other:num - 1)

b302h
7:0 描画単位 x position bit8 for bit7:0 (bit number == unit number)

b303h
7:0 b302h の対象 bit15:8

c400h-c5ffh
7:0 charcter index bit 7:0

e400h-e5ffh
7   x flip
6   y flip
4:0 charcter index bit 12:8

e600h-e7ffh
7:3 color index

atrribute RAM address bit
m:9 each attribute table
8:5 2x16 block unit number
4:0 internal sprite number
*/
class p3_sprite_2x16 extends p3_sprite_1{
	m_visible_area = {x = 511, y = 13 - 1, width = 384 + 1, height = 224 + 1} //?
	function map_init(vram, charbank){
		local map = []
		local unitindex = vram[0x0301] & 0xf
		local unit_x_bit8 = vram[0x302] | (vram[0x303] << 8)
		if(unitindex == 1){
			unitindex = 15
		}else{
			unitindex--
		}

		local global_xy_a = 0x0200 | (unitindex << 4)
		while(unitindex >= 0){
			local global_y = vram[global_xy_a + 0] ^ 0xff
			local global_x = vram[global_xy_a + 4] | onebit_move(unit_x_bit8, unitindex, 8)
			//print(format("i:%d x:%03x y:%02x\n", unitindex, global_x, global_y))
			for(local i = 0, attr_base_a = unitindex << 5; i < 0x20; i++, attr_base_a++){
				local attr = {y_pos = global_y, y_flip = 0, x_pos = global_x, x_flip = 0, color = 0, charcter = 0, bank = 0}
				attr.x_flip = vram[attr_base_a + 0x3400] & 0x80 ? 0x1ff : 0
				attr.y_flip = vram[attr_base_a + 0x3400] & 0x40 ? 0xff : 0
				attr.charcter = (vram[attr_base_a + 0x3400] & 0x1f) << 8
				attr.charcter = attr.charcter | vram[attr_base_a + 0x1400]
				attr.color = (vram[attr_base_a + 0x3600] >>> 3)
				map.append(attr)
				if(i & 1){
					global_y += 16
					global_y = global_y & 0xff
					attr.x_pos += 16
					attr.x_pos = attr.x_pos & 0x1ff
				}
			}
			unitindex--;
			global_xy_a -= (1<<4)
		}
		return map
	}
}
/*
VRAM image is Z80 memory b000h-ffffh
*/
function p3_render(rompath, outfile)
{
	local color = fileio_load_be16(rompath + "color.bin")
	local charcter = fileio_load_be32(rompath + "spritechar.bin")
	local vram = fileio_load_8(rompath + "vram.bin")
	local v1 = p3_sprite_1(
		color, charcter, vram,
		(0x70 >>> 6) & 0x3 //ioport 0x40
	)
	v1.render()
	local v32 = p3_sprite_2x16(
		color, charcter, vram,
		0 //bank is not used
	)
	v32.render()
	v1.image_add_height(v32)
	v1.save(outfile)
}
/*
charcter ROM data bit
     bit3   2  1  0
set0 za0-08 06 04 02
set1 za0-07 05 03 01

charcter ROM address は set0 -> set1 の順番

charcter size 16x16
address assignments  -> reorder address
msb:5 charcter index |msb:5 charcter index
4   y.offset 3       |4:1 y.offset 3:0
3   x.offset 3       |0   x.offset 3
2:0 y.offset 2:0     |
*/
function p3_charrom_decode(infile0, infile1, outfile)
{
	local chardata = romio_bit_8x4to32(infile0)
	chardata.extend(romio_bit_8x4to32(infile1))
	local dest = array(chardata.len(), 0)
	for(local index = 0; index < chardata.len() >>> 5; index++){
	for(local y = 0; y < 16; y++){
	for(local x = 0; x < 16; x += 8){
		local src_a = (
			(index << 5) |
			onebit_move(y, 3, 4) | onebit_move(x, 3, 3) |
			(y & 0x7)
		)
		local dest_a = (
			(index << 5) |
			(y << 1) | onebit_move(x, 3, 0)
		)
		dest[dest_a] = chardata[src_a]
	}}}
	fileio_save_be32(outfile, dest)
}

C Mahjong Clinic video static emulator

/*
Mahjong Clinic video static emulator
*/
class raster_image{
	width = null; height = null; data = null;
	function image_init(w, h)
	{
		width = w;
		height = h;
		data = array(w * h, 0x7f7f7f7f)
	}
	function put(x, y, rgb)
	{
		data[y * width + x] = rgb
	}
	function save(outfile)
	{
		png_save(outfile, this)
	}
	function transback_draw()
	{
		local dest = 0
		for(local y = 0; y < height; y += 16, dest += width * 16){
		for(local x = y & 0x10; x < width; x += 32){
		for(local i = 0; i < 16; i++){
		for(local j = 0; j < 16*width; j+=width){
			data[dest + x + i + j] = 0x7f3f3f3f
		}}}}
	}
	function image_add_height(s)
	{
		if(this.width != s.width){
			return false;
		}
		this.height += s.height
		this.data.extend(s.data)
		return true;
	}
}
class homedata_layer0 extends raster_image{
	m_color = null; m_charcter = null; m_map = null; m_bank = null;

	function colorpart(v, bit4_1, bit0)
	{
		local ret = (v >>> bit4_1) & 0x0f
		return (ret << 1) | onebit_move(v, bit0, 0)
	}
	constructor(pal, c, m, b){
		image_init(512, 256)
		m_charcter = c
		m_map = m
		m_bank = b
		m_color = []
		foreach(v in pal){
			local r = colorpart(v, 12, 2) << 3
			local g = colorpart(v, 8, 1) << 3
			local b = colorpart(v, 4, 0) << 3
			m_color.append((0xff << 24) | (r << 16) | (g << 8) | b)
		}
	}
	function pixel_put(x, y, color_index, d)
	{
		put(x, y, m_color[color_index | d])
	}
	function render_chip(x, y, char_index, color_index)
	{
		char_index = char_index << 3
		color_index = color_index << 4
		for(local yy = 0; yy < 8; yy+=1){
			local chardata = m_charcter[char_index];
			char_index += 1
			for(local xx = 0; xx < 8; xx+=1){
				chardata = (chardata << 4) | (chardata >>> 28)
				local d = chardata & 0x0f
				pixel_put(x + xx, y, color_index, d)
			}
			y += 1
		}
	}
	function render_screen()
	{
		local i = 0, y = 0;
		for(local y = 0; y < height; y += 8){
			for(local x = 0; x < width; x += 8){
				local char_index = m_map[i] & 0x03ff
				char_index = char_index | (m_bank << 10)
				local color_index = m_map[i] >>> 10
				render_chip(x, y, char_index, color_index | (m_bank << 6));
				i += 1
			}
		}
	}
}
class homedata_layer1 extends homedata_layer0{
	function render_screen()
	{
		transback_draw();
		local i = 0, y = 0;
		for(local y = 0; y < height; y += 8){
			for(local x = 0; x < width; x += 8){
				local char_index = m_map[i] & 0x07ff
				char_index = char_index | (m_bank << 11)
				local color_index = m_map[i] >>> 11
				render_chip(x, y, char_index, color_index | ((m_bank & 3) << 6));
				i += 1
			}
		}
	}
	function pixel_put(x, y, color_index, d)
	{
		if(d == 0){
			return;
		}
		put(x, y, m_color[color_index | d])
	}
}
function tile_render(rompath, outfile)
{
	local color = fileio_load_be16(rompath + "colorrom.bin")
	local charcter = fileio_load_be32(rompath + "x80_a03.1g")
	local map = fileio_load_be16("tilemap.bin")
	local bank = 5
	local screen0 = homedata_layer0(
		color.slice(0x6000, 0x7000),
		fileio_load_be32(rompath + "x80_a03.1g"),
		map.slice(0, 0x0800),
		bank & 0x3
	)
	screen0.render_screen()

	local screen1 = homedata_layer1(
		color.slice(0x7000),
		fileio_load_be32(rompath + "tilechar.bin"),
		map.slice(0x0800, 0x1000),
		(bank >>> 3) & 0x7
	)
	screen1.render_screen()

	screen0.image_add_height(screen1)
	screen0.save(outfile)
}

C icon

C 素因数のひとつを表示

#include <stdio.h>

main(){

	int i, n;

	for(n=2 ; n<=100 ; n++){
		for (i=2; i<=n; i++) {
			if (n%i == 0) break;
		}
		if (n%i == 0 && n==i) {printf("%3dは素数です\n",n);}
		else {printf("%3dは合成数です。素因数のひとつは %3d。\n",n,i);}
	}
}

C coll

// 座標
struct Point
{
	int x;
	int y;
	Point(int x_, int y_) : x(x_), y(y_) {};
};

// 当たり判定
struct HitBox
{
	Point pos;
	Point size;
};

// aとbが接触しているか
bool isHit(HitBox a, HitBox b)
{
	if (a.pos.x < b.pos.x + b.size.x &&
	    b.pos.x < a.pos.x + a.size.x &&
	    a.pos.y < b.pos.y + b.size.y &&
	    b.pos.y < a.pos.y + a.size.y)
	{
		return true;
	}
	return false;
}

C 1

#include <stdio.h>
int main()
{
	double t = 0.0, m = 0.0, v = 0.0;

	printf("物体の速度[m/s]を入力する\n");
	scanf("%lf", &v);
	if(v == 0){
		printf("0はだめ\n\n");
	}else if(v < 0){
		printf("負の値はだめ\n\n");
	}else{
		printf("速度%.0lf[m/s]の物体が10秒間等速で直線に進むと\n\n",v);
		for(t; t<=10.0; t=t+0.1){
			m = v*t;
			printf("%.1lf秒後の物体が進んだ距離は%.1lf[m]\n",t,m);
		}
	}
}

C test

あああああああああ

C bethevagineer.sp

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <tf2>
#include <tf2_stocks>

#define PLUGIN_VERSION "1.1.0"

public Plugin:myinfo =
{
	name = "Be the Vagineer",
	author = "svaugrasn",
	description = "HAMALUM",
	version = PLUGIN_VERSION,
	url = ""
}

new bool:isVagineer[MAXPLAYERS + 1] = { false, ... };
new String:voicemenu1[4];
new String:voicemenu2[4];

public OnPluginStart()
{
	RegConsoleCmd("vagineer", BetheVagineer);
	RegConsoleCmd("voicemenu", Command_Voicemenu);
	AddNormalSoundHook(HookSound);
}

public OnMapStart()
{
	AddFileToDownloadsTable("models/player/saxton_hale/vagineer_v134.dx80.vtx");
	AddFileToDownloadsTable("models/player/saxton_hale/vagineer_v134.dx90.vtx");
	AddFileToDownloadsTable("models/player/saxton_hale/vagineer_v134.mdl");
	AddFileToDownloadsTable("models/player/saxton_hale/vagineer_v134.sw.vtx");
	AddFileToDownloadsTable("models/player/saxton_hale/vagineer_v134.vvd");

	AddFileToDownloadsTable("sound/misc/vagineer/engineer_battlecry01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_battlecry03.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_battlecry04.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_battlecry06.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_battlecry07.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_cheers02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_cheers07.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_go01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_goodjob01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_headleft01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_headright03.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_helpme01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_helpme02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_helpme03.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_incoming01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_incoming02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_incoming03.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_jeers01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_jeers02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_jeers03.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_laughlong01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_laughlong02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_medic01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_medic02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_medic03.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_moveup01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_needdispenser01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_negativevocalization12.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_no01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_no02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_no03.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_paincrticialdeath01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_thanks01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_yes01.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_yes02.mp3");
	AddFileToDownloadsTable("sound/misc/vagineer/engineer_yes03.mp3");

	PrecacheSound("misc/vagineer/engineer_battlecry01.mp3");
	PrecacheSound("misc/vagineer/engineer_battlecry03.mp3");
	PrecacheSound("misc/vagineer/engineer_battlecry04.mp3");
	PrecacheSound("misc/vagineer/engineer_battlecry06.mp3");
	PrecacheSound("misc/vagineer/engineer_battlecry07.mp3");
	PrecacheSound("misc/vagineer/engineer_cheers02.mp3");
	PrecacheSound("misc/vagineer/engineer_cheers07.mp3");
	PrecacheSound("misc/vagineer/engineer_go01.mp3");
	PrecacheSound("misc/vagineer/engineer_goodjob01.mp3");
	PrecacheSound("misc/vagineer/engineer_headleft01.mp3");
	PrecacheSound("misc/vagineer/engineer_headright03.mp3");
	PrecacheSound("misc/vagineer/engineer_helpme01.mp3");
	PrecacheSound("misc/vagineer/engineer_helpme02.mp3");
	PrecacheSound("misc/vagineer/engineer_helpme03.mp3");
	PrecacheSound("misc/vagineer/engineer_incoming01.mp3");
	PrecacheSound("misc/vagineer/engineer_incoming02.mp3");
	PrecacheSound("misc/vagineer/engineer_incoming03.mp3");
	PrecacheSound("misc/vagineer/engineer_jeers01.mp3");
	PrecacheSound("misc/vagineer/engineer_jeers02.mp3");
	PrecacheSound("misc/vagineer/engineer_jeers03.mp3");
	PrecacheSound("misc/vagineer/engineer_laughlong01.mp3");
	PrecacheSound("misc/vagineer/engineer_laughlong02.mp3");
	PrecacheSound("misc/vagineer/engineer_medic01.mp3");
	PrecacheSound("misc/vagineer/engineer_medic02.mp3");
	PrecacheSound("misc/vagineer/engineer_medic03.mp3");
	PrecacheSound("misc/vagineer/engineer_moveup01.mp3");
	PrecacheSound("misc/vagineer/engineer_needdispenser01.mp3");
	PrecacheSound("misc/vagineer/engineer_negativevocalization12.mp3");
	PrecacheSound("misc/vagineer/engineer_no01.mp3");
	PrecacheSound("misc/vagineer/engineer_no02.mp3");
	PrecacheSound("misc/vagineer/engineer_no03.mp3");
	PrecacheSound("misc/vagineer/engineer_paincrticialdeath01.mp3");
	PrecacheSound("misc/vagineer/engineer_thanks01.mp3");
	PrecacheSound("misc/vagineer/engineer_yes01.mp3");
	PrecacheSound("misc/vagineer/engineer_yes02.mp3");
	PrecacheSound("misc/vagineer/engineer_yes03.mp3");

}

public Action:BetheVagineer(client, args)
{

	if (!isVagineer[client])
	{
		// SPAWN SOUND
		EmitSoundToAll("misc/vagineer/engineer_laughlong01.mp3");

		// SPAWN CHAT
		new String:name[MAX_NAME_LENGTH];
		GetClientName(client, name, sizeof(name));

		// SET MODEL
		new String:Mdl[PLATFORM_MAX_PATH];
		Format(Mdl, sizeof(Mdl), "models/player/saxton_hale/vagineer_v134.mdl", Mdl, Mdl);
		PrecacheModel(Mdl);
		SetVariantString(Mdl);
		AcceptEntityInput(client, "SetCustomModel");
		SetEntProp(client, Prop_Send, "m_bUseClassAnimations", 1);
		SetEntPropFloat(client, Prop_Send, "m_flModelScale", 1.00);

		isVagineer[client] = true;
	}

}

public Action:Command_Voicemenu(client, args)
{
	if(isVagineer[client])
	{

		new rint = GetRandomInt(0,2);
		GetCmdArg(1, voicemenu1, sizeof(voicemenu1));
		GetCmdArg(2, voicemenu2, sizeof(voicemenu2));

		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 0)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_medic01.mp3", client);
				}
				if(rint == 1){
				EmitSoundToAll("misc/vagineer/engineer_medic02.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_medic03.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 1)
			{
				EmitSoundToAll("misc/vagineer/engineer_thanks01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 2)
			{
				EmitSoundToAll("misc/vagineer/engineer_go01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 3)
			{
				EmitSoundToAll("misc/vagineer/engineer_moveup01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 4)
			{
				EmitSoundToAll("misc/vagineer/engineer_headleft01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 5)
			{
				EmitSoundToAll("misc/vagineer/engineer_headright03.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 6)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_yes01.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_yes02.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_yes03.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 0)
		{
			if(StringToInt(voicemenu2) == 7)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_no01.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_no02.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_no03.mp3", client);
				}
			}
		}

		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 0)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_incoming01.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_incoming02.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_incoming03.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 1)
			{
				EmitSoundToAll("misc/vagineer/engineer_jeers01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 2)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_jeers02.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_battlecry01.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_battlecry04.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 3)
			{
				EmitSoundToAll("misc/vagineer/engineer_needdispenser01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 4)
			{
				EmitSoundToAll("misc/vagineer/engineer_needdispenser01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 5)
			{
				EmitSoundToAll("misc/vagineer/engineer_needdispenser01.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 6)
			{
				EmitSoundToAll("misc/vagineer/engineer_cheers02.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 1)
		{
			if(StringToInt(voicemenu2) == 7)
			{
				EmitSoundToAll("misc/vagineer/engineer_laughlong01.mp3", client);
			}
		}

		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 0)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_helpme01.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_helpme02.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_helpme03.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 1)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_battlecry01.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_battlecry03.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_battlecry04.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 2)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_battlecry06.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_battlecry07.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_cheers02.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 3)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_jeers01.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_jeers02.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_jeers03.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 4)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_laughlong01.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_battlecry07.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_cheers02.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 5)
			{
				if(rint == 0){
					EmitSoundToAll("misc/vagineer/engineer_negativevocalization12.mp3", client);
				}
				if(rint == 1){
					EmitSoundToAll("misc/vagineer/engineer_jeers02.mp3", client);
				}
				if(rint == 2){
					EmitSoundToAll("misc/vagineer/engineer_jeers01.mp3", client);
				}
			}
		}
		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 6)
			{
				EmitSoundToAll("misc/vagineer/engineer_cheers02.mp3", client);
			}
		}
		if(StringToInt(voicemenu1) == 2)
		{
			if(StringToInt(voicemenu2) == 7)
			{
				EmitSoundToAll("misc/vagineer/engineer_goodjob01.mp3", client);
			}
		}
	}
}

public Action:HookSound(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &ent, &channel, &Float:volume, &level, &pitch, &flags)
{
	if (ent < 1 || ent > MaxClients || channel < 1)
		return Plugin_Continue;

	if (isVagineer[ent])
	{
		volume = 0.0;
		return Plugin_Changed;
	}

	return Plugin_Continue;

}

public Action:event_class_change(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	isVagineer[client] = false;
}

public OnClientDisconnect(client)
{
	isVagineer[client] = false;
}
Total Pages: 1 / 712345...最後 »

よく投稿されているコード

タグ

最近投稿されたコード