AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Slap (https://forums.alliedmods.net/showthread.php?t=135142)

zirualas 08-13-2010 03:46

Slap
 
I wanna do then you select item "slap". You been slaped 10 times, but i can do only 1 time. So my question is how to do then person select "slap" he be slaped 10 times

GXLZPGX 08-13-2010 05:17

Re: Slap
 
Quote:

Originally Posted by zirualas (Post 1269437)
I wanna do then you select item "slap". You been slaped 10 times, but i can do only 1 time. So my question is how to do then person select "slap" he be slaped 10 times

Well, the way I thought of it is, create a variable such as:

PHP Code:

new gSlapped

Then set a repeating task to make them get slapped every second or so:

PHP Code:

set_task1.0"SlapFunction", .flags="a" 

Every time the person gets slapped, make it increase the variable by 1, like:

PHP Code:

gSlapped++ 

And make an if( statement to make it remove the task when it reaches 10.

zirualas 08-13-2010 05:47

Re: Slap
 
I add code like you said and i don't have any errors, but then i buy it my money don't disapear and i don't be slaped.
My code:
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <colorchat>
#include <fun>

#define PLUGIN "Fun Buy"
#define VERSION "1.0"
#define AUTHOR "ZiruAl"

new bool:buyedspeed[33]
new 
gSlapped;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd"say /funbuy""FunBuy" );
    
register_clcmd"say_team /funbuy""FunBuy" );
    
register_event("CurWeapon""Event_CurWeapon""be");
}
public 
Event_CurWeapon(id)
{
    if(
is_user_alive(id) && buyedspeed[id] == true)
    {
        new 
Float:speed get_user_maxspeed(id) + 999999999.0;
        
set_user_maxspeed(id speed); 
    }
}  

public  
plugin_precache ( )
{
    
precache_model("models/player/gign/gign.mdl")
    
precache_model("models/player/guerilla/guerilla.mdl")
    
precache_model("models/player/sas/sas.mdl")
    
precache_model("models/player/terror/terror.mdl")
    
precache_model("models/player/leet/leet.mdl")
    
precache_model("models/player/gsg9/gsg9.mdl")

}

public 
FunBuy(id)
{
    new 
menu menu_create("\gFun Buy Menu:""menu_handler");

    
menu_additem(menu"\w Low Gravity - \r4000""1"0);
    
menu_additem(menu"\w Buy C4 - \r16000""2"0);
    
menu_additem(menu"\w CT skin - \r14500""3"0);
    
menu_additem(menu"\w T skin - \r14500""4"0);
    
menu_additem(menu"\w Speed - \r4000""5"0);
    
menu_additem(menu"\w Slap madness - \r2000""6"0);

    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0);
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
acesscallback;

    
menu_item_getinfo(menuitemacessdata,6iName63callback);
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
//gravity
        
{
            new 
name[32];
            
            if (
cs_get_user_money(id) < 4000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 4000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a gravitation"name)
                
set_user_gravity(id0.5)
                
cs_set_user_money(id cs_get_user_money(id) - 40000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 16000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 16000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a C4"name)
                
give_item(id"weapon_c4")
                
cs_set_user_plant(id11)
                
cs_set_user_money(id cs_get_user_money(id) - 160000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 14500)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 14500 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a CT skin"name)
                
cs_set_user_model(id"gign")
                
cs_set_user_model(id"sas")
                
cs_set_user_model(id"sas")
                
cs_set_user_money(id cs_get_user_money(id) - 145000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 14500)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 14500 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a T skin"name)
                
cs_set_user_model(id"guerilla")
                
cs_set_user_model(id"terror")
                
cs_set_user_model(id"leet")
                
cs_set_user_money(id cs_get_user_money(id) - 145000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 4000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 4000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a T skin"name)
                new 
Float:speed get_user_maxspeed(id) + 999999999.0;
        
buyedspeed[id] = true;
        
set_user_maxspeed(id speed);
                
cs_set_user_money(id cs_get_user_money(id) - 40000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 2000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 2000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Is on slap madness!"name)
        
user_slap(id0)
        
set_task1.0"Slapfunction", .flags="a" )    
                
cs_set_user_money(id cs_get_user_money(id) - 20000)
        
gSlapped++
            }
        }
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 } 


naven 08-13-2010 06:13

Re: Slap
 
Eh, try this:
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <colorchat>
#include <fun>

#define PLUGIN "Fun Buy"
#define VERSION "1.0"
#define AUTHOR "ZiruAl"

new bool:buyedspeed[33]
new 
gSlapped[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /funbuy""FunBuy" );
    
register_clcmd"say_team /funbuy""FunBuy" );
    
register_event("CurWeapon""Event_CurWeapon""be");
}
public 
Event_CurWeapon(id)
{
    if(
is_user_alive(id) && buyedspeed[id] == true)
    {
        new 
Float:speed get_user_maxspeed(id) + 999999999.0;
        
set_user_maxspeed(id speed); 
    }
}  

