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

Problem with editing Use Button Once


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cajlo
New Member
Join Date: Feb 2011
Old 02-02-2011 , 08:56   Problem with editing Use Button Once
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <colorchat>
#include <fakemeta_util>

#define PLUGIN "Use button once"
#define VERSION "1.3"
#define AUTHOR "R3X"

#define MAX_BUTTONS 100
#define KeysButtonsMenu (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) // Keys: 137890
#define KeysOptionsMenu (1<<0)|(1<<1)|(1<<8) //129
#define KeysDelayMenu (1<<0)|(1<<1)|(1<<2)|(1<<8) //1239

#define ANNOUNCE_TASK 10000

#define m_flWait 44

//Main

new gEnt[MAX_BUTTONS];
new 
gUsed[MAX_BUTTONS];
new 
giPointer=0;
new 
gOnStart[MAX_BUTTONS];
new 
Float:gDefaultDelay[MAX_BUTTONS];
new 
Float:gDelay[MAX_BUTTONS];

new 
gInMenu[33];

new 
gszFile[128];

new 
giSprite;

new 
gcvarDefaultgcvarTeamgcvarFreeRun;
new 
gcvarLimitgcvarLimitModegcvarPrivilege;
new 
gcvarMessagegcvarRestore;

//VOTE

#define TASK_SHOWMENU 432
#define TASK_RES 123

#define MAX_ROUNDS 999

#define KeysFFVote (1<<0)|(1<<1) // Keys: 12

new gcvarFRVoteTime;

new 
giVoteStartgiVoteTime;

new 
bool:gbFreeRun=false;
new 
bool:gbVote=false;

#define VOTE_ON 0
#define VOTE_OFF 1

new giVotes[33][2];

new 
giRounds=MAX_ROUNDSgiTime=0;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_dictionary("common.txt");
    
register_dictionary("adminvote.txt");
    
register_dictionary("use_button_once.txt");
    
    
register_menucmd(register_menuid("FRVote"), KeysFFVote"PressedFRVote");
    
register_menucmd(register_menuid("ButtonsMenu"), KeysButtonsMenu"PressedButtonsMenu");
    
register_menucmd(register_menuid("OptionsMenu"), KeysOptionsMenu"PressedOptionsMenu");
    
register_menucmd(register_menuid("DelayMenu"), KeysDelayMenu"PressedDelayMenu");
    
    
register_clcmd("amx_buttons","cmd_amx_buttons",ADMIN_CFG,": Buttons Menu");
    
    
//Default count of uses
    
gcvarDefault=register_cvar("amx_buttons_default","1");
    
//Who plugin analyze
    //0 - anyone(plugin disabled?)
    //1 - Te
    //2 - Ct
    //3 - Te+Ct
    
gcvarTeam=register_cvar("amx_buttons_team","1");
    
//Enabled FreeRun mode?
    
gcvarFreeRun=register_cvar("amx_buttons_freerun","1");
    
//Vote time
    
gcvarFRVoteTime=register_cvar("amx_freerun_votetime","10");
    
    
//Type of limit
    //0 - enabled after 'amx_freerun_limit' rounds
    //1 - enabled after 'amx_freerun_limit' minutes
    
gcvarLimitMode=register_cvar("amx_freerun_limit_mode","0");
    
//Size of Limit
    
gcvarLimit=register_cvar("amx_freerun_limit","5");
    
    
//Interval of message
    
gcvarMessage=register_cvar("amx_freerun_info","120.0",0,120.0);
    
    
//Terrorist`s privilege
    //if he use /free FreeRun will start without vote, can he?
    
gcvarPrivilege=register_cvar("amx_freerun_tt_privilege","1");
    
    
//restore buttons on new round
    
gcvarRestore=register_cvar("amx_restore_buttons","1");
    
    
register_clcmd("say /free","cmdVoteFreeRun");
    
register_clcmd("say_team /free","cmdVoteFreeRun");
    
register_clcmd("say free","cmdVoteFreeRun");
    
register_clcmd("say_team free","cmdVoteFreeRun");
    
    
register_clcmd("say /freerun","cmdVoteFreeRun");
    
register_clcmd("say_team /freerun","cmdVoteFreeRun");
    
register_clcmd("say freerun","cmdVoteFreeRun");
    
register_clcmd("say_team freerun","cmdVoteFreeRun");
    
    
register_clcmd("say /fr","cmdVoteFreeRun");
    
register_clcmd("say_team /fr","cmdVoteFreeRun");
    
register_clcmd("say fr","cmdVoteFreeRun");
    
register_clcmd("say_team fr","cmdVoteFreeRun");
    
    
RegisterHam(Ham_Touch"armoury_entity""fwdNoWeaponPickup");
    
RegisterHam(Ham_Touch"weaponbox""fwdNoWeaponPickup");
    
    if( 
engfunc(EngFunc_FindEntityByString,-,"classname""func_button"))
        
RegisterHam(Ham_Use"func_button""fwButtonUsed");

    if(
engfunc(EngFunc_FindEntityByString,-,"classname","func_rot_button"))
        
RegisterHam(Ham_Use"func_rot_button""fwButtonUsed");
        
    if(
engfunc(EngFunc_FindEntityByString,-,"classname""button_target"))
        
RegisterHam(Ham_Use"button_target""fwButtonUsed");
        
    
register_logevent"ResetButtons"2"0=World triggered""1=Round_Start");
    
    
fillButtons("func_button");
    
fillButtons("func_rot_button");
    
fillButtons("button_target");
    
    
set_task(1.0,"eventRoundStart")
    
register_event("HLTV""eventRoundStart""a""1=0""2=0")
}    

public 
passing()
{
    
istekloVreme 1;
}

public 
eventRoundStart()
{
    
istekloVreme 0;
}

