AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   i need help to limit a shopmenu (https://forums.alliedmods.net/showthread.php?t=326111)

abdelwahab 07-18-2020 18:24

i need help to limit a shopmenu
 
Hello guys i am here i want help to limit this shopmenu can u help me ?
i want for 1000 HP you can buy it one in 1 round
buff m4a1 4 per map
jetpack 5 per map
Nemesis(1 per map)
survivor(1 per map)
assassin(1 per map)
sniper (1 per map)
Thanks
This is the code
Quote:

#include <amxmodx>
#include <fun>
#include <zombieplague>
#include <pointweapons>

new Point[33], cvar_head_points, cvar_not_head_points

public plugin_natives()
{
register_native("zp_get_user_points", "native_get_user_points", 1)
register_native("zp_set_user_points", "native_set_user_points", 1)
register_native("zp_reset_user_points", "native_reset_user_points", 1)
}

public native_get_user_points(id)
{
return Point[id]
}
public plugin_precache(){
precache_sound("zombie_plague/buymode.wav")
}

public native_set_user_points(id, amount)
{
Point[id] = amount
}

public native_reset_user_points(id)
{
Point[id] = 0
}

public plugin_init()
{
register_plugin("[ZP43] Addons: Points", "3.0", "OPkiller Gaming")
register_clcmd("say /shop", "point_menu")
register_clcmd("say_team /shop", "point_menu")

// Cvars
cvar_not_head_points = register_cvar("zp_points_normal_reward", "1") // Points reward for a player who kills ZM in anyplace execpt head
cvar_head_points = register_cvar("zp_points_head_reward", "1") // Points reward for a player who kills ZM in head
}


public client_death(killer,victim,weapon,hitplace,TK )
{
if(hitplace == HIT_HEAD)
{
Point[killer] += get_pcvar_num(cvar_head_points)
}
else
{
Point[killer] += get_pcvar_num(cvar_not_head_points)
}

}



public point_menu(id)
{
if(zp_get_user_assassin(id) || zp_get_user_sniper(id) || zp_get_user_survivor(id) || zp_get_user_nemesis(id) || zp_is_assassin_round() || zp_is_nemesis_round() || zp_is_apocalypse_round() || zp_is_armageddon_round() || zp_is_assassin_round() || zp_is_nemesis_round() || zp_is_nightmare_round() || zp_is_plague_round() || zp_is_swarm_round())
{
client_print_color(id,"!t[!gZP!t]!nYou canno't use !gshopmenu !nright now !")
}else
{
new menu = menu_create( "\rShop Menu", "point_handler")
menu_additem( menu, "\wBuy \r1000 Health \wFor 25 \ypoint", "1", 0 )
menu_additem( menu, "\wBuy \r500 ammo packs \wFor 30 \ypoint", "2", 0 )
menu_additem( menu, "\wBuy \rBuff M4 \wFor 40 \ypoint", "3", 0 )
menu_additem( menu, "\wBuy \rJetpack+Bazooka \wFor 45 \ypoint", "4", 0 )
menu_additem( menu, "\wBuy \rNemesis (Only First Zombie) \wFor 150 \ypoint", "5", 0 )
menu_additem( menu, "\wBuy \rSurvivor (Only Last Human) \wFor 200 \ypoint", "6", 0 )
menu_additem( menu, "\wBuy \rAssassin (Only First Zombie) \wFor 120 \ypoint", "7", 0 )
menu_additem( menu, "\wBuy \rSniper (Only Last Human) \wFor 160 \ypoint", "8", 0 )
menu_display( id, menu, 0 )
}
}

public point_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

switch(item)
{
case 0:
{
if(Point[id] >= 25 && !zp_get_user_zombie(id))
{
set_user_health(id,get_user_health(id) + 1000)
client_print_color(id,"!t[!gZP!t] !nYou have bought !g1000 hp !nfor 25 !gpoints!");
Point[id] -= 25
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough points or ur !gzombie , !gassassin , !gsurvivor !nect..")
}
}
case 1:
{
if(Point[id] >= 30 && !zp_get_user_zombie(id))
{
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + 500)
client_print_color(id,"!t[!gZP!t] !nou have bought !g500 ammo packs !nfor 30 points!");
Point[id] -= 30
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough points or You are !gzombie , !gassassin , !gsurvivor !nect..")

}
}
case 2:
{
if(Point[id] >= 40 && !zp_get_user_zombie(id))
{
give_weapon_buffm4(id)
client_print_color(id,"!t[!gZP!t] !nYou have bought !gBuff M4 !nfor 40 points!");
Point[id] -= 40
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough points or You are !gzombie , !gassassin , !gsurvivor !nect..")

}
}
case 3:
{
if(Point[id] >= 45 && !zp_get_user_zombie(id)){
points_get_jetpack(id)
client_print_color(id,"!t[!gZP!t] !nYou have bought !gJetpack+Bazooka !nfor !n45 !gpoint!n!")
Point[id] -= 45
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough points or You are !gzombie , !gassassin , !gsurvivor !nect..")

}
}
case 4:
{
if(Point[id] >= 150 && zp_get_user_first_zombie(id))
{
new ZsName[32]
get_user_name(id,ZsName,32)
zp_make_user_nemesis(id)
client_print_color(0,"!gHeyyy , !nBe Ready !g%s !nbought !gnemesis !nfrom shopmenu try to kill him and get !greward!!",ZsName)
client_cmd(0,"spk ^"sound/zombie_plague/buymode.wav^"")
Point[id] -= 150
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough !gpoints !nor You are !nNot !gFirst Zombie")
}
}
case 5:
{
if(Point[id] >= 200 && zp_get_user_last_human(id))
{
new ZsName[32]
get_user_name(id,ZsName,32)
zp_make_user_survivor(id)
client_print_color(0,"!t[!gZP!t] !gHeyyy , !nBe Ready !g%s !nbought !gSurvivor !nfrom shopmenu try to kill him and get !greward!!",ZsName)
client_cmd(0,"spk ^"sound/zombie_plague/buymode.wav^"")
Point[id] -= 200
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough !gpoints !nor You are !nNot !gLast Human")
}
}
case 6:
{
if(Point[id] >= 120 && zp_get_user_first_zombie(id))
{
new ZsName[32]
get_user_name(id,ZsName,32)
zp_make_user_assassin(id)
client_print_color(0,"!t[!gZP!t] !gHeyyy , !nBe Ready !g%s !nbought !gAssassin !nfrom shopmenu try to kill him and get !greward!!",ZsName)
client_cmd(0,"spk ^"sound/zombie_plague/buymode.wav^"")
Point[id] -= 120
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough !gpoints !nor You are !nNot !gFirst Zombie")
}
}
case 7:
{
if(Point[id] >= 160 && zp_get_user_last_human(id))
{
new Snipname[32]
get_user_name(id,Snipname,32)
zp_make_user_sniper(id)
client_print_color(0,"!t[!gZP!t] !gHeyyy , !nBe Ready !g%s !nbought !gSniper !nfrom shopmenu try to kill him and get !greward!!",Snipname)
client_cmd(0,"spk ^"sound/zombie_plague/buymode.wav^"")
Point[id] -= 160
}
else
{
client_print_color(id,"!t[!gZP!t] !nHey Maybe u don't have enough !gpoints !nor You are !nNot !gLast Human")
}
}


}

menu_destroy(menu)
return PLUGIN_HANDLED
}

stock client_print_color(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);

replace_all(msg, 190, "!g", "^x04"); // Green Color
replace_all(msg, 190, "!n", "^x01"); // Default Color
replace_all(msg, 190, "!t", "^x03"); // Team Color

if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}

Napoleon_be 07-20-2020 07:48

Re: i need help to limit a shopmenu
 
Use booleans, else post in suggestions/requests


All times are GMT -4. The time now is 13:52.

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