public  
plugin_precache ( )
{
    
precache_model("models/player/gign/gign.mdl")
    
precache_model("models/player/guerilla/guerilla.mdl")
    
precache_model("models/player/sas/sas.mdl")
    
precache_model("models/player/terror/terror.mdl")
    
precache_model("models/player/leet/leet.mdl")
    
precache_model("models/player/gsg9/gsg9.mdl")
    
}

public 
FunBuy(id)
{
    new 
menu menu_create("\gFun Buy Menu:""menu_handler");
    
    
menu_additem(menu"\w Low Gravity - \r4000""1"0);
    
menu_additem(menu"\w Buy C4 - \r16000""2"0);
    
menu_additem(menu"\w CT skin - \r14500""3"0);
    
menu_additem(menu"\w T skin - \r14500""4"0);
    
menu_additem(menu"\w Speed - \r4000""5"0);
    
menu_additem(menu"\w Slap madness - \r2000""6"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0);
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
acesscallback;
    
    
menu_item_getinfo(menuitemacessdata,6iName63callback);
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
//gravity
        
{
            new 
name[32];
            
            if (
cs_get_user_money(id) < 4000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 4000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a gravitation"name)
                
set_user_gravity(id0.5)
                
cs_set_user_money(id cs_get_user_money(id) - 40000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 16000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 16000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a C4"name)
                
give_item(id"weapon_c4")
                
cs_set_user_plant(id11)
                
cs_set_user_money(id cs_get_user_money(id) - 160000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 14500)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 14500 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a CT skin"name)
                
cs_set_user_model(id"gign")
                
cs_set_user_model(id"sas")
                
cs_set_user_model(id"sas")
                
cs_set_user_money(id cs_get_user_money(id) - 145000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 14500)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 14500 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a T skin"name)
                
cs_set_user_model(id"guerilla")
                
cs_set_user_model(id"terror")
                
cs_set_user_model(id"leet")
                
cs_set_user_money(id cs_get_user_money(id) - 145000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 4000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 4000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Buy a T skin"name)
                new 
Float:speed get_user_maxspeed(id) + 999999999.0;
                
buyedspeed[id] = true;
                
set_user_maxspeed(id speed);
                
cs_set_user_money(id cs_get_user_money(id) - 40000)
            }
        }
        case 
:
        {
            new 
name[32];
            
            if (
cs_get_user_money(id) < 2000)
            {
                
get_user_name(idname31)
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (!
is_user_alive(id))
            {
                
ColorChat(idGREEN"%s ^x03-need to be alive"name)
                return 
PLUGIN_HANDLED;
            }
            
            if (
cs_get_user_money(id) >= 2000 )
            {
                
get_user_name(idname31)
                
ColorChat(0GREEN"%s ^x03-Is on slap madness!"name)
                
set_task(1.0"Slapfunction"id)
                
cs_set_user_money(id cs_get_user_money(id) - 20000)
                
            }
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}
public 
Slapfunction(id)
{
    if(
gSlapped[id] <= 10)
    {
    
user_slap(id0)
    
gSlapped[id]++;
    
set_task(1.0"Slapfunction"id)
}


oh, and add every round
PHP Code:

gSlapped[id] = 0


zirualas 08-13-2010 06:40

Re: Slap
 
I don't understond where add this?
PHP Code:

gSlapped[id] = 0

In top ?
-EDIT-
When I buy slap madness nad i wanna buy it antoher round he's don't bought. What's problem?

naven 08-13-2010 07:05

Re: Slap
 
Quote:

When I buy slap madness nad i wanna buy it antoher round he's don't bought. What's problem?
Quote:

oh, and add every round
PHP Code:
PHP Code:

gSlapped[id] = 0


Here, ale take a look at this, and do the same thing in model plugin(hamspawn)
PHP Code:

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


#define PLUGIN "Fun Buy" 
#define VERSION "1.0" 
#define AUTHOR "ZiruAl" 

new bool:buyedspeed[33
new 
gSlapped[33]; 

public 
plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
     
    
register_clcmd"say /funbuy""FunBuy" ); 
    
register_clcmd"say_team /funbuy""FunBuy" ); 
    
register_event("CurWeapon""Event_CurWeapon""be"); 
    
RegisterHam(Ham_Spawn"player""runda"1)

public 
runda(id)//called at new round
{
    
gSlapped[id] = 0;
}
public 
Event_CurWeapon(id

    if(
is_user_alive(id) && buyedspeed[id] == true
    { 
        new 
Float:speed get_user_maxspeed(id) + 999999999.0
        
set_user_maxspeed(id speed);  
    } 
}   

public  
plugin_precache ( ) 

    
precache_model("models/player/gign/gign.mdl"
    
precache_model("models/player/guerilla/guerilla.mdl"
    
precache_model("models/player/sas/sas.mdl"
    
precache_model("models/player/terror/terror.mdl"
    
precache_model("models/player/leet/leet.mdl"
    
precache_model("models/player/gsg9/gsg9.mdl"
     


public 
FunBuy(id

    new 
menu menu_create("\gFun Buy Menu:""menu_handler"); 
     
    
menu_additem(menu"\w Low Gravity - \r4000""1"0); 
    
menu_additem(menu"\w Buy C4 - \r16000""2"0); 
    
menu_additem(menu"\w CT skin - \r14500""3"0); 
    
menu_additem(menu"\w T skin - \r14500""4"0); 
    
menu_additem(menu"\w Speed - \r4000""5"0); 
    
menu_additem(menu"\w Slap madness - \r2000""6"0); 
     
    
menu_setprop(menuMPROP_EXITMEXIT_ALL
    
menu_display(idmenu0); 


public 
menu_handler(idmenuitem

    if( 
item == MENU_EXIT 
    { 
        
menu_destroy(menu); 
        return 
PLUGIN_HANDLED
    } 
     
    new 
data[6], iName[64]; 
    new 
acesscallback
     
    
menu_item_getinfo(menuitemacessdata,6iName63callback); 
    new 
key str_to_num(data); 
     
    switch(
key
    { 
        case 
//gravity 
        

            new 
name[32]; 
             
            if (
cs_get_user_money(id) < 4000
            { 
                
get_user_name(idname31
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name
                return 
PLUGIN_HANDLED
            } 
             
            if (!
is_user_alive(id)) 
            { 
                
ColorChat(idGREEN"%s ^x03-need to be alive"name
                return 
PLUGIN_HANDLED
            } 
             
            if (
cs_get_user_money(id) >= 4000 
            { 
                
get_user_name(idname31
                
ColorChat(0GREEN"%s ^x03-Buy a gravitation"name
                
set_user_gravity(id0.5
                
cs_set_user_money(id cs_get_user_money(id) - 40000
            } 
        } 
        case 

        { 
            new 
name[32]; 
             
            if (
cs_get_user_money(id) < 16000
            { 
                
get_user_name(idname31
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name
                return 
PLUGIN_HANDLED
            } 
             
            if (!
is_user_alive(id)) 
            { 
                
ColorChat(idGREEN"%s ^x03-need to be alive"name
                return 
PLUGIN_HANDLED
            } 
             
            if (
cs_get_user_money(id) >= 16000 
            { 
                
get_user_name(idname31
                
ColorChat(0GREEN"%s ^x03-Buy a C4"name
                
give_item(id"weapon_c4"
                
cs_set_user_plant(id11
                
cs_set_user_money(id cs_get_user_money(id) - 160000
            } 
        } 
        case 

        { 
            new 
name[32]; 
             
            if (
cs_get_user_money(id) < 14500
            { 
                
get_user_name(idname31
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name
                return 
PLUGIN_HANDLED
            } 
             
            if (!
is_user_alive(id)) 
            { 
                
ColorChat(idGREEN"%s ^x03-need to be alive"name
                return 
PLUGIN_HANDLED
            } 
             
            if (
cs_get_user_money(id) >= 14500 
            { 
                
get_user_name(idname31
                
ColorChat(0GREEN"%s ^x03-Buy a CT skin"name
                
cs_set_user_model(id"gign"
                
cs_set_user_model(id"sas"
                
cs_set_user_model(id"sas"
                
cs_set_user_money(id cs_get_user_money(id) - 145000
            } 
        } 
        case 

        { 
            new 
name[32]; 
             
            if (
cs_get_user_money(id) < 14500
            { 
                
get_user_name(idname31
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name
                return 
PLUGIN_HANDLED
            } 
             
            if (!
is_user_alive(id)) 
            { 
                
ColorChat(idGREEN"%s ^x03-need to be alive"name
                return 
PLUGIN_HANDLED
            } 
             
            if (
cs_get_user_money(id) >= 14500 
            { 
                
get_user_name(idname31
                
ColorChat(0GREEN"%s ^x03-Buy a T skin"name
                
cs_set_user_model(id"guerilla"
                
cs_set_user_model(id"terror"
                
cs_set_user_model(id"leet"
                
cs_set_user_money(id cs_get_user_money(id) - 145000
            } 
        } 
        case 

        { 
            new 
name[32]; 
             
            if (
cs_get_user_money(id) < 4000
            { 
                
get_user_name(idname31
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name
                return 
PLUGIN_HANDLED
            } 
             
            if (!
is_user_alive(id)) 
            { 
                
ColorChat(idGREEN"%s ^x03-need to be alive"name
                return 
PLUGIN_HANDLED
            } 
             
            if (
cs_get_user_money(id) >= 4000 
            { 
                
get_user_name(idname31
                
ColorChat(0GREEN"%s ^x03-Buy a T skin"name
                new 
Float:speed get_user_maxspeed(id) + 999999999.0
                
buyedspeed[id] = true
                
set_user_maxspeed(id speed); 
                
cs_set_user_money(id cs_get_user_money(id) - 40000
            } 
        } 
        case 

        { 
            new 
name[32]; 
             
            if (
cs_get_user_money(id) < 2000
            { 
                
get_user_name(idname31
                
ColorChat(idGREEN"%s ^x03-Don't have enought money"name
                return 
PLUGIN_HANDLED
            } 
             
            if (!
is_user_alive(id)) 
            { 
                
ColorChat(idGREEN"%s ^x03-need to be alive"name
                return 
PLUGIN_HANDLED
            } 
             
            if (
cs_get_user_money(id) >= 2000 
            { 
                
get_user_name(idname31
                
ColorChat(0GREEN"%s ^x03-Is on slap madness!"name
                
set_task(1.0"Slapfunction"id
                
cs_set_user_money(id cs_get_user_money(id) - 20000
                 
            } 
        } 
    } 
     
    
menu_destroy(menu); 
    return 
PLUGIN_HANDLED

public 
Slapfunction(id

    if(
gSlapped[id] <= 10
    { 
    
user_slap(id0
    
gSlapped[id]++; 
    
set_task(1.0"Slapfunction"id




zirualas 08-13-2010 07:39

Re: Slap
 
Thx man you da best :D.
But 1 bug, after slap madness you die!. Why?

naven 08-13-2010 11:10

Re: Slap
 
Really? Kinda mystery:D
Maybe you just felt down having 1 HP?

zirualas 08-13-2010 14:19

Re: Slap
 
No, then you 1 in server and use slap madness you die if you have even 100 hp but if in server 2 or much peaples you don't die :D


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

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