Raised This Month: $248 Target: $400
 62% 

id goes to 0


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnimalMonster
Member
Join Date: May 2020
Old 09-08-2020 , 10:26   id goes to 0
Reply With Quote #1

hey, i made shop plugin but when menu_display is called for showing the shop id goes to 0
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <cstrike>

#define PLUGIN "[FRN] Furien Shop"
#define VERSION "1.0"
#define AUTHOR "DeclineD"
#define levels 21

new numbers
new knives[33]
new 
hasknife[33]

new 
playershopaf
new playershopf

new TextMsg

new v_knife_1[] = {"models/s-knifes/v_first.mdl"}
new 
v_knife_2[] = {"models/s-knifes/v_second.mdl"}
new 
v_knife_3[] = {"models/s-knifes/v_third.mdl"}
new 
v_knife_4[] = {"models/s-knifes/v_fourth.mdl"}
new 
v_knife_5[] = {"models/s-knifes/v_fifth.mdl"}
new 
v_knife_6[] = {"models/s-knifes/v_sixth.mdl"}
new 
v_knife_7[] = {"models/s_knifes/v_seventh.mdl"}
new 
v_knife_8[] = {"models/s_knifes/v_eighth.mdl"}

new 
p_knife_1[] = {"models/s-knifes/p_first.mdl"}
new 
p_knife_2[] = {"models/s-knifes/p_second.mdl"}
new 
p_knife_3[] = {"models/s-knifes/p_third.mdl"}
new 
p_knife_4[] = {"models/s-knifes/p_fourth.mdl"}
new 
p_knife_5[] = {"models/s-knifes/p_fifth.mdl"}
new 
p_knife_6[] = {"models/s-knifes/p_sixth.mdl"}
new 
p_knife_7[] = {"models/s-knifes/p_seventh.mdl"}
new 
p_knife_8[] = {"models/s_knifes/p_eighth.mdl"}

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /shop","clcmd_shop")
    
RegisterHam(Ham_TakeDamage"player""TAKEDAMAGE")
    
RegisterHam(Ham_Killed"player""Death")
    
register_forward(FM_PlayerPreThink"FWD_PreThink")

    
TextMsg get_user_msgid("SayText")
}

public 
plugin_precache()
{
    
precache_model(v_knife_1)
    
precache_model(v_knife_2)
    
precache_model(v_knife_3)
    
precache_model(v_knife_4)
    
precache_model(v_knife_5)
    
precache_model(v_knife_6)
    
    
precache_model(p_knife_1)
    
precache_model(p_knife_2)
    
precache_model(p_knife_3)
    
precache_model(p_knife_4)
    
precache_model(p_knife_5)
    
precache_model(p_knife_6)
}
public 
clcmd_shop(id)
{
    if(
get_user_team(id) == 1)
    {
        
menu_display(idplayershopf)
    }
    else if(
get_user_team(id) == 2)
    {
        
menu_display(idplayershopaf)
    }
}

public 
Death(id)
{
    
hasknife[id] = false
}

public 
TAKEDAMAGE(victiminflictorattackerFloat:Damagedmgbitsid)
{
    new 
knife = (get_user_weapon(id) == CSW_KNIFE)

    if(
hasknife[id] && knife && get_user_team(id) == 1)
    {
        
SetHamParamFloat(4Damage 1.5)
    }
    else 
SetHamParamFloat(4Damage 1)
}

