Raised This Month: $51 Target: $400
 12% 

[HELP] With The Shop Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 03-09-2014 , 13:39   [HELP] With The Shop Plugin
Reply With Quote #1

Hi, all!!! All day i'm making this Shop Plugin, but all the time - errors and more errors. I'll post you the code, and if someone could help me, it'll be great!
PHP Code:
#pragma semicolon 1

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
#include <vault>

// Define the Plugin Version
new const VERSION[] = { "1.0" };

// PREFIX
new const PREFIX[] = { "^x3[CS-MaxgaminG.iNFO]!n" };


public 
plugin_init()
{
    
register_plugin("HNS Shop"VERSION"flicker");
    
RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1);
    
RegisterHam(Ham_Item_PreFrame"player""FwdPreFrame_Post"1);
    
RegisterHam(Ham_TakeDamage"player""FwdPlayerDamage");
    
//RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
    
    
register_event("CurWeapon","event_curweapon","be","1=1");
    
    
register_clcmd("say /shop""cmdVmenu");
    
register_clcmd("say_team /shop""cmdVmenu");
    
//g_pVisiblity = register_cvar( "km_invis", "200" ); // 255 = clearly visible
    
set_task(480.0"kmodmsg"0__"b");
    
    
    
    
// Ham TakeDamage
    
register_forwardFM_CmdStart"fw_CmdStart" );
    
//RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);



public 
cmdVmenu(id)
{
    new 
menu menu_create("\yHNS Shop:^n\r""Vmenu");
    
    
menu_additem(menu"\wAWP""1"0);
    
menu_additem(menu"\wScout""2"0);
    
menu_additem(menu"\wDeagle""3"0);
    
menu_additem(menu"\wAK47""4"0);
    
menu_additem(menu"\wM4A1""5"0);
    
menu_additem(menu"\wHE Grenade""6"0);
    
menu_additem(menu"\wFlashbang""7"0);
    
menu_additem(menu"\wSmoke Grenade""8"0);
    
menu_additem(menu"\w+ 100 Armor""9"0);
    
menu_additem(menu"\w+ 40 Health""10"0);
    
menu_display(idmenu);
}

public 
Vmenu(idmenuitem)
{    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 8000;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
cs_set_weapon_ammo(give_item(id"weapon_awp" ), 1);
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gAWP!n"PREFIX);
        }
        
        case 
2:
        
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 5000;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
cs_set_weapon_ammo(give_item(id"weapon_scout" ), 1);
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gScout!n"PREFIX);
            
        }
        
        case 
3:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 6700;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
cs_set_weapon_ammo(give_item(id"weapon_deagle" ), 1);
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gDeagle!n"PREFIX);
        }
        
        case 
4:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 6700;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
cs_set_weapon_ammo(give_item(id"weapon_ak47" ), 1);
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gAK47!n"PREFIX);
        }
        case 
5:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 6850;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
cs_set_weapon_ammo(give_item(id"weapon_m4a1" ), 1);
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gM4A1!n"PREFIX);
        }
        case 
6:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 5500;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
give_item(id,"weapon_hegrenade");
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gHE Grenade!n"PREFIX);
        }
        case 
7:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 3500;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
give_item(id,"weapon_flashbang");
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gFlashbang!n"PREFIX);
        }
        
        case 
8:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 4000;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
give_item(id,"weapon_smokegrenade");
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !gSmoke Grenade!n"PREFIX);
        }
        
        case 
9:
        
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 14000;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) < iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
set_user_armor(idget_user_armor(id) + 100);
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"%s !tTi kupi !g100 Armor!n"PREFIX);
        }
        
        case 
10:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 12500;
            if (!(
is_user_alive(id)))
                
                
ColorMessage(id"^1You have to be ^4alive^1 to buy this!");
                return 
PLUGIN_HANDLED;
                
                if (!(
cs_get_user_money(id) >= iPrice))
                
                
ColorMessage(id"^1You cant ^4afford^1 this weapon!");
                return 
PLUGIN_HANDLED;
                
                if (
get_user_weapon(id) == CSW_DEAGLE)
                
                
ColorMessage(id"^1You ^4already^1 have this weapon!");
                return 
PLUGIN_HANDLED;
                
            
set_user_health(idget_user_health(id) + 40);
            
cs_set_user_money(idiMoney iPrice);    
            
ColorMessage(id"%s !tTi kupi !g40 HP!n"PREFIX);
        }
        


    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}



stock ColorMessage(const id, const input[], any:...){
            new 
count 1players[32];
            static 
msg191 ];
            
vformat(msg190input3);
            if (
idplayers[0] = id; else get_players(players count "ch"); {
                for (new 
0counti++){
                    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();}}}
        } 
There it is. For me, there's no problem. But when i type /shop in the chat, nothing happens.... The plugin is running, but nothing.. PLEASE, HELP!

Last edited by Flick3rR; 03-09-2014 at 13:56.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
wickedd
Veteran Member
Join Date: Nov 2009
Old 03-09-2014 , 14:38   Re: [HELP] With The Shop Plugin
Reply With Quote #2

After at quick glance, I'm sure you got some warnings when compiling it.

Do you know what "return PLUGIN_HANDLED" means?
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.

Last edited by wickedd; 03-09-2014 at 14:44.
wickedd is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 03-09-2014 , 15:05   Re: [HELP] With The Shop Plugin
Reply With Quote #3

I had 48 warnings, losing indentation mostly. I didn't want to play with this, so I ignored it. Aboute the PLUGIN_HANDLED, idk what does it exactly mean, but i made this code with one other dude, who told me to do it like this. If you know why it's not working, please help. I think that you got the idea of all these cases, so if you know some other way, you can share it.

Last edited by Flick3rR; 03-09-2014 at 15:09.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
wickedd
Veteran Member
Join Date: Nov 2009
Old 03-09-2014 , 15:12   Re: [HELP] With The Shop Plugin
Reply With Quote #4

PHP Code:
    RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1);
    
RegisterHam(Ham_Item_PreFrame"player""FwdPreFrame_Post"1);
    
RegisterHam(Ham_TakeDamage"player""FwdPlayerDamage");
    
//RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
    
    
register_event("CurWeapon","event_curweapon","be","1=1");
    
    
register_clcmd("say /shop""cmdVmenu");
    
register_clcmd("say_team /shop""cmdVmenu");
    
//g_pVisiblity = register_cvar( "km_invis", "200" ); // 255 = clearly visible
    
set_task(480.0"kmodmsg"0__"b");
    
    
    
    
// Ham TakeDamage
    
register_forwardFM_CmdStart"fw_CmdStart" );
    
//RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1); 


PHP Code:
    //RegisterHam(Ham_Spawn, "player", "FwdHamSpawn_Post", 1);
   //RegisterHam(Ham_Item_PreFrame, "player", "FwdPreFrame_Post", 1);
    //RegisterHam(Ham_TakeDamage, "player", "FwdPlayerDamage");
    //RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
    
    //register_event("CurWeapon","event_curweapon","be","1=1");
    
    
register_clcmd("say /shop""cmdVmenu");
    
register_clcmd("say_team /shop""cmdVmenu");
    
//g_pVisiblity = register_cvar( "km_invis", "200" ); // 255 = clearly visible
   // set_task(480.0, "kmodmsg", 0, _, _, "b");
    
    
    
    // Ham TakeDamage
    
register_forwardFM_CmdStart"fw_CmdStart" );
    
//RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1); 
The menu should appear, but it will not give any items because of
return PLUGIN_HANDLED.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.

Last edited by wickedd; 03-09-2014 at 15:13.
wickedd is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 03-09-2014 , 15:47   Re: [HELP] With The Shop Plugin
Reply With Quote #5

These return PLUGIN_HANDLED are made to not give items, in the next conditions: if you dont have enough money or if you are dead. When is writen to give you item, there's not plugin_handled. About the menu appearing, i hope it'll work. I'll post what happened. ;)

EDIT:
You were damn right, man! The menu appeared, but it didnt give me nothing. Allright, can you tell me how to make it? Give me an example of the structure ot one case and i'll made the others. THANKS A LOT!!!

EDIT:
Thanks a lot, dude! I fixed it myself, by putting {} on each "if". I got perfect plugin thanks to all of you!

Last edited by Flick3rR; 03-09-2014 at 16:01.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 17:26.


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