AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   preventing player from getting extra frags (https://forums.alliedmods.net/showthread.php?t=86933)

rufee 03-04-2009 14:01

preventing player from getting extra frags
 
i need some way to protect the player from pressing the button twice so that he doesnt get extra frags(score)
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Push the button"
#define VERSION "1.0"
#define AUTHOR "rufee"
public plugin_init() {
register_plugin(PLUGINVERSIONAUTHOR)
RegisterHam(Ham_Use"func_button",    "hamUse"); 
}
public 
hamUse(ent,id
{
 new 
iPlayers[32];
 new 
iNum;
 new 
szTarget[32]
 
pev(entpev_targetszTarget31)
 if ( 
equal(szTarget"ct_target")) {
  if(
get_user_team(id) == 2){ 
 
client_print(idprint_chat"[Push the button]You can't push your own button!")
}
else
{
 
get_playersiPlayers iNum ,"ae" ,"CT" );
 for( new 
0iNum i++){ 
  
set_user_frags(iPlayers[i],get_user_frags(iPlayers[i])+1); 
 
user_kill(iPlayers[i])
 }
 
set_user_frags(id,get_user_frags(id)+1)
  
client_print(idprint_chat"[Push the button]You pushed the button!")
}
}
 if ( 
equal(szTarget"t_target")) {
if(
get_user_team(id) == 1){ 
 
client_print(idprint_chat"[Push the button]You can't push your own button!")
}
else
{
  
get_playersiPlayers iNum ,"ae" ,"TERRORIST" );
 for( new 
0iNum i++){
  
set_user_frags(iPlayers[i],get_user_frags(iPlayers[i])+1)
 
user_kill(iPlayers[i])
 }
 
set_user_frags(id,get_user_frags(id)+1)
  
client_print(idprint_chat"[Push the button]You pushed the button!")
 }
}



AntiBots 03-04-2009 14:22

Re: preventing player from getting extra frags
 
PHP Code:

new g_havetouch[33]

enum
{
    
TT 1,
    
CT 2
}

public 
hamUse(entid
{
    if( 
g_havetouch[id] )
        return 
HAM_IGNORED
    
    
new iPlayers[32];
    new 
iNum;
    new 
szTarget[32]
    
pev(entpev_targetszTarget31)
    
    if( 
is_user_alive(id) && ( equal(szTarget"ct_target") || equal(szTarget"t_target") ) )
    {
        new 
style equal(szTarget"ct_target") ? CT TT
        
        
if( get_user_team(id) == style )
        { 
            
client_print(idprint_chat"[Push the button] You can't push your own button!")
        }
        else
        {
            
get_playersiPlayers iNum ,"ae"style == CT "CT" "TERRORIST");
            for( new 
0iNum i++)
            { 
                
set_user_frags(iPlayers[i],get_user_frags(iPlayers[i])+1); 
                
user_kill(iPlayers[i])
            }
            
set_user_frags(id,get_user_frags(id)+1)
            
client_print(idprint_chat"[Push the button] You pushed the button!")
            
g_havetouch[id] = true
        
}
    }
    
    return 
HAM_IGNORED



rufee 03-05-2009 08:28

Re: preventing player from getting extra frags
 
seems to work but when a player presses the enemy button he cant press it anymore even on the next round

Brad 03-05-2009 10:02

Re: preventing player from getting extra frags
 
Quote:

Originally Posted by rufee (Post 773891)
i need some way to protect the player from pressing the button twice so that he doesnt get extra frags(score)

I'm curious what you mean by this. I've never heard of such a thing before.

rufee 03-05-2009 10:34

Re: preventing player from getting extra frags
 
well i have 2 buttons in a map each belongs to a team
the way i written the script the player can press the enemy button many times and get more score, instead of +1 they get +16 etc... so i need to let the player and the whole team press the enemy button 1 time per round


All times are GMT -4. The time now is 17:05.

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