Raised This Month: $ Target: $400
 0% 

First time make sma ... help !!!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RPDisNOOB
New Member
Join Date: Jan 2016
Old 01-05-2016 , 06:00   First time make sma ... help !!!
Reply With Quote #1

I want to make a change player model menu
help me ... thx !!!

Quote:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>

#define PLUGIN "RPD"
#define VERSION "1.0"
#define menu_create

public plugin_init()
{
register_plugin("RPD's插件", "1.0", "RPD")
register_clcmd("model", "rpd")
return PLUGIN_CONTINUE
}

public rpd(id)
{
new menu = menu_create("\r[RPD Model Menu]", "rpd_menu")
menu_additem(menu, "\wModel-1", "1", 0)
menu_additem(menu, "\wModel-2", "2", 0)
menu_additem(menu, "\wModel-3", "3", 0)
menu_additem(menu, "\wModel-4", "4", 0)

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)

menu_display(id, menu, 0)

}

public plugin_precache()
{
precache_model("models/player/vip/vip.mdl")
precache_model("models/player/admin1/admin1.mdl")
precache_model("models/player/admin2/admin2.mdl")
precache_model("models/player/admin3/admin3.mdl")

return PLUGIN_CONTINUE
}

public menu(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new acces, callback
menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback)

new key = str_to_num(data)

switch(key)
{
case 1 :
{
client_print(id, print_chat, "你按了VIP");
cs_set_user_model(id, "vip")
}
case 2 : cs_set_user_model(id, "admin1")
case 3 : cs_set_user_model(id, "admin2")
case 4 : cs_set_user_model(id, "admin3")
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
Attached Images
File Type: jpg bandicam 2016-01-04 20-21-24-251.jpg (69.4 KB, 124 views)
Attached Files
File Type: sma Get Plugin or Get Source (rpdmodelmenu.sma - 557 views - 1.5 KB)

Last edited by RPDisNOOB; 01-05-2016 at 06:07.
RPDisNOOB is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 01-05-2016 , 07:12   Re: First time make sma ... help !!!
Reply With Quote #2

Wrong section. This is sourcemod.
Addicted. is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 01-06-2016 , 18:07   Re: First time make sma ... help !!!
Reply With Quote #3

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
1) //#include <colorchat>

#define PLUGIN "RPD"
#define VERSION "1.0"

2) //#define menu_create

public plugin_init()
{
	3) register_plugin(PLUGIN, VERSION, "RPD")
	
	register_clcmd("model", "rpd")
	4) //return PLUGIN_CONTINUE
}

public plugin_precache() 
{
	precache_model("models/player/vip/vip.mdl")
	precache_model("models/player/admin1/admin1.mdl")
	precache_model("models/player/admin2/admin2.mdl")
	precache_model("models/player/admin3/admin3.mdl")

	5) //return PLUGIN_CONTINUE
}

public rpd(id)
{
	new menu = menu_create("\r[RPD Model Menu]", "rpd_menu")
	
	6) menu_additem(menu, "\wModel-1") //vip
	menu_additem(menu, "\wModel-2") //admin1
	menu_additem(menu, "\wModel-3")	//admin2
	menu_additem(menu, "\wModel-4")	//admin3
	
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	
	menu_display(id, menu, 0)
}

public menu(id, menu, item)
{
	if (item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}
	
	new data[6], iName[64]
	new acces, callback
	menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback)

	new key = str_to_num(data)

	switch(key)
	{ 
		7) case 0:
		{
			8) client_print(id, print_chat, "???VIP"); //client_print_color?
		9) cs_reset_user_model( id );
			cs_set_user_model(id, "vip")
		}
		case 1: 
		{
			cs_reset_user_model( id );
			cs_set_user_model(id, "admin1")
		}
		case 2: 
		{
			cs_reset_user_model( id );
			cs_set_user_model(id, "admin2")
		}
		case 3: 
		{
			cs_reset_user_model( id );
			cs_set_user_model(id, "admin3")
		}
	}
	
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
1) Why are you including "colorchat" when there's already: "client_print_color".
2) Why did you define "menu_create"? It's in the menu system.
3) There's so many ways to put the information in the "register_plugin". It always goes: "Plugin"-"Version"-"Author". You can set them as: new const g_szPlugin [] = "My Plugin Name"; if you are going to use it later in the code as in print in chat or something. It all depends on how or where are you going to use them. If you're not going to use any of them anywhere else in the code, just put them like this: "register_plugin( "My Plugin Name", "0.0.1", "Baws" );" It's up to you.
4) Why did you put "return PLUGIN_CONTINUE;" in the "plugin_init"? Do you know the use of: "return;"-"return PLUGIN_HANDLED;"-"return PLUGIN_CONTINUE;"-...etc ?
5) Look at number 4.
6) Whenever you're adding an item in the menu, it's number is already defined automatically.
7) The cases need to start by "case 0:" then you continue like "case 1:"-"case 2:"...etc.
"client_print_color" and "client_print" are the same use basically. The "client_print_color" is to print the words in the colors you tell it to print with, but "client_print" is simply to print in the default yellow color.
9) Before setting a new model on a user, I suggest to reset it first and then adding the new model.
__________________
Like my clean plugins and work?

Last edited by Baws; 01-06-2016 at 18:09.
Baws 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 09:20.


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