public 
plugin_cfg(){
    
setButtons();
    
    new 
iLen=0iMax=charsmax(gszFile);
    
iLen=get_configsdir(gszFileiMax );
    
iLen+=copy(gszFile[iLen], iMax-iLen"/dr_buttons/");
    
    if(!
dir_exists(gszFile)){
        
set_fail_state("Not found dir: configs/dr_buttons");
        return;
    }
    new 
szMap[32];
    
get_mapname(szMap31);
    
formatex(gszFile[iLen], charsmax(gszFile)-iLen"%s.ini"szMap);
    if(!
file_exists(gszFile)){
        return;
    }
    new 
szLine[51];
    new 
szButton[4], szTimes[3], szDelay[5];
    new 
Float:fDelay;
    for(new 
i=0;read_file(gszFileiszLine50iLen);i++){
        if(
iLen==0) continue;
        
trim(szLine);
        if(
szLine[0]==';') continue;
        
parse(szLineszButton3szTimes2szDelay4);
        
fDelay=szDelay[0]?str_to_float(szDelay):-1.0;
        
set_start_value(str_to_num(szButton), str_to_num(szTimes), fDelay);
    }
    new 
Float:fInterval=get_pcvar_float(gcvarMessage);
    if(
fInterval 0.0)
        
set_task(120.0"announceVote",ANNOUNCE_TASK,_,_,"b");
}
public 
plugin_precache(){
    
giSprite=precache_model("sprites/flare1.spr");
    
}
public 
client_putinserver(id){
    if(!
is_user_bot(id))
        
eventInGame(id);
}
public 
client_connect(id){
    
giVotes[id][VOTE_ON]=0;
    
giVotes[id][VOTE_OFF]=0;
}
public 
announceVote(){
    if(
get_pcvar_num(gcvarFreeRun))
        
ColorChat(0,GREEN"[FreeRun]^x01 %L",LANG_SERVER"ANNOUNCE");
}
setButtons(){
    new 
iDef=get_pcvar_num(gcvarDefault);
    for(new 
i=0;i<giPointer;i++){
        
gUsed[i]=iDef;
        
gOnStart[i]=iDef;
        
gDelay[i]=get_pdata_float(gEnt[i],m_flWait);
        
gDefaultDelay[i]=gDelay[i];
    }
}
fillButtons(const szClass[]){
    new 
ent = -1;
    while((
ent engfunc(EngFunc_FindEntityByString,ent ,"classname"szClass)) != 0){
        
gEnt[giPointer++]=ent;
        
set_pev(entpev_iuser4giPointer);
    }
}
set_start_value(enttimesFloat:delay){
    new 
index=get_ent_index(ent);
    if(
index!=-1){
        
gOnStart[index]=times;
        if(
delay>=0.0)
            
gDelay[index]=delay;
    }
}
get_ent_index(ent){
    
/*
    for(new i=0;i<giPointer;i++)
        if(gEnt[i]==ent) return i;
    return -1;
    */
    
return pev(entpev_iuser4)-1;
}
restoreButton(ent){
    if(
pev(entpev_frame) > 0.0){
        new 
Float:Life;
        
pev(entpev_nextthinkLife);
        
set_pev(entpev_ltimeLife-0.01);
    }
}
public 
ResetButtons(){
    
gbFreeRun=false;
    
gbVote=false;
    new 
bool:bRestore=get_pcvar_num(gcvarRestore)!=0;
    for(new 
i=0;i<MAX_BUTTONS;i++){
        
gUsed[i]=gOnStart[i];
        if(
bRestore){
            
restoreButton(gEnt[i]);
        }
    }
    
giRounds++;
}
public 
fwButtonUsed(thisidcalleridactivatoruse_typeFloat:value){
    if(
idcaller!=idactivator) return HAM_IGNORED;
    
    if(
pev(thispev_frame) > 0.0)
         return 
HAM_IGNORED;
    new 
index=get_ent_index(this);
    if(
index==-1
        return 
HAM_IGNORED;
    if(
get_user_team(idcaller)&get_pcvar_num(gcvarTeam)){
        
        if(
gbFreeRun){
            
ColorChat(idcaller,GREEN"[FreeRun]^x01 %L",idcaller"BUTTON_FREERUN");
            return 
HAM_SUPERCEDE;
        }
        else if(
gUsed[index]<=&& gOnStart[index]!=-1){
            
ColorChat(idcaller,GREEN"[Info]^x01 %L",idcaller,"BUTTON_NOMORE");
            return 
HAM_SUPERCEDE;
        }
        else{
            if(
gUsed[index]>0)
                if(--
gUsed[index]){
                    
ColorChat(idcallerGREEN"[Info]^x01 %L"idcaller"BUTTON_LEFT"gUsed[index]);
                }else
                    
ColorChat(idcallerGREEN"[Info]^x01 %L"idcaller"BUTTON_ENDOFLIMIT");
        }
        
set_task(1.0,"passing")
    }
    
    
set_task(0.1,"setDelay",this);
    
    return 
HAM_IGNORED;
}
public 
setDelay(this){
    new 
index=get_ent_index(this);
    
set_pev(thispev_nextthinkpev(thispev_ltime)+gDelay[index]+0.01);
}

//MENU--------------
public cmd_amx_buttons(idlevelcid){
    if(!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED;
    if(
giPointer==0)
        
client_print(idprint_chat"%L"id,"NO_BUTTONS");
    else
        
ShowButtonsMenu(id);
    return 
PLUGIN_HANDLED;
}
ShowButtonsMenu(idtrace=1){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id"MUST_B_ALIVE");
        return;
    }
    new 
iNow=gInMenu[id];
    new 
iKeys=(1<<0)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<9);
    new 
szMenu[196], iLeniMax=(sizeof szMenu) - 1;
    new 
szNoLimit[32];
    
formatex(szNoLimit,31,"(%L)",id,"NOLIMIT");
    
iLen=copy(szMenuiMax,"\yButtons Menu^n");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\wEnt#%d^n^n",gEnt[iNow]);
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"%L: %d %s^n\y1\w. %L ",id"USAGE",gOnStart[iNow],(gOnStart[iNow]==-1)?szNoLimit:""id"MORE");
    
    if(
gOnStart[iNow]>=0){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"\y2\w. %L",id"WORD_LESS");
        
iKeys|=(1<<1);
    }else
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"\d2. %L\w",id,"WORD_LESS");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n^n3. %L^n^n4. %L^n^n",id"DELAY_EDITOR",id,"OPTIONS");
    
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"5. %sNo Clip\w^n",isNoClip(id)?"\r":"");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"6. %sGodMode\w^n",isGodMode(id)?"\r":"");
    
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n7. \r%L^n\w",id"WORD_SAVE");
    
    if(
iNow>0){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n8. %L",id"BACK");
        
iKeys|=(1<<7);
    }
    if(
iNow<giPointer-1){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n9. %L",id"WORD_NEXT");
        
iKeys|=(1<<8);
    }
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n0. %L"id"EXIT");
    
show_menu(idiKeysszMenu, -1"ButtonsMenu");
    if(
trace){
        new 
Float:fOrigin[3], Float:fOrigin2[3];
        
fm_get_brush_entity_origin(gEnt[gInMenu[id]], fOrigin);
        
pev(idpev_originfOrigin2);
        
Create_TE_BEAMPOINTS(fOriginfOrigin2giSprite01020512550010050);
    }
}
bool:isNoClip(id)
    return 
pev(idpev_movetype)==MOVETYPE_NOCLIP;
    
bool:isGodMode(id)
    return 
pev(idpev_takedamage)==0.0;
    