public 
ShopPlayeraf(id)
{
    new 
len
    
new text[512]
    
    
playershopaf menu_create("UR BEAUTY SHOP""ShopHandleraf")
    
    if((
get_user_health(id) < 255) && get_user_health(id) > 215)
    {
        
len formatex(text[len], charsmax(text), "Hp \y[\r+%s\y] \w[\y2500$\w]"get_user_health(id) - 255)
    }
    
    if((
get_user_health(id) < 255) && get_user_health(id) < 215)
    {
        
len formatex(text[len], charsmax(text), "Hp \y[\r+40\y] \w[\y2500$\w]")
    }
    
    if(
get_user_health(id) >= 255)
    {
        
len formatex(text[len], charsmax(text), "\dHp (Unavailable)")
    }

    
menu_additem(playershopaf,text)
    
menu_additem(playershopaf,"Armor \y[\r+30\y] \w[\y1000$\w]")
    
menu_additem(playershopaf,"\rDefuse \wKit \r[\y800$\r]")
    
menu_setprop(playershopafMPROP_EXITMENU_EXIT)
    
}

public 
ShopHandleraf(iditem)
{
    if(
item == MENU_EXIT)
    {
        
menu_cancel(id)
    }
    
    switch(
playershopaf)
    {
        case 
0: {
            if(
cs_get_user_money(id) >= 2500)
            {
                
cs_set_user_money(idcs_get_user_money(id) - 2500)
            }
            else return

            if(
get_user_health(id) < 255)
            {
                
set_user_health(idget_user_health(id) + 30)
                
set_dhudmessage(020250, -1.00.7020.22.00.20.5)
                
show_dhudmessage(id"[+30 Hp]")
            }
            else if(
get_user_health(id) >= 255)
            {
                
set_user_health(id255)
            }
        }
        case 
1:{
            if(
cs_get_user_money(id) >= 1000)
            {
                
cs_set_user_money(idcs_get_user_money(id) - 1000)
            }
            else return
    
            if(
get_user_armor(id) < 300)
            {
                
set_user_armor(idget_user_armor(id) + 30)
                
set_dhudmessage(0202500.50.7020.22.00.20.5)
                
show_dhudmessage(id"[+30 Armor]")
            }
            else if(
get_user_armor(id) >= 300)
            {
                
set_user_health(id255)
            }
        }

        case 
2:{
            if(
cs_get_user_money(id) >= 800)
            {
                
cs_set_user_money(idcs_get_user_money(id) - 800)
            }
            else return

            
give_item(id"item_thighpack")
        }
    }
}

public 
ShopPlayerf(id)
{
    new 
len
    
new text[512]

    
playershopf menu_create("UR BEAUTY SHOP""ShopHandlerf")
    
    if((
get_user_health(id) < 255) && get_user_health(id) > 215)
    {
        
len formatex(text[len], charsmax(text), "Hp \y[\r+%s\y] \w[\y2500$\w]"get_user_health(id) - 255)
    }
    
    if((
get_user_health(id) < 255) && get_user_health(id) < 215)
    {
        
len formatex(text[len], charsmax(text), "Hp \y[\r+40\y] \w[\y2500$\w]")
    }
    
    if(
get_user_health(id) >= 255)
    {
        
len formatex(text[len], charsmax(text), "\dHp (Unavailable)")
    }

    
menu_additem(playershopftext)
    
menu_additem(playershopf"Armor \y[\r+30\y] \w[\y500$\w]")
    
menu_additem(playershopf"\yLucky \wS-Knife \rWheel \w[\y6000$\w]")
    
menu_additem(playershopf"\yChoose Your S-Knife \w[\y7000$\w] [V.I.P.]","4"ADMIN_LEVEL_D)
    
menu_setprop(playershopfMPROP_EXITMENU_EXIT)
}

