AlliedModders

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

funstyle 02-08-2010 16:27

amx_slap
 
how to add a function that can not use amx_slap more than 5 times in a player

PHP Code:

public cmdSlap(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED

    
new arg[32]
    
    
read_argv(1arg31)
    new 
player cmd_target(idargCMDTARGET_OBEY_IMMUNITY CMDTARGET_ALLOW_SELF CMDTARGET_ONLY_ALIVE)
    
    if (!
player)
        return 
PLUGIN_HANDLED

    
new spower[32], authid[32], name2[32], authid2[32], name[32]
    
    
read_argv(2spower31)
    
    new 
damage str_to_num(spower)
    
    
user_slap(playerdamage)
    
    
get_user_authid(idauthid31)
    
get_user_name(idname31)
    
get_user_authid(playerauthid231)
    
get_user_name(playername231)
    
    
log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^""nameget_user_userid(id), authiddamagename2get_user_userid(player), authid2)

    
show_activity_key("ADMIN_SLAP_1""ADMIN_SLAP_2"namename2damage);

    
console_print(id"[AMXX] %L"id"CLIENT_SLAPED"name2damage)
    
    return 
PLUGIN_HANDLED



NiQu 02-08-2010 16:37

Re: amx_slap
 
I dont know :P
Maybe you could create ur own slap and make it count each slap.

funstyle 02-08-2010 16:46

Re: amx_slap
 
I need amx_slap order not to let it use more than 5 times to use it on a player
if possible plugin new or little modification of admincmd.amxx

Kreation 02-08-2010 17:53

Re: amx_slap
 
Quote:

Originally Posted by NiQu (Post 1083066)
I dont know :P
Maybe you could create ur own slap and make it count each slap.

Why post if you don't know.

Sylwester 02-08-2010 18:30

Re: amx_slap
 
Quote:

Originally Posted by Kreation (Post 1083112)
Why post if you don't know.

The same goes for you.

@funstyle: You need to make few small changes:
PHP Code:

#define MAX_SLAPS 5
new g_slap_cnt[33]
public 
cmdSlap(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED

    
new arg[32]
    
    
read_argv(1arg31)
    new 
player cmd_target(idargCMDTARGET_OBEY_IMMUNITY CMDTARGET_ALLOW_SELF CMDTARGET_ONLY_ALIVE)
    
    if (!
player || ++g_slap_cnt[player] > MAX_SLAPS)
        return 
PLUGIN_HANDLED

    
new spower[32], authid[32], name2[32], authid2[32], name[32]

    
read_argv(2spower31)

    new 
damage str_to_num(spower)
    
user_slap(playerdamage)
    
    
get_user_authid(idauthid31)
    
get_user_name(idname31)
    
get_user_authid(playerauthid231)
    
get_user_name(playername231)
    
    
log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^""nameget_user_userid(id), authiddamagename2get_user_userid(player), authid2)

    
show_activity_key("ADMIN_SLAP_1""ADMIN_SLAP_2"namename2damage);

    
console_print(id"[AMXX] %L"id"CLIENT_SLAPED"name2damage)
    
    return 
PLUGIN_HANDLED


But you also need to reset g_slap_cnt[id] somewhere.

You can do this (you will be able to slap player only 5 times until he disconnects):
PHP Code:

public client_connect(id)
    
g_slap_cnt[id] = 

or this (you will be able to slap player 5 times after every spawn):
PHP Code:

#include <hamsandwich>
public plugin_init(){
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
}

public 
player_spawn(id){
    if(!
is_user_alive(id))
        return
    
g_slap_cnt[id] = 0



funstyle 02-08-2010 19:28

Re: amx_slap
 
wow, thank you very much Sylwester work ,i add that the you will be able to slap player 5 times after every spawn

can you after 5 slapping if you try to give more a msg appear

-B1ng0- 07-06-2010 03:21

Re: amx_slap
 
Try this
PHP Code:

#define MAX_SLAPS 5
new g_slap_cnt[33]
public 
cmdSlap(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED

    
new arg[32]
    
    
read_argv(1arg31)
    new 
player cmd_target(idargCMDTARGET_OBEY_IMMUNITY CMDTARGET_ALLOW_SELF CMDTARGET_ONLY_ALIVE)
    
    if (!
player || ++g_slap_cnt[player] > MAX_SLAPS){
        
client_print(idprint_chat"* You can do this only 5 times a player in each round")
        return 
PLUGIN_HANDLED
    
}

    new 
spower[32], authid[32], name2[32], authid2[32], name[32]

    
read_argv(2spower31)

    new 
damage str_to_num(spower)
    
user_slap(playerdamage)
    
    
get_user_authid(idauthid31)
    
get_user_name(idname31)
    
get_user_authid(playerauthid231)
    
get_user_name(playername231)
    
    
log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^""nameget_user_userid(id), authiddamagename2get_user_userid(player), authid2)

    
show_activity_key("ADMIN_SLAP_1""ADMIN_SLAP_2"namename2damage);

    
console_print(id"[AMXX] %L"id"CLIENT_SLAPED"name2damage)
    
    return 
PLUGIN_HANDLED


Changes:
PHP Code:

if (!player || ++g_slap_cnt[player] > MAX_SLAPS)
        return 
PLUGIN_HANDLED 

with this:
PHP Code:

if (!player || ++g_slap_cnt[player] > MAX_SLAPS){
        
client_print(idprint_chat"* You can do this only 5 times a player in each round")
        return 
PLUGIN_HANDLED
    




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

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