public 
PressedButtonsMenu(idkey) {
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    
/* Menu:
    * Buttons Menu
    * Ent#<ent>
    * 
    * Uzyc: <ile>
    * 1. Wiecej 2. Mniej
    * 
    * 3. Editor
    *
    * 4. Options
    *
    * 5. NoClip
    * 6. GodMode
    * 
    * 7. Zapisz
    * 
    * 8. Poprzedni
    * 9. Nastepny
    * 0. Wyjdz
    */
    
new trace=0;
    switch (
key) {
        case 
0: { // 1
            
gOnStart[gInMenu[id]]++;
        }
        case 
1: { // 2
            
gOnStart[gInMenu[id]]--;
        }
        case 
2: { // 3
            
ShowDelayMenu(id);
            return;
        }
        case 
3:{ //4
            
ShowOptionsMenu(id);
            return;
        }
        case 
4:{ //5
            
set_pev(idpev_movetypeisNoClip(id)?MOVETYPE_WALK:MOVETYPE_NOCLIP);    
        }
        case 
5:{ //6
            
set_pev(idpev_takedamageisGodMode(id)?1.0:0.0);
        }
        case 
6: { // 7
            
save2File(id);
        }
        case 
7: { // 8
            
gInMenu[id]--;
            
trace=1;
        }
        case 
8: { // 9
            
gInMenu[id]++;
            
trace=1;
        }
        case 
9: { // 0
            
return;
        }
    }
    
ShowButtonsMenu(idtrace);
}
//--------------
ShowOptionsMenu(id){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    new 
szMenu[196], iLeniMax=(sizeof szMenu) - 1;
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\yOptions^n^n");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\w1. %L^n",id"GOTO");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"2. %L^n^n",id"NEAREST");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"9. %L",id"BACK");
    
show_menu(idKeysOptionsMenuszMenu, -1"OptionsMenu");
}
public 
PressedOptionsMenu(idkey){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    new 
trace=0;
    switch (
key) {
        case 
0: { // 1
            
go2Button(id);
        }
        case 
1: { // 2
            
gInMenu[id]=findTheClosest(id);
            
trace=1;
        }
    }
    
ShowButtonsMenu(idtrace);
}
//-------------
ShowDelayMenu(id){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    new 
iNow=gInMenu[id];
    new 
iKeys=(1<<0)|(1<<2)|(1<<8);
    new 
szMenu[196], iLeniMax=(sizeof szMenu) - 1;
    
iLen=copy(szMenuiMax,"\yDelay Menu^n");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\wEnt#%d^n^n",gEnt[iNow]);
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"%L: %.1f^n",id"CURRENT_DELAY"gDelay[iNow]);
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\y1\w. %L ",id"MORE");
    if(
gDelay[iNow]>0.0){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"\y2\w. %L",id"WORD_LESS");
        
iKeys|=(1<<1);
    }else
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"\d2. %L\w",id,"WORD_LESS");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n3. %L",id"DEFAULT");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n^n9. %L",id"BACK");
    
show_menu(idiKeysszMenu, -1"DelayMenu");
}
public 
PressedDelayMenu(idkey){
    new 
iNow=gInMenu[id];
    switch(
key){
        case 
0:{
            
gDelay[iNow]+=1.0;
        }
        case 
1:{
            
gDelay[iNow]-=1.0;
            if(
gDelay[iNow] < 0.0)
                
gDelay[iNow]=0.0;
        }
        case 
2:{
            
gDelay[iNow]=gDefaultDelay[iNow];
        }
        case 
8:{
            
ShowButtonsMenu(id0);
            return;
        }
    }
    
ShowDelayMenu(id);
}
//-------------
save2File(id){
    if(
file_exists(gszFile))
        
delete_file(gszFile);
    
write_file(gszFile";<ent> <count> <delay>");
    new 
szLine[35];
    for(new 
i=0;i<giPointer;i++){
        
formatex(szLine34"%d %d %.1f",gEnt[i], gOnStart[i], gDelay[i]);
        
write_file(gszFileszLine);
    }
    
client_print(idprint_center"%L!",id,"WORD_SAVED");
}
findTheClosest(id){
    new 
Float:fPlayerOrig[3];
    
pev(idpev_originfPlayerOrig);
    new 
Float:fOrigin[3];
    
fm_get_brush_entity_origin(gEnt[0], fOrigin);
    
    new 
Float:fRange=get_distance_f(fOriginfPlayerOrig), index=0;
    new 
Float:fNewRange;
    for(new 
i=1;i<giPointer;i++){
        
fm_get_brush_entity_origin(gEnt[i], fOrigin);
        
fNewRange=get_distance_ffOrigin,  fPlayerOrig);
        if(
fNewRange fRange){
            
fRange=fNewRange;
            
index=i;
        }
    }
    return 
index;
}
go2Button(ident=-1){
    if(
ent==-1)
        
ent=gInMenu[id];
    
ent=gEnt[ent];
    if(!
pev_valid(ent)){
        
client_print(idprint_center"%L",id,"NOTARGET");
        return;
    }
    new 
Float:fOrigin[3];
    
fm_get_brush_entity_origin(entfOrigin);
    
set_pev(idpev_originfOrigin);
    
client_print(idprint_chat"PS. No Clip :)");
}
//FreeRun
public cmdVoteFreeRun(id){
    if(
get_pcvar_num(gcvarFreeRun)==0){
        
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_DISABLED");
        return 
PLUGIN_HANDLED;
    }
    if(
gbVote){
        
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_VOTE_IS_NOW");
        return 
PLUGIN_HANDLED;
    }
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id"MUST_B_ALIVE");
        return 
PLUGIN_HANDLED;
    }
    if(
get_pcvar_num(gcvarPrivilege)!=&& !gbFreeRun && get_user_team(id)==1){
        
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_TT_DECIDED");
        
makeFreeRun(true);
        return 
PLUGIN_HANDLED;
    }
    new 
iLimit=get_pcvar_num(gcvarLimit);
    new 
iOffset=0;
    if(
get_pcvar_num(gcvarLimitMode)){
        
iOffset = ( giTime iLimit 60 )  - get_systime();
        if( 
iOffset ){
             
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_NEXT_VOTE_TIME"iOffset/60iOffset%60);
            return 
PLUGIN_HANDLED;
        }
    }
    else{
        
iOffset =  min(MAX_ROUNDSiLimit) - giRounds;
        if( 
iOffset ){
             
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_NEXT_VOTE_ROUNDS"iOffset);
            return 
PLUGIN_HANDLED;
        }
    }
    
    
makeVote();
    return 