public 
ShopHandlerf(iditem)
{
    if(
item == MENU_EXIT)
    {
        
menu_cancel(id)
    }
    
    switch(
playershopaf)
    {
        case 
0: {
            if(
cs_get_user_money(id) >= 2500)
            {
                
cs_set_user_money(idcs_get_user_money(id) - 2500)
            }
            else return

            if(
get_user_health(id) < 255)
            {
                
set_user_health(idget_user_health(id) + 30)
                
set_dhudmessage(020250, -1.00.7020.22.00.20.5)
                
show_dhudmessage(id"[+30 Hp]")
            }
            else if(
get_user_health(id) >= 255)
            {
                
set_user_health(id255)
            }
        }
        case 
1:{
            if(
cs_get_user_money(id) >= 500)
            {
                
cs_set_user_money(idcs_get_user_money(id) - 500)
            }
            else return

            if(
get_user_armor(id) < 300)
            {
                
set_user_armor(idget_user_armor(id) + 30)
                
set_dhudmessage(0202500.50.7020.22.00.20.5)
                
show_dhudmessage(id"[+30 Armor]")
            }
            else if(
get_user_armor(id) >= 300)
            {
                
set_user_health(id255)
            }
        }

        case 
2:{
            if(
cs_get_user_money(id) >= 6000)
            {
                
cs_set_user_money(idcs_get_user_money(id) - 6000)
            }
            else return

            
Prepare(id)
        }
        
        case 
3:{
            if(
cs_get_user_money(id) >= 7000 && get_user_flags(id) && ADMIN_LEVEL_D)
            {
                
cs_set_user_money(idcs_get_user_money(id) - 7000)
            }
            else return

            if(
get_user_flags(id) && ADMIN_LEVEL_D)
            {
                
show_skins_menu(id)
            }
            else 
message_begin(MSG_ONETextMsg,_,id)
            
write_byte(id)
            
write_string("^x04[Furien]^x01: Only Vip Ranks Has Acces!")
            
message_end()
        }
    }
}

Prepare(id)
{
    
numbers 8
    set_task
(0.2,"Spin",id,_,_,"a",numbers)
}

Spin(id)
{
    
knives[id] = random_num(1,numbers)
    
hasknife[id] = true

    
if(knives[id] == 1)
    {
        
set_pev(idpev_weaponmodel2p_knife_1)
        
set_pev(idpev_viewmodel2v_knife_1)
    }
    
    if(
knives[id] == 2)
    {
        
set_pev(idpev_weaponmodel2p_knife_2)
        
set_pev(idpev_viewmodel2v_knife_2)
    }
    
    if(
knives[id] == 3)
    {
        
set_pev(idpev_weaponmodel2p_knife_3)
        
set_pev(idpev_viewmodel2v_knife_3)
    }
    
    if(
knives[id] == 4)
    {
        
set_pev(idpev_weaponmodel2p_knife_4)
        
set_pev(idpev_viewmodel2v_knife_4)
    }
    
    if(
knives[id] == 5)
    {
        
set_pev(idpev_weaponmodel2p_knife_5)
        
set_pev(idpev_viewmodel2v_knife_5)
    }
    
    if(
knives[id] == 6)
    {
        
set_pev(idpev_weaponmodel2p_knife_6)
        
set_pev(idpev_viewmodel2v_knife_6)
    }
    
    if(
knives[id] == 7)
    {
        
set_pev(idpev_weaponmodel2p_knife_7)
        
set_pev(idpev_viewmodel2v_knife_7)
    }
    
    if(
knives[id] == 8)
    {
        
set_pev(idpev_weaponmodel2p_knife_8)
        
set_pev(idpev_viewmodel2v_knife_8)
    }
}

public 
show_skins_menu(id)
{
    new 
len
    
new text[512]
    new 
name[33]
    
    
len formatex(textcharsmax(text), "Choose Your Knife ,Lord %s"get_user_name(idname32))

    new 
menu menu_create(text"skinshandler")
    
    
menu_additem(menu"\yBu\rlava \w[\yKNIFE\w]")
    
menu_additem(menu"\yDual \rXMas \w[\yKNIVES\w]")
    
menu_additem(menu"\yDr\rag\yon \rXMas \w[\yCSO SWORD\w]")
    
menu_additem(menu"\yK\ro\ysa \w[\ySCYTHE\w]")
    
menu_additem(menu"\yAnc\ri\yent \w[\yLIL HAMMER\w]")
    
menu_additem(menu"\yAnc\ri\yent \w[\yAXE\w]")
    
menu_additem(menu"\rGun\rkata \w[\yAXE\w]")
    
menu_additem(menu"\rMeta\ytroic w\[\yAXE\w]")
    
    
menu_display(idmenu)
}

