Raised This Month: $ Target: $400
 0% 

Server Shutdown - Plugin CSO Costume


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Evencelance
Member
Join Date: Dec 2012
Old 08-13-2013 , 01:27   Server Shutdown - Plugin CSO Costume
Reply With Quote #1

Rewrite who is not difficult, if the server crashes with this code, please help me.

Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "[CSO] Costume"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define MAX_COSTUME 11
#define MAX_COSTUMEPART 4

#define COSTUME_THINKDELAY 5.0

#define COSTUME_CLASSNAME "costume"
#define COSTUME_URL "models/costumes"

new const CostumeName[MAX_COSTUME][] =
{
	"Angel",
	"Cat",
	"Clock",
	"Devil",
	"Gold",
	"Panda",
	"Pig",
	"Polar Bear",
	"Pumpkin",
	"Snow",
	"Squirrel"
}

new const CostumePart[MAX_COSTUME] =
{
	2,
	4,
	1,
	3,
	2,
	4,
	4,
	2,
	2,
	2,
	4
}

new const CostumeBack[MAX_COSTUME][] =
{
	"angel_back.mdl",
	"cat_back.mdl",
	"clock_back.mdl",
	"devil_back.mdl",
	"gold_back.mdl",
	"panda_back.mdl",
	"pig_back.mdl",
	"polarbear_back.mdl",
	"pumpkin_back.mdl",
	"snow_back.mdl",
	"squirrel_back.mdl"
}

new const CostumeFace[MAX_COSTUME][] = 
{
	"angel_head.mdl",
	"cat_face.mdl",
	"",
	"",
	"",
	"panda_face.mdl",
	"pig_face.mdl",
	"",
	"",
	"",
	"squirrel_face.mdl"
}

new const CostumeHead[MAX_COSTUME][] =
{
	"",
	"cat_head.mdl",
	"",
	"devil_head.mdl",
	"gold_head.mdl",
	"panda_head.mdl",
	"pig_head.mdl",
	"polarbear_head.mdl",
	"pumpkin_head.mdl",
	"snow_head.mdl",
	"squirrel_head.mdl"
}

new const CostumePelvis[MAX_COSTUME][] =
{
	"",
	"cat_pelvis.mdl",
	"",
	"devil_pelvis.mdl",
	"",
	"panda_pelvis.mdl",
	"pig_pelvis.mdl",
	"",
	"",
	"",
	"squirrel_pelvis.mdl"
}

enum
{
	COSTUME_BACK = 0,
	COSTUME_FACE,
	COSTUME_HEAD,
	COSTUME_PELVIS
}

new g_MyCostumeID[33], g_MyCostumeEnt[33][MAX_COSTUME]
new g_MaxPlayers, g_MsgSayText

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	g_MaxPlayers = get_maxplayers()
	g_MsgSayText = get_user_msgid("SayText")

	RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
	register_clcmd("say /costume", "Open_CostumeMenu")
}

public client_putinserver(id)
{
	Reset_AllCostume(id)
	g_MyCostumeID[id] = -1
}

public client_disconnect(id)
{
	Reset_AllCostume(id)
	g_MyCostumeID[id] = -1
}

public plugin_precache()
{
	static Buffer[128]
	
	for(new i = 0; i < MAX_COSTUME; i++)
	{
		// Precache Costume's Back
		if(!equal(CostumeBack[i], ""))
		{
			formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeBack[i])
			engfunc(EngFunc_PrecacheModel, Buffer)
		}
			
		// Precache Costume's Face
		if(!equal(CostumeFace[i], ""))
		{
			formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeFace[i])
			engfunc(EngFunc_PrecacheModel, Buffer)
		}
		
		// Precache Costume's Head
		if(!equal(CostumeHead[i], ""))
		{
			formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeHead[i])
			engfunc(EngFunc_PrecacheModel, Buffer)
		}
		
		// Precache Costume's Pelvis
		if(!equal(CostumePelvis[i], ""))
		{
			formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumePelvis[i])
			engfunc(EngFunc_PrecacheModel, Buffer)
		}
	}
}

public fw_PlayerSpawn_Post(id) set_task(random_float(0.1, 0.25), "Delay_SpawnPost", id)
public Delay_SpawnPost(id)
{
	Reset_AllCostume(id)
	if(g_MyCostumeID[id] != -1) Set_PlayerCostume(id, g_MyCostumeID[id])
}

public Open_CostumeMenu(id)
{
	if(!is_user_connected(id))
		return
		
	static Menu; Menu = menu_create("Name (Total Costume Part)", "MenuHandle_CostumeSelect")
	static CostumeNameIn[64], CostumeID[4]
	
	menu_additem(Menu, "[No Use]", "nouse")
	for(new i = 0; i < MAX_COSTUME; i++)
	{
		formatex(CostumeNameIn, sizeof(CostumeNameIn), "%s \y(%i)\w", CostumeName[i], CostumePart[i])
		num_to_str(i, CostumeID, sizeof(CostumeID))
	
		menu_additem(Menu, CostumeNameIn, CostumeID)
	}
	
	menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, Menu, 0)
}

