Resolved Scripting

Coding Help/Re-API Supported
User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 634
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

Re: Scripting

#31

Post by Spir0x » 2 Years Ago

And still kill my default knife in zombie_escape.ini fix it please!
I trynna make money, not friends.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1990
Joined: 3 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#32

Post by Raheem » 2 Years Ago

You don't know? Learn and you will know.

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 634
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#33

Post by Spir0x » 2 Years Ago

the same problems .. error ze_get_vip_flags please compile it for me
I trynna make money, not friends.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1990
Joined: 3 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#34

Post by Raheem » 2 Years Ago

Use pure compiler and see if you will get it or not. Also include only <ze_vip>
You don't know? Learn and you will know.

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 634
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#35

Post by Spir0x » 2 Years Ago

Yes i included :/ but wont compile look

Code: Select all

#include <ze_vip>
 
#define is_user_valid(%1) (is_user_alive(%1) && !is_user_bot(%1) && !is_user_hltv(%1))

// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
 
// Models
new const Compat_Models[][] =
{
	"models/zombie_escape/v_combat_knife.mdl",
	"models/zombie_escape/p_combat_knife.mdl"
}

new const Strong_Models[][] =
{
	"models/zombie_escape/v_strong_knife.mdl",
	"models/zombie_escape/p_strong_knife.mdl"
}

new const Katana_Models[][] =
{
	"models/zombie_escape/v_katana_knife.mdl",
	"models/zombie_escape/p_katana_knife.mdl"
}

new const Hammer_Models[][] =
{ 
    "models/zombie_escape/v_hammer_knife.mdl",
    "models/zombie_escape/p_hammer_knife.mdl" 
}

// Sounds
new const g_sound_knife[] = "items/gunpickup2.wav"

new const combat_sounds[][] =
{
	"zombie_escape/knife_menu/combat_deploy.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hit.wav",
	"zombie_escape/knife_menu/combat_hitwall.wav",
	"zombie_escape/knife_menu/combat_slash.wav",
	"zombie_escape/knife_menu/combat_slash.wav",
	"zombie_escape/knife_menu/combat_stab.wav"
}

new const strong_sounds[][] =
{
	"zombie_escape/knife_menu/strong_deploy.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hit.wav",
	"zombie_escape/knife_menu/strong_hitwall.wav",
	"zombie_escape/knife_menu/strong_slash.wav",
	"zombie_escape/knife_menu/strong_slash.wav",
	"zombie_escape/knife_menu/strong_stab.wav"
}

new const katana_sounds[][] =
{
	"zombie_escape/knife_menu/katana_deploy.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hit.wav",
	"zombie_escape/knife_menu/katana_hitwall.wav",
	"zombie_escape/knife_menu/katana_slash.wav",
	"zombie_escape/knife_menu/katana_slash.wav",
	"zombie_escape/knife_menu/katana_stab.wav"
}

new const hammer_sounds[][] =
{
	"zombie_escape/knife_menu/hammer_deploy.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hit.wav",
	"zombie_escape/knife_menu/hammer_hitwall.wav",
	"zombie_escape/knife_menu/hammer_slash.wav",
	"zombie_escape/knife_menu/hammer_slash.wav",
	"zombie_escape/knife_menu/hammer_stab.wav"
}

new const oldknife_sounds[][] =
{
	"weapons/knife_deploy1.wav",
	"weapons/knife_hit1.wav",
	"weapons/knife_hit2.wav",
	"weapons/knife_hit3.wav",
	"weapons/knife_hit4.wav",
	"weapons/knife_hitwall1.wav",
	"weapons/knife_slash1.wav",
	"weapons/knife_slash2.wav",
	"weapons/knife_stab.wav"
}
 
new bool:g_bCompat[33], bool:g_bStrong[33], bool:g_bKatana[33], bool:g_bHammer[33],
g_iUsedTimes[33], cvar_use_times

// Dynamic Arrays
new Array:g_szNormalModel

public plugin_precache()
{
    new i
	
    for(i = 0; i < sizeof(Hammer_Models); i++)
        precache_model(Hammer_Models[i])
	
    for(i = 0; i < sizeof(Katana_Models); i++)
        precache_model(Katana_Models[i])
	
    for(i = 0; i < sizeof(Compat_Models); i++)
        precache_model(Compat_Models[i])
	
    for(i = 0; i < sizeof(Strong_Models); i++)
        precache_model(Strong_Models[i])
       
    precache_sound(g_sound_knife)
 
    for(i = 0; i < sizeof(combat_sounds); i++)
        precache_sound(combat_sounds[i])
 
    for(i = 0; i < sizeof(strong_sounds); i++)
        precache_sound(strong_sounds[i])
 
    for(i = 0; i < sizeof(katana_sounds); i++)
        precache_sound(katana_sounds[i])
 
    for(i = 0; i < sizeof(hammer_sounds); i++)
        precache_sound(hammer_sounds[i])
	
	// Initialize arrays
	g_szNormalModel = ArrayCreate(64, 1)
	
	// Load from external file
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapon Models", "V_KNIFE HUMAN", g_szNormalModel)
}
 