PLUGIN_CONTINUE;
}
//FREERUN
public makeVote(){
    
giVoteTime=get_pcvar_num(gcvarFRVoteTime);
    
gbVote=true;
    
giVoteStart=get_systime();
    
set_task(float(giVoteTime), "resultsOfVote"TASK_RES);
    new 
Players[32], playerCount;
    new 
id;
    
get_players(PlayersplayerCount);
    for (new 
i=0i<playerCounti++){
        
id Players[i]; 
        
eventInGame(id);
    }
    
}
public 
resultsOfVote(tid){
    
gbVote=false;
    
    new 
giVotesOn=count(VOTE_ON);
    new 
giVotesOff=count(VOTE_OFF);
    
    
ColorChat(0,GREEN"[FreeRun]^x01 %L %L(%d) vs %L(%d)",LANG_SERVER,"FREERUN_RESULTS",LANG_SERVER,"YES",giVotesOn,LANG_SERVER,"NO"giVotesOff);
    
    if( 
giVotesOn == giVotesOff ){
        
ColorChat(0,GREEN"[FreeRun]^x01 %L",LANG_SERVER,"FREERUN_TIE");
        return;
    }
    
makeFreeRun((giVotesOn giVotesOff));
    
ColorChat(0,GREEN"[FreeRun]^x01 %L ^x03%L",LANG_SERVER,"FREERUN_WINOPTION",LANG_SERVERgbFreeRun?"YES":"NO");
}
makeFreeRun(bool:bFR=true){
    
gbFreeRun=bFR;
    
reset();
    
giRounds=0;
    
giTime=get_systime();
    
    if(
gbFreeRun)
    {
        
set_hudmessage(02552550.02, -1.0);
        
show_hudmessage(0"FreeRun!");
        
        new 
players[32], plNumi
        get_players
(playersplNum"ah")
        for (
0plNumi++)
        {
        
fm_strip_user_weapons(players[i])
        
fm_give_item(players[i], "weapon_knife")
        }
    }
    
}
count(VOTE_STATE){
    new 
iCounter=0;
    for(new 
i=1;i<33;i++)
        if(
giVotes[i][VOTE_STATE])
            
iCounter++;
    return 
iCounter;
}
reset(){
    for(new 
i=1;i<33;i++){
        
giVotes[i][VOTE_ON]=0;
        
giVotes[i][VOTE_OFF]=0;
    }
}
public 
show_menu_(tid){
    new 
id=tid-TASK_SHOWMENU;
    new 
iTeam=get_user_team(id);
    new 
menu_idkeys;
    new 
menuUp player_menu_infoidmenu_idkeys );
    
// Only display menu if another isn't shown
    
if ( iTeam && (menuUp <= || menu_id 0) ){
        new 
iTime=get_pcvar_num(gcvarFRVoteTime);
        new 
iOffset=get_systime()-giVoteStart;
        
iTime-=iOffset;
        new 
szMenu[128];
        
formatex(szMenu127"\y%L^n^n\w1. %L^n2. %L",id,"FREERUN_VOTEMENU",id,"YES",id,"NO");
        
show_menu(idKeysFFVoteszMenuiTime"FRVote");
    }else
        
set_task(1.0"show_menu_"tid);
}
public 
eventInGame(id){
    if(
giVotes[id][VOTE_ON] || giVotes[id][VOTE_OFF])
        return;
    if(
gbVote)
        
set_task(1.0"show_menu_"id+TASK_SHOWMENU);
}
public 
PressedFRVote(idkey) {
    if(
gbVote==false) return;
    switch (
key) {
        case 
VOTE_ON: { // 1
            
giVotes[id][VOTE_ON]=1;
        }
        case 
VOTE_OFF: { // 2
            
giVotes[id][VOTE_OFF]=1;
        }
        default:{
            return;
        }
    }
    new 
szName[32];
    
get_user_name(idszName31);
    
    
client_print(0print_chat"* %L",LANG_PLAYER,(key==VOTE_ON)?"VOTED_FOR":"VOTED_AGAINST"szName);
}

stock Create_TE_BEAMPOINTS(Float:start[3], Float:end[3], iSpritestartFrameframeRatelifewidthnoiseredgreenbluealphaspeed){
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_BEAMPOINTS )
    
write_coordfloatround(start[0]) )
    
write_coordfloatround(start[1]) )
    
write_coordfloatround(start[2]) )
    
write_coordfloatround(end[0]) )
    
write_coordfloatround(end[1]) )
    
write_coordfloatround(end[2]) )
    
write_shortiSprite )            // model
    
write_bytestartFrame )        // start frame
    
write_byteframeRate )            // framerate
    
write_bytelife )                // life
    
write_bytewidth )                // width
    
write_bytenoise )                // noise
    
write_bytered)                // red
    
write_bytegreen )                // green
    
write_byteblue )                // blue
    
write_bytealpha )                // brightness
    
write_bytespeed )                // speed
    
message_end()
}
stock fm_get_brush_entity_origin(entFloat:fOrigin[3]){
    new 
Float:fMins[3], Float:fMaxs[3];
    
pev(entpev_minsfMins);
    
pev(entpev_maxsfMaxs);
    
    for(new 
i=0;i<3;i++)
        
fOrigin[i]=(fMins[i]+fMaxs[i])/2;
}

