hi.. I've been writing this plugin and changing it for a long time.. people in my server likes it so thats why I keep upgrading it..
this pluging has text in spanish. It change the model of 3 guns: ak, deagle and knife.. everything works fine except for the menu.. the first menu works great, but the second one (armas2) doesn't.
I want to set "0" to be the back button, instead of "4" that is what i have right now.. i can't make it work with "0", i dunno if it has to be with the first menu that has "0" to exit. I've been trying to fix that with no results.
About saving data I also want to save the models that each player has chosen, because every map change they have to type /armas for the menu to change models again and most of the time people get killed because of that. So it would be great to save the models a player chose and keep that models util he makes another another change.
The problem is that I dunno how to do it, I have read a tutorial about saving data with cvault, i also cheked some plugings that save data but i cant figure it out, i don't understand.. :(
here is the code, please help me with it..
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#define PLUGIN "Custom Models"
#define VERSION "90346087109273123"
#define AUTHOR "who??"
new ak_model[33]
new deagle_model[33]
new knife_model[33]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("CurWeapon","checkWeapon","be","1=1")
new keys1 = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4
new keys2 = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4
register_menucmd(register_menuid("Skins para las armas"), keys1, "marmas")
register_menucmd(register_menuid("Skins para Cuchillo"), keys2, "marmas2")
register_clcmd("say /armas", "armas")
register_clcmd("say /armas2", "armas2")
}
public plugin_precache() {
precache_model("mdl/test/models/v_ak47.mdl")
precache_model("models/v_ak47.mdl")
precache_model("mdl/test/models/v_laser.mdl")
precache_model("models/v_deagle.mdl")
precache_model("mdl/test/models/v_hacha.mdl")
precache_model("mdl/test/models/p_hacha.mdl")
precache_model("mdl/test/models/v_bate.mdl")
precache_model("mdl/test/models/v_machete.mdl")
precache_model("mdl/test/models/p_machete.mdl")
precache_model("models/v_knife.mdl")
}
public armas(id)
{
new menu[512]
new keys1 = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4
new aktext[50], lasertext[50]
if(ak_model[id] == 0 ){
format(aktext, 49, "AK-47 Plateada")
}
else if(ak_model[id] == 1 ){
format(aktext, 49, "AK-47 Normal")
}
if(deagle_model[id] == 0 ){
format(lasertext, 49, "Deagle Laser")
}
else if(deagle_model[id] == 1 ){
format(lasertext, 49, "Deagle Normal")
}
format(menu, 511, "Skins para las armas^n^n1. %s^n2. %s^n3. Skins para cuchillo^n^n0. Salir^n^n", aktext, lasertext)
show_menu(id, keys1, menu)
return PLUGIN_HANDLED
}
public marmas(id, key)
{
new bool:stayinmenu = false
switch (key)
{
case 0: {
if(ak_model[id] == 0 ){
akplata(id)
}
else if(ak_model[id] == 1 ){
ak(id)
}
stayinmenu = true
}
case 1: {
if(deagle_model[id] == 0 ){
laser(id)
}
else if(deagle_model[id] == 1 ){
deagle(id)
}
stayinmenu = true
}
case 2: {
armas2(id)
}
case 3: {
end_menu(id)
}
}
if (stayinmenu)
armas(id)
return PLUGIN_HANDLED
}
public armas2(id)
{
new menu2[512]
new keys2 = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4
new hachatext[150], machetetext[150], batetext[150]
if(knife_model[id] == 0){
format(hachatext, 149, "Hacha de Carnicero")
}
else if(knife_model[id] == 2 ){
format(hachatext, 149, "Hacha de Carnicero")
}
else if(knife_model[id] == 3 ){
format(hachatext, 149, "Hacha de Carnicero")
}
else if(knife_model[id] == 1 ){
format(hachatext, 149, "Cuchillo Normal")
}
if(knife_model[id] == 0 ){
format(machetetext, 149, "Machete")
}
else if(knife_model[id] == 1 ){
format(machetetext, 149, "Machete")
}
else if(knife_model[id] == 2 ){
format(machetetext, 149, "Machete")
}
else if(knife_model[id] == 3 ){
format(machetetext, 149, "Cuchillo Normal")
}
if(knife_model[id] == 0 ){
format(batetext, 149, "Bate de Baseball")
}
else if(knife_model[id] == 1 ){
format(batetext, 149, "Bate de Baseball")
}
else if(knife_model[id] == 3 ){
format(batetext, 149, "Bate de Baseball")
}
else if(knife_model[id] == 2 ){
format(batetext, 149, "Cuchillo Normal")
}
format(menu2, 511, "Skins para Cuchillo^n^n1. %s^n2. %s^n3. %s^n4. Atras^n^n", hachatext, machetetext, batetext)
show_menu(id, keys2, menu2) // i want to set "0" to be the back button, instead of "4" that is it now
return PLUGIN_HANDLED // but i dunno why i cant do it, if i set it to 0, when you press it, the menu wont go back
}
public marmas2(id, key){
if (armas2(id)){
new bool:stayinmenu = false
switch (key)
{
case 0: {
if(knife_model[id] == 0 ){
hacha(id)
}
else if(knife_model[id] == 2 ){
hacha(id)
}
else if(knife_model[id] == 3 ){
hacha(id)
}
else if(knife_model[id] == 1 ){
cuchillo(id)
}
stayinmenu = true
}
case 1: {
if(knife_model[id] == 0 ){
machete(id)
}
else if(knife_model[id] == 2 ){
machete(id)
}
else if(knife_model[id] == 1 ){
machete(id)
}
else if(knife_model[id] == 3 ){
cuchillo(id)
}
stayinmenu = true
}
case 2: {
if(knife_model[id] == 0 ){
bate(id)
}
else if(knife_model[id] == 1 ){
bate(id)
}
else if(knife_model[id] == 3 ){
bate(id)
}
else if(knife_model[id] == 2 ){
cuchillo(id)
}
stayinmenu = true
}
case 3: {
armas(id)
}
}
if (stayinmenu)
armas2(id)
}
return PLUGIN_HANDLED
}
public end_menu(id)
{
return PLUGIN_HANDLED
}
public ak(id) {
ak_model[id] = 0
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_AK47 ) {
entity_set_string(id, EV_SZ_viewmodel, "models/v_ak47.mdl")
}
}
public akplata(id) {
ak_model[id] = 1
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_AK47 ) {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_ak47.mdl")
}
}
public cuchillo(id) {
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
knife_model[id] = 0
if ( Weapon == CSW_KNIFE ) {
entity_set_string(id, EV_SZ_viewmodel, "models/v_knife.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_knife.mdl")
}
}
public hacha(id) {
knife_model[id] = 1
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_KNIFE ) {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_hacha.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "mdl/test/models/p_hacha.mdl")
}
}
public bate(id) {
knife_model[id] = 2
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_KNIFE ) {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_bate.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_knife.mdl")
}
}
public machete(id) {
knife_model[id] = 3
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_KNIFE ) {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_machete.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "mdl/test/models/p_machete.mdl")
}
}
public deagle(id) {
deagle_model[id] = 0
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_DEAGLE ) {
entity_set_string(id, EV_SZ_viewmodel, "models/v_deagle.mdl")
}
}
public laser(id) {
deagle_model[id] = 1
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_DEAGLE ) {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_revolver.mdl")
}
}
public checkWeapon(id)
{
new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
if ( Weapon == CSW_AK47 && ak_model[id] == 1 ) {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_ak47.mdl")
}
else if ( Weapon == CSW_AK47 && ak_model[id] == 0 ) {
entity_set_string(id, EV_SZ_viewmodel, "models/v_ak47.mdl")
}
else if ( Weapon == CSW_DEAGLE && deagle_model[id] == 1 ) {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_laser.mdl")
}
else if ( Weapon == CSW_DEAGLE && deagle_model[id] == 0 ) {
entity_set_string(id, EV_SZ_viewmodel, "models/v_deagle.mdl")
}
else if ( Weapon == CSW_KNIFE ) {
entity_set_string(id, EV_SZ_weaponmodel, "models/p_knife.mdl")
switch (knife_model[id]) {
case 0: {
entity_set_string(id, EV_SZ_viewmodel, "models/v_knife.mdl")
}
case 1: {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_hacha.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "mdl/test/models/p_hacha.mdl")
}
case 2: {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_bate.mdl")
}
case 3: {
entity_set_string(id, EV_SZ_viewmodel, "mdl/test/models/v_machete.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "mdl/test/models/p_machete.mdl")
}
}
}
}
// I dunno how to save the data to keep the models for each player, so they will get those models when they reconnect