AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu "case" doesn't work. (https://forums.alliedmods.net/showthread.php?t=183200)

reidark 04-18-2012 21:30

Menu "case" doesn't work.
 
I have this "case".

PHP Code:

        case 6:
        {
            
bhop(id)
        } 

And function bhop is:

PHP Code:

public bhop(id)
{
    new 
money cs_get_user_money(id);
    new 
cost get_pcvar_num(bhopcost);
    
    if(
money cost || money == cost
    {
        
cs_set_user_money(idmoney cost);
        
client_cmd(id"cmdBhopActive")
        
        
        
client_print(idprint_chat"[First DR] Voce comprou o bunnyhop!");
    } else {
        
client_print(idprint_chat"[First DR] Voce nao tem dinheiro suficiente!");
    }


But doesn't work!

Anyways, my plugin of bunnyhop is:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define FL_WATERJUMP    (1<<11)
#define FL_ONGROUND     (1<<9)

new g_has_bhop[33]

public 
plugin_init()
{
    
register_clcmd("bunnyserver" ,"cmdBhopActive")
    
register_clcmd("bunnyserver2" ,"cmdBhopDesactive")
}

public 
cmdBhopActive(id)
{
        if(
g_has_bhop[id])
        {
                
g_has_bhop[id]=0
                
return PLUGIN_HANDLED
        
}
      
        return 
PLUGIN_HANDLED
}

public 
cmdBhopDesactive(id)
{
        if(!
g_has_bhop[id])
        {
                
g_has_bhop[id]=1
                
return PLUGIN_HANDLED
        
}

        return 
PLUGIN_HANDLED
}

public 
client_PreThink(id
{
        if(!
g_has_bhop[id])
                return 
PLUGIN_CONTINUE
        
        entity_set_float
(idEV_FL_fuser20.0)
        
        if(
entity_get_int(idEV_INT_button) & 2
        {
                new 
flags entity_get_int(idEV_INT_flags)
                
                if(
flags FL_WATERJUMP)
                {
                        return 
PLUGIN_CONTINUE
                
}
                
                if(
entity_get_int(idEV_INT_waterlevel) >= 2)
                {
                        return 
PLUGIN_CONTINUE
                
}
                
                if(!(
flags FL_ONGROUND))
                {
                        return 
PLUGIN_CONTINUE
                
}
                
                new 
Float:velocity[3]
                
entity_get_vector(idEV_VEC_velocityvelocity)
                
velocity[2] += 250.0
                entity_set_vector
(idEV_VEC_velocityvelocity)
                
                
entity_set_int(idEV_INT_gaitsequence6)
        }
        return 
PLUGIN_CONTINUE


Pls, i need help!

rak 04-18-2012 21:47

Re: Menu "case" doesn't work.
 
client_cmd(id, "cmdBhopActive")
:arrow:
client_cmd(id, "cmdBhopDesactive")

reidark 04-18-2012 22:18

Re: Menu "case" doesn't work.
 
PHP Code:

public bhop(id)
{
    new 
money cs_get_user_money(id);
    new 
cost get_pcvar_num(bhopcost);
    
    if(
money cost || money == cost
    {
        
cs_set_user_money(idmoney cost);
        
client_cmd(id"cmdBhopDesactive")
        
        
        
client_print(idprint_chat"[First DR] Voce comprou o bunnyhop!");
    } else {
        
client_print(idprint_chat"[First DR] Voce nao tem dinheiro suficiente!");
    }


rak, i try this, but doesn't work too.
Pls, help me!

fysiks 04-19-2012 00:33

Re: Menu "case" doesn't work.
 
You can't access an internal function of another plugin like that. You have to use the same thing that the client would normally type (aka "bunnyserver").

Quote:

Originally Posted by rak (Post 1692118)
client_cmd(id, "cmdBhopActive")
:arrow:
client_cmd(id, "cmdBhopDesactive")

That doesn't even make sense. If that would have worked then it would have worked completely wrong. It seems you rarely know what you are saying.

rak 04-19-2012 03:21

Re: Menu "case" doesn't work.
 
Quote:

Originally Posted by fysiks (Post 1692168)
You can't access an internal function of another plugin like that. You have to use the same thing that the client would normally type (aka "bunnyserver").



That doesn't even make sense. If that would have worked then it would have worked completely wrong. It seems you rarely know what you are saying.

i see wrong.. and you are wrong.. is bunnyserver2

hleV 04-19-2012 03:52

Re: Menu "case" doesn't work.
 
Quote:

Originally Posted by rak (Post 1692226)
i see wrong.. and you are wrong.. is bunnyserver2

Nope, it's "bunnyserver" because the player is supposed to activate the bhop, not deactivate it.
PHP Code:

    // If the player has ENOUGH money to get bhop
    
if(money cost || money == cost
    {
        
cs_set_user_money(idmoney cost);

        
// ACTIVATE bhop
        
client_cmd(id"bunnyserver"

That's not the best way to do things, though. Better would be to directly call
PHP Code:

        //client_cmd(id, "bunnyserver")
        
cmdBhopActive(id); 

And you're removing player's money even if he already has bhop.

rak 04-19-2012 08:12

Re: Menu "case" doesn't work.
 
Quote:

Originally Posted by hleV (Post 1692230)
Nope, it's "bunnyserver" because the player is supposed to activate the bhop, not deactivate it.
PHP Code:

    // If the player has ENOUGH money to get bhop
    
if(money cost || money == cost
    {
        
cs_set_user_money(idmoney cost);

        
// ACTIVATE bhop
        
client_cmd(id"bunnyserver"

That's not the best way to do things, though. Better would be to directly call
PHP Code:

        //client_cmd(id, "bunnyserver")
        
cmdBhopActive(id); 

And you're removing player's money even if he already has bhop.

PHP Code:

register_clcmd("bunnyserver2" ,"cmdBhopDesactive"

PHP Code:

public cmdBhopDesactive(id)
{
        if(!
g_has_bhop[id])
        {
                
g_has_bhop[id]=1
                
return PLUGIN_HANDLED
        
}

        return 
PLUGIN_HANDLED
}

public 
client_PreThink(id
{
        if(!
g_has_bhop[id])
                return 
PLUGIN_CONTINUE
        
        entity_set_float
(idEV_FL_fuser20.0)
        
        if(
entity_get_int(idEV_INT_button) & 2
        {
                new 
flags entity_get_int(idEV_INT_flags)
                
                if(
flags FL_WATERJUMP)
                {
                        return 
PLUGIN_CONTINUE
                
}
                
                if(
entity_get_int(idEV_INT_waterlevel) >= 2)
                {
                        return 
PLUGIN_CONTINUE
                
}
                
                if(!(
flags FL_ONGROUND))
                {
                        return 
PLUGIN_CONTINUE
                
}
                
                new 
Float:velocity[3]
                
entity_get_vector(idEV_VEC_velocityvelocity)
                
velocity[2] += 250.0
                entity_set_vector
(idEV_VEC_velocityvelocity)
                
                
entity_set_int(idEV_INT_gaitsequence6)
        }
        return 
PLUGIN_CONTINUE



reidark 04-19-2012 19:04

Re: Menu "case" doesn't work.
 
Thank guys, but who is right is: rak
I tried this:
PHP Code:

client_cmd(id"bunnyserver2"

And works!
THANKS!
</span>

fysiks 04-19-2012 21:48

Re: Menu "case" doesn't work.
 
Quote:

Originally Posted by reidark (Post 1692610)
Thank guys, but who is right is: rak
I tried this:
PHP Code:

client_cmd(id"bunnyserver2"

And works!
THANKS!
</span>

According to your first post, he is wrong!

rak 04-19-2012 21:51

Re: Menu "case" doesn't work.
 
Quote:

Originally Posted by fysiks (Post 1692682)
According to your first post, he is wrong!

nop; he put bad the names; nothing more


All times are GMT -4. The time now is 07:54.

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