public 
fwdNoWeaponPickup(entid)
{
    if (
is_user_alive(id) && gbFreeRun)
        return 
HAM_SUPERCEDE
    
return HAM_IGNORED

PHP Code:
// by the AMX Mod X Dev Team

//// use_button_once.sma
// E:\Deathrun\cstrike\addons\amxmodx\scripting\use_button_once.sma(157) : error
 
017undefined symbol "istekloVreme"
// E:\Deathrun\cstrike\addons\amxmodx\scripting\use_button_once.sma(157) : warni
ng 215expression has no effect
// E:\Deathrun\cstrike\addons\amxmodx\scripting\use_button_once.sma(162) : error
 
017undefined symbol "istekloVreme"
// E:\Deathrun\cstrike\addons\amxmodx\scripting\use_button_once.sma(162) : warni
ng 215expression has no effect
// E:\Deathrun\cstrike\addons\amxmodx\scripting\use_button_once.sma(706) : error
 
021symbol already defined"fm_get_brush_entity_origin"
// E:\Deathrun\cstrike\addons\amxmodx\scripting\use_button_once.sma(713) : warni
ng 209: function "fm_get_brush_entity_origin" should return a value
//
// 3 Errors.
// Could not locate output file E:\Deathrun\cstrike\addons\amxmodx\scripting\com
piled\use_button_once.amx (compile failed).
//
// Compilation Time: 0,7 sec
// ----------------------------------------

Press enter to exit ... 
or give me use_button_once with fixed freerun when ct and tt can't pick up weapon please
sorry for my english

Last edited by cajlo; 02-02-2011 at 12:50.
cajlo is offline
Old 02-04-2011, 00:48
cajlo
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 02-04-2011 , 01:41   Re: Problem with editing Use Button Once
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <colorchat>

#define PLUGIN "Use button once"
#define VERSION "1.3"
#define AUTHOR "R3X"

#define MAX_BUTTONS 100
#define KeysButtonsMenu (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) // Keys: 137890
#define KeysOptionsMenu (1<<0)|(1<<1)|(1<<8) //129
#define KeysDelayMenu (1<<0)|(1<<1)|(1<<2)|(1<<8) //1239

#define ANNOUNCE_TASK 10000

#define m_flWait 44

//Main

new gEnt[MAX_BUTTONS];
new 
gUsed[MAX_BUTTONS];
new 
giPointer=0;
new 
gOnStart[MAX_BUTTONS];
new 
Float:gDefaultDelay[MAX_BUTTONS];
new 
Float:gDelay[MAX_BUTTONS];

new 
gInMenu[33];

new 
gszFile[128];

new 
giSprite;

new 
gcvarDefaultgcvarTeamgcvarFreeRun;
new 
gcvarLimitgcvarLimitModegcvarPrivilege;
new 
gcvarMessagegcvarRestore;

//VOTE

#define TASK_SHOWMENU 432
#define TASK_RES 123

#define MAX_ROUNDS 999

#define KeysFFVote (1<<0)|(1<<1) // Keys: 12

new gcvarFRVoteTime;

new 
giVoteStartgiVoteTime;

new 
bool:gbFreeRun=false;
new 
bool:gbVote=false;

#define VOTE_ON 0
#define VOTE_OFF 1

new giVotes[33][2];

new 
giRounds=MAX_ROUNDSgiTime=0;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_dictionary("common.txt");
    
register_dictionary("adminvote.txt");
    
register_dictionary("use_button_once.txt");
    
    
register_menucmd(register_menuid("FRVote"), KeysFFVote"PressedFRVote");
    
register_menucmd(register_menuid("ButtonsMenu"), KeysButtonsMenu"PressedButtonsMenu");
    
register_menucmd(register_menuid("OptionsMenu"), KeysOptionsMenu"PressedOptionsMenu");
    
register_menucmd(register_menuid("DelayMenu"), KeysDelayMenu"PressedDelayMenu");
    
    
register_clcmd("amx_buttons","cmd_amx_buttons",ADMIN_CFG,": Buttons Menu");
    
    
//Default count of uses
    
gcvarDefault=register_cvar("amx_buttons_default","1");
    
//Who plugin analyze
    //0 - anyone(plugin disabled?)
    //1 - Te
    //2 - Ct
    //3 - Te+Ct
    
gcvarTeam=register_cvar("amx_buttons_team","1");
    
//Enabled FreeRun mode?
    
gcvarFreeRun=register_cvar("amx_buttons_freerun","1");
    
//Vote time
    
gcvarFRVoteTime=register_cvar("amx_freerun_votetime","10");
    
    
//Type of limit
    //0 - enabled after 'amx_freerun_limit' rounds
    //1 - enabled after 'amx_freerun_limit' minutes
    
gcvarLimitMode=register_cvar("amx_freerun_limit_mode","0");
    
//Size of Limit
    
gcvarLimit=register_cvar("amx_freerun_limit","5");
    
    
//Interval of message
    
gcvarMessage=register_cvar("amx_freerun_info","120.0",0,120.0);
    
    
//Terrorist`s privilege
    //if he use /free FreeRun will start without vote, can he?
    
gcvarPrivilege=register_cvar("amx_freerun_tt_privilege","1");
    
    
//restore buttons on new round
    
gcvarRestore=register_cvar("amx_restore_buttons","1");
    
    
register_clcmd("say /free","cmdVoteFreeRun");
    
register_clcmd("say_team /free","cmdVoteFreeRun");
    
register_clcmd("say free","cmdVoteFreeRun");
    
register_clcmd("say_team free","cmdVoteFreeRun");
    
    
register_clcmd("say /freerun","cmdVoteFreeRun");
    
register_clcmd("say_team /freerun","cmdVoteFreeRun");
    
register_clcmd("say freerun","cmdVoteFreeRun");
    
register_clcmd("say_team freerun","cmdVoteFreeRun");
    
    
register_clcmd("say /fr","cmdVoteFreeRun");
    
register_clcmd("say_team /fr","cmdVoteFreeRun");
    
register_clcmd("say fr","cmdVoteFreeRun");
    
register_clcmd("say_team fr","cmdVoteFreeRun");
    
    
RegisterHam(Ham_Touch"armoury_entity""fwdNoWeaponPickup");
    
RegisterHam(Ham_Touch"weaponbox""fwdNoWeaponPickup");
    
    if( 
engfunc(EngFunc_FindEntityByString,-,"classname""func_button"))
        
RegisterHam(Ham_Use"func_button""fwButtonUsed");
    
    if(
engfunc(EngFunc_FindEntityByString,-,"classname","func_rot_button"))
        
RegisterHam(Ham_Use"func_rot_button""fwButtonUsed");
    
    if(
engfunc(EngFunc_FindEntityByString,-,"classname""button_target"))
        
RegisterHam(Ham_Use"button_target""fwButtonUsed");
    
    
register_logevent"ResetButtons"2"0=World triggered""1=Round_Start");
    
    
fillButtons("func_button");
    
fillButtons("func_rot_button");
    
fillButtons("button_target");
}    

public 
plugin_cfg(){
    
setButtons();
    
    new 
iLen=0iMax=charsmax(gszFile);
    
iLen=get_configsdir(gszFileiMax );
    
iLen+=copy(gszFile[iLen], iMax-iLen"/dr_buttons/");
    
    if(!
dir_exists(gszFile)){
        
set_fail_state("Not found dir: configs/dr_buttons");
        return;
    }
    new 
szMap[32];
    
get_mapname(szMap31);
    
formatex(gszFile[iLen], charsmax(gszFile)-iLen"%s.ini"szMap);
    if(!
file_exists(gszFile)){
        return;
    }
    new 
szLine[51];
    new 
szButton[4], szTimes[3], szDelay[5];
    new 
Float:fDelay;
    for(new 
i=0;read_file(gszFileiszLine50iLen);i++){
        if(
iLen==0) continue;
        
trim(szLine);
        if(
szLine[0]==';') continue;
        
parse(szLineszButton3szTimes2szDelay4);
        
fDelay=szDelay[0]?str_to_float(szDelay):-1.0;
        
set_start_value(str_to_num(szButton), str_to_num(szTimes), fDelay);
    }
    new 
Float:fInterval=get_pcvar_float(gcvarMessage);
    if(
fInterval 0.0)
        
set_task(120.0"announceVote",ANNOUNCE_TASK,_,_,"b");
}
public 
plugin_precache(){
    
giSprite=precache_model("sprites/flare1.spr");
    
}
public 
client_putinserver(id){
    if(!
is_user_bot(id))
        
eventInGame(id);
}
public 
client_connect(id){
    
giVotes[id][VOTE_ON]=0;
    
giVotes[id][VOTE_OFF]=0;
}
public 
announceVote(){
    if(
get_pcvar_num(gcvarFreeRun))
        
ColorChat(0,GREEN"[FreeRun]^x01 %L",LANG_SERVER"ANNOUNCE");
}
setButtons(){
    new 
iDef=get_pcvar_num(gcvarDefault);
    for(new 
i=0;i<giPointer;i++){
        
gUsed[i]=iDef;
        
gOnStart[i]=iDef;
        
gDelay[i]=get_pdata_float(gEnt[i],m_flWait);
        
gDefaultDelay[i]=gDelay[i];
    }
}
fillButtons(const szClass[]){
    new 
ent = -1;
    while((
ent engfunc(EngFunc_FindEntityByString,ent ,"classname"szClass)) != 0){
        
gEnt[giPointer++]=ent;
        
set_pev(entpev_iuser4giPointer);
    }
}
set_start_value(enttimesFloat:delay){
    new 
index=get_ent_index(ent);
    if(
index!=-1){
        
gOnStart[index]=times;
        if(
delay>=0.0)
            
gDelay[index]=delay;
    }
}
get_ent_index(ent){
    
/*
    for(new i=0;i<giPointer;i++)
        if(gEnt[i]==ent) return i;
    return -1;
    */
    
return pev(entpev_iuser4)-1;
}
restoreButton(ent){
    if(
pev(entpev_frame) > 0.0){
        new 
Float:Life;
        
pev(entpev_nextthinkLife);
        
set_pev(entpev_ltimeLife-0.01);
    }
}
public 
ResetButtons(){
    
gbFreeRun=false;
    
gbVote=false;
    new 
bool:bRestore=get_pcvar_num(gcvarRestore)!=0;
    for(new 
i=0;i<MAX_BUTTONS;i++){
        
gUsed[i]=gOnStart[i];
        if(
bRestore){
            
restoreButton(gEnt[i]);
        }
    }
    
giRounds++;
}
public 
fwButtonUsed(thisidcalleridactivatoruse_typeFloat:value){
    if(
idcaller!=idactivator) return HAM_IGNORED;
    
    if(
pev(thispev_frame) > 0.0)
        return 
HAM_IGNORED;
    new 
index=get_ent_index(this);
    if(
index==-1
        return 
HAM_IGNORED;
    if(
get_user_team(idcaller)&get_pcvar_num(gcvarTeam)){
        
        if(
gbFreeRun){
            
ColorChat(idcaller,GREEN"[FreeRun]^x01 %L",idcaller"BUTTON_FREERUN");
            return 
HAM_SUPERCEDE;
        }
        else if(
gUsed[index]<=&& gOnStart[index]!=-1){
            
ColorChat(idcaller,GREEN"[Info]^x01 %L",idcaller,"BUTTON_NOMORE");
            return 
HAM_SUPERCEDE;
        }
        else
        {
            if(
gUsed[index]>0)
            {
                if(--
gUsed[index]){
                    
ColorChat(idcallerGREEN"[Info]^x01 %L"idcaller"BUTTON_LEFT"gUsed[index]);
                }
                else
                {
                    
ColorChat(idcallerGREEN"[Info]^x01 %L"idcaller"BUTTON_ENDOFLIMIT");
                }
            }
        }
    }
    
    
set_task(0.1,"setDelay",this);
    
    return 
HAM_IGNORED;
}
public 
setDelay(this){
    new 
index=get_ent_index(this);
    
set_pev(thispev_nextthinkpev(thispev_ltime)+gDelay[index]+0.01);
}

//MENU--------------
public cmd_amx_buttons(idlevelcid){
    if(!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED;
    if(
giPointer==0)
        
client_print(idprint_chat"%L"id,"NO_BUTTONS");
    else
        
ShowButtonsMenu(id);
    return 
PLUGIN_HANDLED;
}
ShowButtonsMenu(idtrace=1){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id"MUST_B_ALIVE");
        return;
    }
    new 
iNow=gInMenu[id];
    new 
iKeys=(1<<0)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<9);
    new 
szMenu[196], iLeniMax=(sizeof szMenu) - 1;
    new 
szNoLimit[32];
    
formatex(szNoLimit,31,"(%L)",id,"NOLIMIT");
    
iLen=copy(szMenuiMax,"\yButtons Menu^n");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\wEnt#%d^n^n",gEnt[iNow]);
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"%L: %d %s^n\y1\w. %L ",id"USAGE",gOnStart[iNow],(gOnStart[iNow]==-1)?szNoLimit:""id"MORE");
    
    if(
gOnStart[iNow]>=0){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"\y2\w. %L",id"WORD_LESS");
        
iKeys|=(1<<1);
    }else
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\d2. %L\w",id,"WORD_LESS");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n^n3. %L^n^n4. %L^n^n",id"DELAY_EDITOR",id,"OPTIONS");
    
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"5. %sNo Clip\w^n",isNoClip(id)?"\r":"");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"6. %sGodMode\w^n",isGodMode(id)?"\r":"");
    
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n7. \r%L^n\w",id"WORD_SAVE");
    
    if(
iNow>0){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n8. %L",id"BACK");
        
iKeys|=(1<<7);
    }
    if(
iNow<giPointer-1){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n9. %L",id"WORD_NEXT");
        
iKeys|=(1<<8);
    }
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n0. %L"id"EXIT");
    
show_menu(idiKeysszMenu, -1"ButtonsMenu");
    if(
trace){
        new 
Float:fOrigin[3], Float:fOrigin2[3];
        
fm_get_brush_entity_origin(gEnt[gInMenu[id]], fOrigin);
        
pev(idpev_originfOrigin2);
        
Create_TE_BEAMPOINTS(fOriginfOrigin2giSprite01020512550010050);
    }
}
bool:isNoClip(id)
return 
pev(idpev_movetype)==MOVETYPE_NOCLIP;

bool:isGodMode(id)
return 
pev(idpev_takedamage)==0.0;

public 
PressedButtonsMenu(idkey) {
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    
/* Menu:
    * Buttons Menu
    * Ent#<ent>
    * 
    * Uzyc: <ile>
    * 1. Wiecej 2. Mniej
    * 
    * 3. Editor
    *
    * 4. Options
    *
    * 5. NoClip
    * 6. GodMode
    * 
    * 7. Zapisz
    * 
    * 8. Poprzedni
    * 9. Nastepny
    * 0. Wyjdz
    */
    
new trace=0;
    switch (
key) {
        case 
0: { // 1
            
gOnStart[gInMenu[id]]++;
        }
        case 
1: { // 2
            
gOnStart[gInMenu[id]]--;
        }
        case 
2: { // 3
            
ShowDelayMenu(id);
            return;
        }
        case 
3:{ //4
            
ShowOptionsMenu(id);
            return;
        }
        case 
4:{ //5
            
set_pev(idpev_movetypeisNoClip(id)?MOVETYPE_WALK:MOVETYPE_NOCLIP);    
        }
        case 
5:{ //6
            
set_pev(idpev_takedamageisGodMode(id)?1.0:0.0);
        }
        case 
6: { // 7
            
save2File(id);
        }
        case 
7: { // 8
            
gInMenu[id]--;
            
trace=1;
        }
        case 
8: { // 9
            
gInMenu[id]++;
            
trace=1;
        }
        case 
9: { // 0
            
return;
        }
    }
    
ShowButtonsMenu(idtrace);
}
//--------------
ShowOptionsMenu(id){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    new 
szMenu[196], iLeniMax=(sizeof szMenu) - 1;
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\yOptions^n^n");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\w1. %L^n",id"GOTO");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"2. %L^n^n",id"NEAREST");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"9. %L",id"BACK");
    
show_menu(idKeysOptionsMenuszMenu, -1"OptionsMenu");
}
public 
PressedOptionsMenu(idkey){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    new 
trace=0;
    switch (
key) {
        case 
0: { // 1
            
go2Button(id);
        }
        case 
1: { // 2
            
gInMenu[id]=findTheClosest(id);
            
trace=1;
        }
    }
    
ShowButtonsMenu(idtrace);
}
//-------------
ShowDelayMenu(id){
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id,"MUST_B_ALIVE");
        return;
    }
    new 
iNow=gInMenu[id];
    new 
iKeys=(1<<0)|(1<<2)|(1<<8);
    new 
szMenu[196], iLeniMax=(sizeof szMenu) - 1;
    
iLen=copy(szMenuiMax,"\yDelay Menu^n");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\wEnt#%d^n^n",gEnt[iNow]);
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"%L: %.1f^n",id"CURRENT_DELAY"gDelay[iNow]);
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\y1\w. %L ",id"MORE");
    if(
gDelay[iNow]>0.0){
        
iLen+=formatex(szMenu[iLen], iMax-iLen,"\y2\w. %L",id"WORD_LESS");
        
iKeys|=(1<<1);
    }else
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"\d2. %L\w",id,"WORD_LESS");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n3. %L",id"DEFAULT");
    
iLen+=formatex(szMenu[iLen], iMax-iLen,"^n^n9. %L",id"BACK");
    
show_menu(idiKeysszMenu, -1"DelayMenu");
}
public 
PressedDelayMenu(idkey){
    new 
iNow=gInMenu[id];
    switch(
key){
        case 
0:{
            
gDelay[iNow]+=1.0;
        }
        case 
1:{
            
gDelay[iNow]-=1.0;
            if(
gDelay[iNow] < 0.0)
                
gDelay[iNow]=0.0;
        }
        case 
2:{
            
gDelay[iNow]=gDefaultDelay[iNow];
        }
        case 
8:{
            
ShowButtonsMenu(id0);
            return;
        }
    }
    
ShowDelayMenu(id);
}
//-------------
save2File(id){
    if(
file_exists(gszFile))
        
delete_file(gszFile);
    
write_file(gszFile";<ent> <count> <delay>");
    new 
szLine[35];
    for(new 
i=0;i<giPointer;i++){
        
formatex(szLine34"%d %d %.1f",gEnt[i], gOnStart[i], gDelay[i]);
        
write_file(gszFileszLine);
    }
    
client_print(idprint_center"%L!",id,"WORD_SAVED");
}
findTheClosest(id){
    new 
Float:fPlayerOrig[3];
    
pev(idpev_originfPlayerOrig);
    new 
Float:fOrigin[3];
    
fm_get_brush_entity_origin(gEnt[0], fOrigin);
    
    new 
Float:fRange=get_distance_f(fOriginfPlayerOrig), index=0;
    new 
Float:fNewRange;
    for(new 
i=1;i<giPointer;i++){
        
fm_get_brush_entity_origin(gEnt[i], fOrigin);
        
fNewRange=get_distance_ffOrigin,  fPlayerOrig);
        if(
fNewRange fRange){
            
fRange=fNewRange;
            
index=i;
        }
    }
    return 
index;
}
go2Button(ident=-1){
    if(
ent==-1)
        
ent=gInMenu[id];
    
ent=gEnt[ent];
    if(!
pev_valid(ent)){
        
client_print(idprint_center"%L",id,"NOTARGET");
        return;
    }
    new 
Float:fOrigin[3];
    
fm_get_brush_entity_origin(entfOrigin);
    
set_pev(idpev_originfOrigin);
    
client_print(idprint_chat"PS. No Clip :)");
}
//FreeRun
public cmdVoteFreeRun(id){
    if(
get_pcvar_num(gcvarFreeRun)==0){
        
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_DISABLED");
        return 
PLUGIN_HANDLED;
    }
    if(
gbVote){
        
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_VOTE_IS_NOW");
        return 
PLUGIN_HANDLED;
    }
    if(!
is_user_alive(id)){
        
client_print(idprint_center"%L",id"MUST_B_ALIVE");
        return 
PLUGIN_HANDLED;
    }
    if(
get_pcvar_num(gcvarPrivilege)!=&& !gbFreeRun && get_user_team(id)==1){
        
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_TT_DECIDED");
        
makeFreeRun(true);
        return 
PLUGIN_HANDLED;
    }
    new 
iLimit=get_pcvar_num(gcvarLimit);
    new 
iOffset=0;
    if(
get_pcvar_num(gcvarLimitMode)){
        
iOffset = ( giTime iLimit 60 )  - get_systime();
        if( 
iOffset ){
            
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_NEXT_VOTE_TIME"iOffset/60iOffset%60);
            return 
PLUGIN_HANDLED;
        }
    }
    else{
        
iOffset =  min(MAX_ROUNDSiLimit) - giRounds;
        if( 
iOffset ){
            
ColorChat(idGREEN"[FreeRun]^x01 %L",id,"FREERUN_NEXT_VOTE_ROUNDS"iOffset);
            return 
PLUGIN_HANDLED;
        }
    }
    
    
makeVote();
    return 
PLUGIN_CONTINUE;
}
//FREERUN
public makeVote(){
    
giVoteTime=get_pcvar_num(gcvarFRVoteTime);
    
gbVote=true;
    
giVoteStart=get_systime();
    
set_task(float(giVoteTime), "resultsOfVote"TASK_RES);
    new 
Players[32], playerCount;
    new 
id;
    
get_players(PlayersplayerCount);
    for (new 
i=0i<playerCounti++){
        
id Players[i]; 
        
eventInGame(id);
    }
    
}
public 
resultsOfVote(tid){
    
gbVote=false;
    
    new 
giVotesOn=count(VOTE_ON);
    new 
giVotesOff=count(VOTE_OFF);
    
    
ColorChat(0,GREEN"[FreeRun]^x01 %L %L(%d) vs %L(%d)",LANG_SERVER,"FREERUN_RESULTS",LANG_SERVER,"YES",giVotesOn,LANG_SERVER,"NO"giVotesOff);
    
    if( 
giVotesOn == giVotesOff ){
        
ColorChat(0,GREEN"[FreeRun]^x01 %L",LANG_SERVER,"FREERUN_TIE");
        return;
    }
    
makeFreeRun((giVotesOn giVotesOff));
    
ColorChat(0,GREEN"[FreeRun]^x01 %L ^x03%L",LANG_SERVER,"FREERUN_WINOPTION",LANG_SERVERgbFreeRun?"YES":"NO");
}
makeFreeRun(bool:bFR=true){
    
gbFreeRun=bFR;
    
reset();
    
giRounds=0;
    
giTime=get_systime();
    
    if(
gbFreeRun)
    {
        
set_hudmessage(02552550.02, -1.0);
        
show_hudmessage(0"FreeRun!");
        
        new 
players[32], plNumi
        get_players
(playersplNum"ah")
        for (
0plNumi++)
        {
            
fm_strip_user_weapons(players[i])
            
fm_give_item(players[i], "weapon_knife")
        }
    }
    
}
count(VOTE_STATE){
    new 
iCounter=0;
    for(new 
i=1;i<33;i++)
        if(
giVotes[i][VOTE_STATE])
        
iCounter++;
    return 
iCounter;
}
reset(){
    for(new 
i=1;i<33;i++){
        
giVotes[i][VOTE_ON]=0;
        
giVotes[i][VOTE_OFF]=0;
    }
}
public 
show_menu_(tid){
    new 
id=tid-TASK_SHOWMENU;
    new 
iTeam=get_user_team(id);
    new 
menu_idkeys;
    new 
menuUp player_menu_infoidmenu_idkeys );
    
// Only display menu if another isn't shown
    
if ( iTeam && (menuUp <= || menu_id 0) ){
        new 
iTime=get_pcvar_num(gcvarFRVoteTime);
        new 
iOffset=get_systime()-giVoteStart;
        
iTime-=iOffset;
        new 
szMenu[128];
        
formatex(szMenu127"\y%L^n^n\w1. %L^n2. %L",id,"FREERUN_VOTEMENU",id,"YES",id,"NO");
        
show_menu(idKeysFFVoteszMenuiTime"FRVote");
    }else
    
set_task(1.0"show_menu_"tid);
}
public 
eventInGame(id){
    if(
giVotes[id][VOTE_ON] || giVotes[id][VOTE_OFF])
        return;
    if(
gbVote)
        
set_task(1.0"show_menu_"id+TASK_SHOWMENU);
}
public 
PressedFRVote(idkey) {
    if(
gbVote==false) return;
    switch (
key) {
        case 
VOTE_ON: { // 1
            
giVotes[id][VOTE_ON]=1;
        }
        case 
VOTE_OFF: { // 2
            
giVotes[id][VOTE_OFF]=1;
        }
        default:{
            return;
        }
    }
    new 
szName[32];
    
get_user_name(idszName31);
    
    
client_print(0print_chat"* %L",LANG_PLAYER,(key==VOTE_ON)?"VOTED_FOR":"VOTED_AGAINST"szName);
}

stock Create_TE_BEAMPOINTS(Float:start[3], Float:end[3], iSpritestartFrameframeRatelifewidthnoiseredgreenbluealphaspeed){
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_BEAMPOINTS )
    
write_coordfloatround(start[0]) )
    
write_coordfloatround(start[1]) )
    
write_coordfloatround(start[2]) )
    
write_coordfloatround(end[0]) )
    
write_coordfloatround(end[1]) )
    
write_coordfloatround(end[2]) )
    
write_shortiSprite )            // model
    
write_bytestartFrame )        // start frame
    
write_byteframeRate )            // framerate
    
write_bytelife )                // life
    
write_bytewidth )                // width
    
write_bytenoise )                // noise
    
write_bytered)                // red
    
write_bytegreen )                // green
    
write_byteblue )                // blue
    
write_bytealpha )                // brightness
    
write_bytespeed )                // speed
    
message_end()
}
stock fm_get_brush_entity_origin(entFloat:fOrigin[3]){
    new 
Float:fMins[3], Float:fMaxs[3];
    
pev(entpev_minsfMins);
    
pev(entpev_maxsfMaxs);
    
    for(new 
i=0;i<3;i++)
        
fOrigin[i]=(fMins[i]+fMaxs[i])/2;
}

stock fm_strip_user_weapons(index) {
    new 
ent create_entity("player_weaponstrip");
    if (!
pev_valid(ent))
        return 
0;
    
    
dllfunc(DLLFunc_Spawnent);
    
dllfunc(DLLFunc_Useentindex);
    
engfunc(EngFunc_RemoveEntityent);
    
    return 
1;
}

stock fm_give_item(index, const item[]) {
    if (!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
        return 
0;
    
    new 
ent create_entity(item);
    if (!
pev_valid(ent))
        return 
0;
    
    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);
    
    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);
    if (
pev(entpev_solid) != save)
        return 
ent;
    
    
engfunc(EngFunc_RemoveEntityent);
    
    return -
1;
}

public 
fwdNoWeaponPickup(entid)
{
    if (
is_user_alive(id) && gbFreeRun)
        return 
HAM_SUPERCEDE
    
return HAM_IGNORED

I fixed the errors. Not promising that it will work the way you intend though.
__________________
Hi.
Kreation is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-04-2011 , 02:57   Re: Problem with editing Use Button Once
Reply With Quote #3

Quote:
Originally Posted by cajlo View Post
up
Don't bump until 2 weeks have passed since the last post in the topic.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
cajlo
New Member
Join Date: Feb 2011
Old 02-04-2011 , 06:45   Re: Problem with editing Use Button Once
Reply With Quote #4

thx
it works)
cajlo is offline
karolek0901
Junior Member
Join Date: May 2010
Old 03-23-2011 , 18:46   Re: Problem with editing Use Button Once
Reply With Quote #5

hello i have question can add when terrorist turn the lock when you start up the first trap you can not enter the free round

Last edited by karolek0901; 03-23-2011 at 18:54.
karolek0901 is offline
karolek0901
Junior Member
Join Date: May 2010
Old 03-23-2011 , 18:53   Re: Problem with editing Use Button Once
Reply With Quote #6

Or turn the lock when you start up the first trap you can not enter the free round
karolek0901 is offline
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 16:25.


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