public plugin_natives()
{
    register_native("ze_open_knife_menu", "native_ze_open_knife_menu", 1)
}
 
public plugin_init()
{
    register_plugin("[ZE] Addon: Knife Menu", "1.1", "Jack GamePlay")
	
	// Forwards
    register_forward(FM_EmitSound, "fw_EmitSound")
	
	// Events
    register_event("CurWeapon", "CurrentWeapon", "be", "1=1")

    // Cvars
    cvar_use_times = register_cvar("ze_knife_menu_use_times", "1")
	
	// Messages
    register_message(get_user_msgid("DeathMsg"), "DeathMsg")
}
 
public ze_user_humanized(id)
{
	g_iUsedTimes[id] = 0
}

public client_connect(id)
{
    g_bCompat[id] = false
    g_bStrong[id] = false
    g_bKatana[id] = false
    g_bHammer[id] = false
    g_iUsedTimes[id] = 0
}
 
public Show_Knife_Menu(id)
{
    new menu = menu_create("\rChoose Your Knife\w:", "Knife_Menu_Functions")
    menu_additem(menu, "\yCombat", "", 0)
    menu_additem(menu, "\yGolden", "", 0)
    menu_additem(menu, "\yKatana", "", 0)
    menu_additem(menu, "\yHammer", "", 0)
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	
    if((g_iUsedTimes[id] < get_pcvar_num(cvar_use_times)) && !ze_is_user_zombie(id) && is_user_valid(id)) && ze_get_vip_flags(id) & VIP_A)
    {
        menu_display(id, menu, 0)
    }
    else if(ze_is_user_zombie(id))
    {
        ze_colored_print(id, "!tYou can't open knife menu due to being zombie!y.")
        return PLUGIN_HANDLED
    }
    else if(g_iUsedTimes[id] >= get_pcvar_num(cvar_use_times))
    {
        ze_colored_print(id, "!tYou have already used !gKnife menu!y, !twait for the next round!y!", get_pcvar_num(cvar_use_times))
        return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE
}
 
public Knife_Menu_Functions(id, menu, key)
{
    if(!is_user_valid(id) || ze_is_user_zombie(id))
        return
       
    switch(key)
    {
        case 0: // Compat
        {
            g_bCompat[id] = true
            g_bStrong[id] = false
            g_bKatana[id] = false
            g_bHammer[id] = false
            g_iUsedTimes[id]++
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            engclient_cmd(id, "weapon_knife")
            emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
        }
        case 1: // Strong
        {
            g_bCompat[id] = false
            g_bStrong[id] = true
            g_bKatana[id] = false
            g_bHammer[id] = false
            g_iUsedTimes[id]++
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            engclient_cmd(id, "weapon_knife")
            emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
        }
        case 2: // Katana
        {
            g_bCompat[id] = false
            g_bStrong[id] = false
            g_bKatana[id] = true
            g_bHammer[id] = false
            g_iUsedTimes[id]++
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            engclient_cmd(id, "weapon_knife")
            emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
        }
        case 3: // Hammer
        {
            g_bCompat[id] = false
            g_bStrong[id] = false
            g_bKatana[id] = false
            g_bHammer[id] = true
            g_iUsedTimes[id]++
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            engclient_cmd(id, "weapon_knife")
            emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
        }
    }
    menu_destroy(menu)
}
 