public MenuHandle_CostumeSelect(id, Menu, Item)
{
	if(!is_user_connected(id) || Item == MENU_EXIT)
	{
		menu_destroy(Menu)
		return
	}

	static Name[32], Data[8], ItemAccess, ItemCallback
	menu_item_getinfo(Menu, Item, ItemAccess, Data, charsmax(Data), Name, charsmax(Name), ItemCallback)

	if(Data[0] == 'n' && Data[2] == 'u')
	{
		Reset_AllCostume(id)
		g_MyCostumeID[id] = -1
		
		client_printc(id, "!g[CSO]!n Costume: Removed Costume")
		
		return
	}
	static CostumeID; CostumeID = str_to_num(Data)
	if(CostumeID >= MAX_COSTUME)
	{
		menu_destroy(Menu)
		return
	}
	
	g_MyCostumeID[id] = CostumeID
	client_printc(id, "!g[CSO]!n Costume: You've selected !t%s!n !!!", CostumeName[CostumeID])
	
	if(is_user_alive(id)) 
	{
		Reset_AllCostume(id)
		Set_PlayerCostume(id, CostumeID)
	}
}

public Set_PlayerCostume(id, CostumeID)
{
	static CostumeModel[128]
	
	// Costume: Back
	if(!equal(CostumeBack[CostumeID], ""))
	{
		formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeBack[CostumeID])
		g_MyCostumeEnt[id][COSTUME_BACK] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_BACK)
	}
	
	// Costume: Face
	if(!equal(CostumeFace[CostumeID], ""))
	{
		formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeFace[CostumeID])
		g_MyCostumeEnt[id][COSTUME_FACE] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_FACE)
	}
	
	// Costume: Head
	if(!equal(CostumeHead[CostumeID], ""))
	{
		formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeHead[CostumeID])
		g_MyCostumeEnt[id][COSTUME_HEAD] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_HEAD)
	}
	
	// Costume: Pelvis
	if(!equal(CostumePelvis[CostumeID], ""))
	{
		formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumePelvis[CostumeID])
		g_MyCostumeEnt[id][COSTUME_PELVIS] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_PELVIS)
	}
}

public Create_CostumeModel(id, Model[], CostumeID, Part)
{
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	if(!pev_valid(Ent)) return 0
	
	static Float:Origin[3]; pev(id, pev_origin, Origin)
	set_pev(Ent, pev_origin, Origin)
	
	set_pev(Ent, pev_dmg_take, DAMAGE_NO)
	set_pev(Ent, pev_health, 100.0)
	
	set_pev(Ent, pev_classname, COSTUME_CLASSNAME)
	engfunc(EngFunc_SetModel, Ent, Model)
	set_pev(Ent, pev_solid, SOLID_NOT)
	set_pev(Ent, pev_movetype, MOVETYPE_FOLLOW)
	
	set_pev(Ent, pev_aiment, id)
	set_pev(Ent, pev_owner, id)
	set_pev(Ent, pev_nextthink, get_gametime())
	
	set_pev(Ent, pev_animtime, get_gametime())
	set_pev(Ent, pev_framerate, 1.0)
	set_pev(Ent, pev_sequence, 0)
	
	return Ent
}

/*
public fw_Costume_Think(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!is_user_connected(Id))
		return
		
	static IntVar, Float:FloatVar, Color[3]
	
	pev(Id, pev_renderamt, FloatVar); set_pev(Ent, pev_renderamt, FloatVar)
	pev(Id, pev_rendercolor, Color); set_pev(Ent, pev_rendercolor, Color)
	IntVar = pev(Id, pev_renderfx); set_pev(Ent, pev_renderfx, IntVar)
	IntVar = pev(Id, pev_rendermode); set_pev(Ent, pev_rendermode, IntVar)
		
	client_print(Id, print_chat, "Amt: %f | FX: %i | Mode: %i", FloatVar, pev(Id, pev_renderfx), pev(Id, pev_rendermode))
		
	// Set Next Think
	set_pev(Ent, pev_nextthink, get_gametime() + COSTUME_THINKDELAY)
}*/

public Reset_AllCostume(id)
{
	Reset_CostumePart(id, COSTUME_BACK)
	Reset_CostumePart(id, COSTUME_FACE)
	Reset_CostumePart(id, COSTUME_HEAD)
	Reset_CostumePart(id, COSTUME_PELVIS)
}

public Reset_CostumePart(id, Part)
{
	if(IsValid_CostumeEnt(id, Part)) engfunc(EngFunc_RemoveEntity, Get_CostumeEnt(id, Part))
}

public IsValid_CostumeEnt(id, Part)
{
	return pev_valid(g_MyCostumeEnt[id][Part])
}

public Get_CostumeEnt(id, Part)
{
	return g_MyCostumeEnt[id][Part]
}

stock client_printc(index, const text[], any:...)
{
	static szMsg[128]; vformat(szMsg, sizeof(szMsg) - 1, text, 3)

	replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04")
	replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01")
	replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03")

	if(!index)
	{
		for(new i = 0; i < g_MaxPlayers; i++)
		{
			if(!is_user_connected(i))
				continue
				
			message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, i);
			write_byte(i);
			write_string(szMsg);
			message_end();	
		}		
	} else {
		message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, index);
		write_byte(index);
		write_string(szMsg);
		message_end();
	}
} 
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Evencelance is offline
tei1995
Senior Member
Join Date: Feb 2011
Location: VietNam
Old 08-13-2013 , 08:53   Re: Server Shutdown - Plugin CSO Costume
Reply With Quote #2

Give us your log file
__________________

Hatsune Miku~
tei1995 is offline
ALBTeam
BANNED
Join Date: Aug 2013
Old 08-13-2013 , 16:49   Re: Server Shutdown - Plugin CSO Costume
Reply With Quote #3

try this http://forums.alliedmods.net/showthr...32#post2012432
ALBTeam is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode