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

Error when buy cocaina


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xfire97
Member
Join Date: Aug 2011
Old 02-28-2012 , 18:01   Error when buy cocaina
Reply With Quote #1

Hello, i make a menu, i want this:
when a player buy Cocaina the speed change for 310.0
when a player buy Heroina the speed change for 350.0
when a player buy Marijuana the speed change for 360.0

and the speed and the all things the player buy during 1 round only.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

#define PLUGIN "Drogas"
#define VERSION "1.0"
#define AUTHOR "Rocha"


public plugin_init() 
{
    
register_plugin("Drogas""1.0""Rocha")
    
    
register_clcmd"say /drogas","DrogasMenu");
    
    
RegisterHam(Ham_Spawn"player""ronda"1);
}

public 
ronda(id)
{
        
set_task(0.1"DrogasMenu"id)
    
}
public 
DrogasMenu(id)
{
    new 
menu menu_create("\r[Drogas Menu]\yEscolhe a tua Droga:""menu_handler");
    
    
menu_additem(menu"\wPolen""1"0);
    
menu_additem(menu"\wErva""2"0);
    
menu_additem(menu"\wCogumelos""3"0);
    
menu_additem(menu"\wLSD""4"0);
    
menu_additem(menu"\wCocaina""5"0);
    
menu_additem(menu"\rHeroina""6"ADMIN_RESERVATION);
    
menu_additem(menu"\rCrack""7"ADMIN_RESERVATION);
    
menu_additem(menu"\rMarijuana""8"ADMIN_RESERVATION);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
    
menu_display(idmenu0);
    
}
public 
menu_handler(idmenuitem)
{
    new 
health get_user_health(id)
    new 
frags get_user_frags(id)
    new 
money cs_get_user_money(id)
    {
    if (
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
        return 
PLUGIN_HANDLED;
    }
    if(
is_user_alive(id))
    {
        
    new 
data[6], iName[64]
    new 
acesscallback
    
    menu_item_getinfo
(menuitemacessdata5iName63callback);
    
    new 
key str_to_num(data);
    
    switch (
key)
    {
        case 
1:
        {
            
client_print(idprint_chat"Esta pedra de polen era boa, ganhas te 10 HP");
            
set_user_health(idhealth 10);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
2:
        {
            
client_print(idprint_chat"Ganda Saquinho de Erva, ganhas te 15 HP");
            
set_user_health(idhealth 15);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
3:
        {
            
client_print(idprint_chat"Ganda alucinacao, acho que matei alguem");
            
set_user_frags(idfrags 1);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
4:
        {
            
client_print(idprint_chat"Este LSD, tou mesmo relaxado, ganhei ainda 750$");
            
cs_set_user_money(idmoney 750);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
5:
        {
            
client_print(idprint_chat"Cocaina da boa, ate corro mais rapido, adrenalina!");
            
set_user_maxspeed(id310.0);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
6:
        {
            
client_print(idprint_chat"Heroina de qualidade, corro mais rapido e tenho mais saude!");
            
set_user_maxspeed(id350.0);
            
set_user_health(idhealth 25);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
7:
        {
            
client_print(idprint_chat"Crack do melhor, ganhei 25 HP, e ainda ganhei 850$");
            
set_user_health(idhealth 25);
            
cs_set_user_money(idmoney 850);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
8:
        {
            
client_print(idprint_chat"Marijuana do Mexico, da me alto speed e saude, e ainda vendo!");
            
set_user_maxspeed(id360.0);
            
set_user_health(idhealth 30);
            
cs_set_user_money(idmoney 1000);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
    }
    
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

xfire97 is offline
xfire97
Member
Join Date: Aug 2011
Old 02-28-2012 , 18:26   Re: Give velocity when buy
Reply With Quote #2

can this resolved it?
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

#define PLUGIN "Drogas"
#define VERSION "1.0"
#define AUTHOR "Rocha"

new speed_cvar
new speed_cvar1
new speed_cvar2

public plugin_init() 
{
    
register_plugin("Drogas""1.0""Rocha")
    
    
register_clcmd"say /drogas","DrogasMenu");
    
    
RegisterHam(Ham_Spawn"player""ronda"1);
    
    
speed_cvar register_cvar ("dc""310.0")
    
    
speed_cvar1 register_cvar "dh""340.0")
    
    
speed_cvar2 register_cvar "dh""360")
}

public 
ronda(id)
{
        
set_task(0.1"DrogasMenu"id)
    
}
public 
DrogasMenu(id)
{
    new 
menu menu_create("\r[Drogas Menu]\yEscolhe a tua Droga:""menu_handler");
    
    
menu_additem(menu"\wPolen""1"0);
    
menu_additem(menu"\wErva""2"0);
    
menu_additem(menu"\wCogumelos""3"0);
    
menu_additem(menu"\wLSD""4"0);
    
menu_additem(menu"\wCocaina""5"0);
    
menu_additem(menu"\rHeroina""6"ADMIN_RESERVATION);
    
menu_additem(menu"\rCrack""7"ADMIN_RESERVATION);
    
menu_additem(menu"\rMarijuana""8"ADMIN_RESERVATION);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
    
menu_display(idmenu0);
    
}
public 
menu_handler(idmenuitem)
{
    new 
health get_user_health(id)
    new 
frags get_user_frags(id)
    new 
money cs_get_user_money(id)
    {
    if (
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
        return 
PLUGIN_HANDLED;
    }
    if(
is_user_alive(id))
    {
        
    new 
data[6], iName[64]
    new 
acesscallback
    
    menu_item_getinfo
(menuitemacessdata5iName63callback);
    
    new 
key str_to_num(data);
    
    switch (
key)
    {
        case 
1:
        {
            
client_print(idprint_chat"Esta pedra de polen era boa, ganhas te 10 HP");
            
set_user_health(idhealth 10);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
2:
        {
            
client_print(idprint_chat"Ganda Saquinho de Erva, ganhas te 15 HP");
            
set_user_health(idhealth 15);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
3:
        {
            
client_print(idprint_chat"Ganda alucinacao, acho que matei alguem");
            
set_user_frags(idfrags 1);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
4:
        {
            
client_print(idprint_chat"Este LSD, tou mesmo relaxado, ganhei ainda 750$");
            
cs_set_user_money(idmoney 750);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
5:
        {
            
client_print(idprint_chat"Cocaina da boa, ate corro mais rapido, adrenalina!");
            
set_user_maxspeed(id,get_pcvar_float(speed_cvar));
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
6:
        {
            
client_print(idprint_chat"Heroina de qualidade, corro mais rapido e tenho mais saude!");
            
set_user_maxspeed(id,get_pcvar_float(speed_cvar1));
            
set_user_health(idhealth 25);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
7:
        {
            
client_print(idprint_chat"Crack do melhor, ganhei 25 HP, e ainda ganhei 850$");
            
set_user_health(idhealth 25);
            
cs_set_user_money(idmoney 850);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
8:
        {
            
client_print(idprint_chat"Marijuana do Mexico, da me alto speed e saude, e ainda vendo!");
            
set_user_maxspeed(id,get_pcvar_float(speed_cvar2));
            
set_user_health(idhealth 30);
            
cs_set_user_money(idmoney 1000);
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
    }
    
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

xfire97 is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 02-28-2012 , 22:41   Re: Give velocity when buy
Reply With Quote #3

not realistic buying weed and being faster....

Check out Exolents Shop Menu API
Doc-Holiday is offline
xfire97
Member
Join Date: Aug 2011
Old 02-29-2012 , 12:00   Re: Give velocity when buy
Reply With Quote #4

But counter strike is not really and u play counter strike.
I want help not comments, i see the shop menu api dont help me in nothing because i dont understand pro scripting.

I want that the speed during 1 round only and player only can buy a drog 1 time per round.
xfire97 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-29-2012 , 12:23   Re: Give velocity when buy
Reply With Quote #5

Quote:
Originally Posted by xfire97 View Post
I want help not comments, i see the shop menu api dont help me in nothing because i dont understand pro scripting.
The API makes it easier to make shops, not harder.
For example:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <shop>

// enumerate our items
enum _:Items {
    
Item_Polen,
    
Item_Erva,
    
Item_Cogumelos,
    
Item_LSD,
    
Item_Cocaina,
    
Item_Heroina,
    
Item_Crack,
    
Item_Marijuana
};

// create the names for each
new const gItemNames[Items][] = {
    
"Polen",
    
"Erva",
    
"Cogumelos",
    
"LSD",
    
"Cocaina",
    
"Heroina",
    
"Crack",
    
"Marijuana"
};

// setup the short names of the items
new const gItemShortNames[Items][] = {
    
"polen",
    
"erva",
    
"cogumelos",
    
"lsd",
    
"cocaina",
    
"heroina",
    
"crack",
    
"marijuana"
};

// registered item id's
new gItems[Items];

public 
plugin_init() {
    
// prepare items
    
for(new 0Itemsi++) {
        
// register item to shop
        
gItems[i] = shop_add_item(gItemNames[i], gItemShortNames[i]);
    }
}

public 
CallbackItemAllowed(itemid) {
    
// get item constant from item id
    
for(new 0Itemsi++) {
        
// check if found item
        
if(gItems[i] == item) {
            
// can only use these items while alive
            
if(!is_user_alive(id)) {
                return 
SHOP_ITEM_DISABLED;
            }
            
            
// if an admin reserved item and not an admin
            
if((== Item_Heroina || == Item_Crack || == Item_Marijuana) && !access(idADMIN_RESERVATION)) {
                return 
SHOP_ITEM_DISABLED;
            }
            
            
// player is allowed this item
            
return SHOP_ITEM_ENABLED;
        }
    }
    
    
// player not allowed item, so hide item from menu
    
return SHOP_ITEM_HIDDEN;
}

public 
shop_item_selected(itemid) {
    
// find which item was selected, if one from this plugin
    
for(new 0Itemsi++) {
        
// check if found item
        
if(gItems[i] == item) {
            
// switch item for specific giving
            
switch(i) {
                case 
Item_Polen: {
                    
// handle selection
                    
set_user_health(idget_user_health(id) + 10);
                }
                case 
Item_Erva: {
                    
// handle selection
                    
set_user_health(idget_user_health(id) + 15);
                }
                case 
Item_Cogumelos: {
                    
// handle selection
                    
set_user_frags(idget_user_frags(id) + 1);
                }
                case 
Item_LSD: {
                    
// handle selection
                    
cs_set_user_money(idcs_get_user_money(id) + 750);
                }
                case 
Item_Cocaina: {
                    
// handle selection
                    
set_user_maxspeed(id310.0);
                }
                case 
Item_Heroina: {
                    
// handle selection
                    
set_user_maxspeed(id350.0);
                    
set_user_health(idget_user_health(id) + 25);
                }
                case 
Item_Crack: {
                    
// handle selection
                    
set_user_health(idget_user_health(id) + 25);
                    
cs_set_user_money(idcs_get_user_money(id) + 850);
                }
                case 
Item_Marijuana: {
                    
// handle selection
                    
set_user_maxspeed(id360.0);
                    
set_user_health(idget_user_health(id) + 30);
                    
cs_set_user_money(idcs_get_user_money(id) + 1000);
                }
            }
            
            
// found item, so don't look anymore
            
break;
        }
    }

Then just change these cvars:
Code:
shop_spawn_menu 1
shop_menu_title "\r[Drogas Menu]\yEscolhe a tua Droga:"
It takes away the part of having to know menus and all of that.
All you need to handle is preparing items and when player selects one.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
xfire97
Member
Join Date: Aug 2011
Old 02-29-2012 , 12:37   Re: Give velocity when buy
Reply With Quote #6

The shop_spawn_menu 1
sho_menu_title "\r[Drogas Menu]\yEscolhe a tua Droga:"
I dont find, this must be added by me?
P.S."The Player only can use the shop one time in round?, and the speed during the all round and end when player die or when round die?"

Thanks Doc Holiday, and Exolent, i shouldnt be so agressive .

xfire97 is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 02-29-2012 , 12:39   Re: Give velocity when buy
Reply With Quote #7

If you set the max speed in the menu handler, if you change the weapon the speed will return to normal. You have put it in client pre think.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 02-29-2012 , 12:50   Re: Give velocity when buy
Reply With Quote #8

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
You have put it in client pre think.
Agreed, do everything always in prethink.

EDIT: And I am against drugs.

Last edited by SnoW; 02-29-2012 at 12:50.
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-29-2012 , 13:00   Re: Give velocity when buy
Reply With Quote #9

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
If you set the max speed in the menu handler, if you change the weapon the speed will return to normal. You have put it in client pre think.
PreThink is the worst place to set user maxspeed, or model, or weapon model, or whatever.
Only use PreThink when you exactly know why you are using it ;)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xfire97
Member
Join Date: Aug 2011
Old 02-29-2012 , 13:02   Re: Give velocity when buy
Reply With Quote #10

Neeel, explain better, or give me the code please
xfire97 is offline
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 13:36.


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