public 
skinshandler(idmenu)
{
    switch(
menu)
    {
        case 
0: {
            
set_pev(idpev_weaponmodel2p_knife_1)
            
set_pev(idpev_viewmodel2v_knife_1)
        }
        
        case 
1:{
            
set_pev(idpev_weaponmodel2p_knife_2)
            
set_pev(idpev_viewmodel2v_knife_2)
        }
        
        case 
2:{
            
set_pev(idpev_weaponmodel2p_knife_3)
            
set_pev(idpev_viewmodel2v_knife_3)
        }
        
        case 
3:{
            
set_pev(idpev_weaponmodel2p_knife_4)
            
set_pev(idpev_viewmodel2v_knife_4)
        }
        
        case 
4:{
            
set_pev(idpev_weaponmodel2p_knife_5)
            
set_pev(idpev_viewmodel2v_knife_5)
        }
        
        case 
5:{
            
set_pev(idpev_weaponmodel2p_knife_6)
            
set_pev(idpev_viewmodel2v_knife_6)
        }
        
        case 
6:{
            
set_pev(idpev_weaponmodel2p_knife_7)
            
set_pev(idpev_viewmodel2v_knife_7)
        }
        
        case 
7:{
            
set_pev(idpev_weaponmodel2p_knife_8)
            
set_pev(idpev_viewmodel2v_knife_8)
        }
    }

__________________
A little of scripting makes a MIRACLE.
=============================================
DeclineD#7346 // for everyone who wants a friend..

Last edited by AnimalMonster; 09-08-2020 at 10:26.
AnimalMonster is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-08-2020 , 21:58   Re: id goes to 0
Reply With Quote #2

When you have an issue, you need to better explain what your issue actually is because your one sentence makes no sense.

After quickly going over your code, it looks like you are making things more complicated than it needs to be. Don't try to do global menus, especially since you're doing user-specific items. Simply create the menu when the player uses the chat command, display it there, and then destroy it in the handler.
__________________
fysiks is offline
AnimalMonster
Member
Join Date: May 2020
Old 09-11-2020 , 17:33   Re: id goes to 0
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
When you have an issue, you need to better explain what your issue actually is because your one sentence makes no sense.

After quickly going over your code, it looks like you are making things more complicated than it needs to be. Don't try to do global menus, especially since you're doing user-specific items. Simply create the menu when the player uses the chat command, display it there, and then destroy it in the handler.
Do not reply bcs im pretty d**b and yeah, i already solved.
__________________
A little of scripting makes a MIRACLE.
=============================================
DeclineD#7346 // for everyone who wants a friend..

Last edited by AnimalMonster; 09-11-2020 at 17:34.
AnimalMonster is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-12-2020 , 00:25   Re: id goes to 0
Reply With Quote #4

Quote:
Originally Posted by AnimalMonster View Post
Do not reply bcs im pretty d**b
What?!?!
__________________
fysiks is offline
generalmemer
Member
Join Date: Sep 2017
Old 09-12-2020 , 04:31   Re: id goes to 0
Reply With Quote #5

Quote:
Originally Posted by AnimalMonster View Post
Do not reply bcs im pretty d**b and yeah, i already solved.
Yeah no that's not how it works here. If you've solved your issue you should edit the thread title as solved and post the solution. Also you should keep in mind that someone took the time to read you code and you just got some decent advice for the script, that's a very inconsiderate thing to say after. You don't tell people not to reply after you submit a thread asking for help
generalmemer is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-12-2020 , 08:00   Re: id goes to 0
Reply With Quote #6

The code is garbage I'd recommend to start over.
__________________
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply


Thread Tools
Display Modes

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 07:59.


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