public fw_EmitSound(id, channel, const sound[])
{
    if(!is_user_valid(id) || ze_is_user_zombie(id))
        return FMRES_IGNORED
       
    new i
    for(i = 0; i < sizeof(combat_sounds); i++)
    for(i = 0; i < sizeof(strong_sounds); i++)
    for(i = 0; i < sizeof(katana_sounds); i++)
    for(i = 0; i < sizeof(hammer_sounds); i++)
    {
        if(equal(sound, oldknife_sounds[i]))
        {
            if (g_bCompat[id])
            {
                emit_sound(id, channel, combat_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (g_bStrong[id])
            {
                emit_sound(id, channel, strong_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (g_bKatana[id])
            {
                emit_sound(id, channel, katana_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (g_bHammer[id])
            {
                emit_sound(id, channel, hammer_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (!g_bCompat[id] || !g_bStrong[id] || !g_bKatana[id] || !g_bHammer[id])
            {
                emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
        }
    }
    return FMRES_IGNORED
}

public CurrentWeapon(id)
{
    if(!is_user_valid(id) || ze_is_user_zombie(id))
        return
       
    if(get_user_weapon(id) & CSW_KNIFE)
    {
        if(g_bCompat[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Compat_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Compat_Models[1])
        }
        else if(g_bStrong[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Strong_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Strong_Models[1])
        }
        else if(g_bKatana[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Katana_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Katana_Models[1])
        }
        else if(g_bHammer[id])
        {
            cs_set_player_view_model(id, CSW_KNIFE, Hammer_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Hammer_Models[1])
        }
		else
		{
			new szModel[64]
			ArrayGetString(g_szNormalModel, random_num(0, ArraySize(g_szNormalModel) - 1), szModel, charsmax(szModel))
			
			cs_set_player_view_model(id, CSW_KNIFE, szModel)
			cs_reset_player_weap_model(id, CSW_KNIFE)
		}
    }
}

public DeathMsg(msg_id, msg_dest, id)
{
    static szTruncatedWeapon[33], iAttacker
    get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
    iAttacker = get_msg_arg_int(1)
   
    if(!is_user_valid(iAttacker) || iAttacker == get_msg_arg_int(2) || !is_user_valid(get_msg_arg_int(2))) // get_msg_arg_int(2) = iVictim
        return
   
    if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iAttacker) & CSW_KNIFE)
    {
        if(g_bCompat[id])
        {
            set_msg_arg_string(4, "Combat knife")
        }
        else if(g_bStrong[id])
        {
            set_msg_arg_string(4, "Strong knife")
        }
        else if(g_bKatana[id])
        {
            set_msg_arg_string(4, "Katana knife")
        }
        else if(g_bHammer[id])
        {
            set_msg_arg_string(4, "Ice knife")
        }
    }
}

public native_ze_open_knife_menu(id)
{
	Show_Knife_Menu(id)
}
I trynna make money, not friends.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1990
Joined: 3 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#36

Post by Raheem » 2 Years Ago

Edit:
    1. if((g_iUsedTimes[id] < get_pcvar_num(cvar_use_times)) && !ze_is_user_zombie(id) && is_user_valid(id)) && ze_get_vip_flags(id) & VIP_A)
TO
    1. if ((g_iUsedTimes[id] < get_pcvar_num(cvar_use_times)) && !ze_is_user_zombie(id) && is_user_valid(id) && (ze_get_vip_flags(id) & VIP_A))
These users thanked the author Raheem for the post:
Spir0x (2 Years Ago)
You don't know? Learn and you will know.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 626
Joined: 3 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 49 times
Age: 20
Contact:

#37

Post by Mohamed Alaa » 2 Years Ago

Take:

Code: Select all

#include <ze_vip>


native ze_open_knife_menu(id)

// Keys
const OFFSET_CSMENUCODE = 205
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

public plugin_init()
{
	register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
	
	// Commands
	register_clcmd("chooseteam", "Cmd_ChooseTeam")
	register_clcmd("say /ze", "Cmd_ChooseTeam")
	register_clcmd("say_team /ze", "Cmd_ChooseTeam")
	
	// Register Menus
	register_menu("Main Menu", KEYSMENU, "Main_Menu")
}

public Cmd_ChooseTeam(id)
{
	Show_Menu_Main(id)
	return PLUGIN_HANDLED // Kill the Choose Team Command
}

// Main Menu
public Show_Menu_Main(id)
{
	static szMenu[250]
	new iLen
    
	// Title
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
	
	// 1. Buy Weapons
	if (is_user_alive(id))
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
	}
	else
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
	}
	
	// 2. Extra Items
	if (is_user_alive(id))
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
	}
	else
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
	}
	
	// 3. Knife Menu
	if (ze_get_vip_flags(id) & VIP_D)
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w3.\r Knife Menu")
	else
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d3.  Knife Menu [VIP]")
    
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
    
	// Fix for AMXX custom menus
	set_pdata_int(id, OFFSET_CSMENUCODE, 0)
	show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
}

// Main Menu
public Main_Menu(id, key)
{
	// Player disconnected?
	if (!is_user_connected(id))
		return PLUGIN_HANDLED
    
	switch (key)
	{
		case 0: // Buy Weapons
		{
			client_cmd(id, "guns")
		}
		case 1: // Extra Items
		{
			if (is_user_alive(id))
			{
				ze_show_items_menu(id)
			}
			else
			{
				ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
			}
		}
		case 2:
		{
			if (ze_get_vip_flags(id))
				ze_open_knife_menu(id)
			else
				ze_colored_print(id, "Unavailable command,")
		}
	}
	return PLUGIN_HANDLED
}
It compiles fine.
Use default knife menu.
These users thanked the author Mohamed Alaa for the post:
Spir0x (2 Years Ago)
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 634
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#38

Post by Spir0x » 2 Years Ago

Guys Congratulations to me!! actually to jack,raheem xD ! Nice all work Thanks all +like
I trynna make money, not friends.

Taurus
Member
Member
Jordan
Posts: 1
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

#39

Post by Taurus » 2 Years Ago

Are you including your library/stocks in the plugin?

I mean something like:
#include < ze_knife_menu >

if not, you need to include it and then should compile fine :)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests