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

Some one help :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Balck
Senior Member
Join Date: Apr 2013
Location: Kosova-Mitrovica
Old 10-17-2013 , 09:34   Some one help :)
Reply With Quote #1

Can some one add in this plugin, even if it is not free if i press a button and i will pres it again it saysYou can't press this button until the new round

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta_util>

//CREDITS TO UNKNOWN AUTHOR.

#define PLUGIN "Deathrun_FreeRun"
#define VERSION "1.0"
#define AUTHOR "UNKNOWN AUTHOR"

enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
bool:g_free
new g_free_count
new g_cvar_Tonly
new passed

new TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
g_cvar_Tonly register_cvar("dh_free_run_Tonly""1")

    
register_clcmd("say /free""cmdFree")

    
register_event("HLTV""eventRoundStart""a""1=0""2=0")

    
RegisterHam(Ham_Touch"armoury_entity""fwdTouch")
    
RegisterHam(Ham_Touch"weaponbox""fwdTouch")
    
RegisterHam(Ham_Use"func_button""fwdUse")        
}

public 
passing()
{
    
passed 1
}

public 
eventRoundStart()
{
    
g_free false
    passed 
0
    set_task
(10.0"passing")
}

public 
cmdFree(id)
{
    if(
passed)
    {
        if( 
get_user_team(id) == 1
        {

            
ColorChat(idRED"[ Deathrun ] ^4 10 sec. are passed, you cant do a freerun anymore"
            return 
PLUGIN_HANDLED
        
}
    }
    if (
get_pcvar_num(g_cvar_Tonly) && get_user_team(id) != 1)
        
client_print(idprint_center"Only T can use it!")
    else if (
g_free)
        
client_print(idprint_center"Already FreeRun!")
    else if (!
is_user_alive(id))
        
client_print(idprint_center"You are dead u can't use freerun!")        
    else
    {
        
set_task(0.3"setfree")
    }
    return 
PLUGIN_HANDLED
}

public 
setfree()
{    
    
g_free true
        
    g_free_count
++
    
    
ColorChat(0RED"[ Deathrun ]^x01 Now it's free :)")    
        
        
    new 
players[32], plNumi
    get_players
(playersplNum"ah")
    for (
0plNumi++)
    {
        
fm_strip_user_weapons(players[i])
        
fm_give_item(players[i], "weapon_knife")
    }  
    
set_task(0.3"freerunmsg")         
}

public 
freerunmsg()
{
    if(
g_free)
    {
        
set_hudmessage(02552550.02, -1.0)
        
show_hudmessage(0"FreeRun!")
    }
}


ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    if( !
get_playersnum() ) return;
    
    new 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
                case 
GREY// Grey
                
{
                        
message[0] = 0x05;
                }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    new 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    static 
bool:saytext_used;
    static 
get_user_msgid_saytext;
    if(!
saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText");
        
saytext_used true;
    }
    
message_begin(typeget_user_msgid_saytext_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    static 
bool:teaminfo_used;
    static 
get_user_msgid_teaminfo;
    if(!
teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo");
        
teaminfo_used true;
    }
    
message_begin(typeget_user_msgid_teaminfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    new 
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
            return 
i;
    }

    return -
1;
}


public 
fwdTouch(entid)
{
    if (
is_user_alive(id) && g_free)
        return 
HAM_SUPERCEDE
    
return HAM_IGNORED
}

public 
fwdUse(entidcalleridactivatoruse_typeFloat:value)
{
    if (
is_user_alive(idactivator) && g_free && get_user_team(idactivator) == 1)
    {
        
client_print(idactivatorprint_center"It's free you can't use buttons!")
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED

__________________

Last edited by Balck; 10-17-2013 at 10:31.
Balck is offline
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 10-17-2013 , 14:00   Re: Some one help :)
Reply With Quote #2

Like this ..

declare

PHP Code:
new didpress[33
now everytime someone leaves the press handling function .. intialize it to 1
PHP Code:
didpress[id]=
and everytime someone enters ... make a check if the value is 1

PHP Code:
public handle_press(id)
{
if(
didpress[id]==1)
{
//already pressed once this round
return PLUGIN_HANDLED
}

//your code

didpress[id]=1

now .. Hook new round ..

PHP Code:
register_event"HLTV""event_NewRound""a""1=0""2=0" ); 
PHP Code:
public event_NewRound()
{
for(new 
i=0;i<33;i++)
{
didpress[i]=0
}

Now you have to handle other initializations like if someone disconnects..

PHP Code:
public client_disconnect(id)
didpress[id]=
You are good enough to understand why we doing this.
__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then

Last edited by devilicioux; 10-17-2013 at 14:01. Reason: grr.. missed
devilicioux is offline
Old 10-18-2013, 12:51
LordOfNothing
This message has been deleted by ConnorMcLeod. Reason: troll, or posting random confusing code, or posting for posts count
Reply



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 07:53.


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