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

Use Button Once Edit.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iTouch
Member
Join Date: Feb 2011
Old 10-01-2011 , 04:38   Use Button Once Edit.
Reply With Quote #1

Hello all i am using the Use Button Once plugin for deathrun which has the FreeRun inside it but it doesn't disarm the players can some one edit it
when it is free to disarm all CT-s.

Link : http://forums.alliedmods.net/showthread.php?p=873614
PHP Code:
/*
Manager of Buttons
for DeathRun

Licence: GPL
Description:
    Allow admin to define how many times every button could be used by Menu.
    Add to game (cvar controlled) FreeRun mode - during round with FR traps can`t 
    be used by defined teams (default Te).

*/
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#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");
    
    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!");
    }
    
}
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;

__________________
Feel the diference
iTouch is offline
Nur56
Member
Join Date: Apr 2007
Old 10-01-2011 , 13:57   Re: Use Button Once Edit.
Reply With Quote #2

PHP Code:
makeFreeRun(bool:bFR=true){
    
gbFreeRun=bFR;
    
reset();
    
giRounds=0;
    
giTime=get_systime();
    
    if(
gbFreeRun){
        
set_hudmessage(02552550.02, -1.0);
        
show_hudmessage(0"FreeRun!");
    }
    

Find this block.

then, at the top of the .sma file, where all the #includes are, below any include, include the fun module and the cstrike module.. so

PHP Code:
#include <amxmodx> 
#include <amxmisc>
#include <fun>
#include <cstrike> 
#include <hamsandwich> 
#include <fakemeta> 
#include <colorchat> 
Now, replace that block with this one:

PHP Code:
makeFreeRun(bool:bFR=true){
    
gbFreeRun=bFR;
    
reset();
    
giRounds=0;
    
giTime=get_systime();
    new 
iPlayers[32], iCountidi
    
if(gbFreeRun){
        
set_hudmessage(02552550.02, -1.0);
        
show_hudmessage(0"FreeRun!");
        
get_playersiPlayersiCount )
        for( 
0iCounti++ ) {
            
id iPlayers[i]
            if( ( 
is_user_aliveid ) ) && ( cs_get_user_teamid ) == CS_TEAM_CT ) ) {
                
strip_user_weaponsid )
            }
        }
    }

have fun.
Nur56 is offline
iTouch
Member
Join Date: Feb 2011
Old 10-02-2011 , 14:11   Re: Use Button Once Edit.
Reply With Quote #3

Man thanks but its my mistake

With dissarm i meant to let him have a knife.

And every time he respawns with a weapon the player drops that weapon and have only knife can u make it :$.
__________________
Feel the diference
iTouch is offline
Nur56
Member
Join Date: Apr 2007
Old 10-03-2011 , 14:03   Re: Use Button Once Edit.
Reply With Quote #4

PHP Code:
makeFreeRun(bool:bFR=true){
    
gbFreeRun=bFR;
    
reset();
    
giRounds=0;
    
giTime=get_systime();
    new 
iPlayers[32], iCountidi
    
if(gbFreeRun){
        
set_hudmessage(02552550.02, -1.0);
        
show_hudmessage(0"FreeRun!");
        
get_playersiPlayersiCount )
        for( 
0iCounti++ ) {
            
id iPlayers[i]
            if( ( 
is_user_aliveid ) ) && ( cs_get_user_teamid ) == CS_TEAM_CT ) ) {
                
strip_user_weaponsid )
                
give_item(id"weapon_knife")
            }
        }
    }

Nur56 is offline
iTouch
Member
Join Date: Feb 2011
Old 10-03-2011 , 14:50   Re: Use Button Once Edit.
Reply With Quote #5

Firslty thank you very much.

Man sorry for bothering you but i need to ask you something.
Firstly i'm running a deathrun server with respawn plugin if it is free you have only knife until you die when you respawn again you will have a weapon the thing is i can make
dr_giveusp 0 but i wanted to ask you is there any way to make it drop your weapon when it's free without making that command coz the players need the usp in maps when it is not free.

I hope you understanded me.
__________________
Feel the diference
iTouch is offline
Nur56
Member
Join Date: Apr 2007
Old 10-03-2011 , 15:19   Re: Use Button Once Edit.
Reply With Quote #6

Really easy! First of all you need to hook player spawn, in plugin_init() block

at the end, hook Ham_Spawn.. so it would look like this:

PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);

    
//big code block here... never mind it
    
fillButtons("func_button");
    
fillButtons("func_rot_button");
    
fillButtons("button_target");
    
//here you hook Ham_Spawn
    
RegisterHam(Ham_Spawn"player""fwdSpawn")

Now we make new public for fwdSpawn

so anywhere free in the code, preferably right under plugin_init

PHP Code:
public fwdSpawnid ) {


Now you write the code.. since you probably don't know scripting I'll do it for you


PHP Code:
public fwdSpawnid ) {
    if( 
gbFreeRun ) {
        if( (
cs_get_user_teamid ) == CS_TEAM_CT) && is_user_aliveid ) ) {
            
strip_user_weaponsid )
            
give_item(id"weapon_knife")
        }
    }
    return 
HAM_IGNORED

So finished product would be


PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);

    
//big code block here... never mind it
    
fillButtons("func_button");
    
fillButtons("func_rot_button");
    
fillButtons("button_target");
    
//here you hook Ham_Spawn
    
RegisterHam(Ham_Spawn"player""fwdSpawn")
}
public 
fwdSpawnid ) {
    if( 
gbFreeRun ) {
        if( (
cs_get_user_teamid ) == CS_TEAM_CT) && is_user_aliveid ) ) {
            
strip_user_weaponsid )
            
give_item(id"weapon_knife")
        }
    }
    return 
HAM_IGNORED

Have fun, I didn't test it but it should work 100% and if it doesn't simply reply here


edit: make sure you don't replace the full plugin_init() with the one I posted, instead just hook Ham_Spawn( add the line I added)

Last edited by Nur56; 10-03-2011 at 15:24.
Nur56 is offline
iTouch
Member
Join Date: Feb 2011
Old 10-03-2011 , 15:34   Re: Use Button Once Edit.
Reply With Quote #7

Yes i understand it thanks
There is another problem to make it easier.
I saw that at the end of the game the player can get the weapon that are used in end of map in deathrun.

Can u edit the plugin just tu make it drop weapon every time he catches one and uses only knife when it's freerun. this would be the last time u make a code coz i know i'm boring i just ask and ask and ask :S

Edit : Edit this part coz this script is usefull just make it drop the weapon if u can :$.
PHP Code:
makeFreeRun(bool:bFR=true){
    
gbFreeRun=bFR;
    
reset();
    
giRounds=0;
    
giTime=get_systime();
    new 
iPlayers[32], iCountidi
    
if(gbFreeRun){
        
set_hudmessage(02552550.02, -1.0);
        
show_hudmessage(0"FreeRun!");
        
get_playersiPlayersiCount )
        for( 
0iCounti++ ) {
            
id iPlayers[i]
            if( ( 
is_user_aliveid ) ) && ( cs_get_user_teamid ) == CS_TEAM_CT ) ) {
                
strip_user_weaponsid )
                
give_item(id"weapon_knife")
            }
        }
    }

__________________
Feel the diference

Last edited by iTouch; 10-03-2011 at 15:40.
iTouch is offline
Nur56
Member
Join Date: Apr 2007
Old 10-03-2011 , 15:43   Re: Use Button Once Edit.
Reply With Quote #8

I'll do it in a sec, but I forgot something
the hook
PHP Code:
 RegisterHam(Ham_Spawn"player""fwdSpawn"


PHP Code:
 RegisterHam(Ham_Spawn"player""fwdSpawn",1
forgot that


i'll edit this post when I finish doing your weapon drop


OK back

first you must hook another event.. I won't tell you how to do it, just add an extra line in plugin_init().. add this line

PHP Code:
register_event("CurWeapon""do_disarm""b""1=1"
Ok, now add another public.. and just write this inside of it(put it anywhere except inside other public functions.. just like you did with the spawn thing)

PHP Code:
public do_disarm(id) {
    
    if( 
gbFreeRun ) {
        if( 
is_user_aliveid ) && (cs_get_user_team(id) == CS_TEAM_CT) ) {
            if(!(
get_user_weapon(id) == CSW_KNIFE)) {
                
client_cmd(id"drop")
            }
        }
    }

Have fun

Last edited by Nur56; 10-03-2011 at 16:12.
Nur56 is offline
iTouch
Member
Join Date: Feb 2011
Old 10-03-2011 , 16:25   Re: Use Button Once Edit.
Reply With Quote #9

Thank you thank you thank you thousand times you are the best man it is perfect.
__________________
Feel the diference
iTouch is offline
iTouch
Member
Join Date: Feb 2011
Old 10-04-2011 , 12:41   Re: Use Button Once Edit.
Reply With Quote #10

Sorry for double post.

Nur56. there is a small problem wich i haven't thought
The terror is using this and pressing the buttons but when a player comes to the end he just types /free and the plugin disarms the CT-s

Is there any way that the terror has only 30 sec to decide if he want's to let it free or normal game. :$

Im sorry for bothering you but i think this would be the Ultimate Plugin.

Edit it here coz this has all the codes you;ve made till yet for this plugin
PHP Code:
/* 
Manager of Buttons 
for DeathRun 

Licence: GPL 
Description: 
    Allow admin to define how many times every button could be used by Menu. 
    Add to game (cvar controlled) FreeRun mode - during round with FR traps can`t  
    be used by defined teams (default Te). 

*/ 
#include <amxmodx> 
#include <amxmisc>
#include <fun>
#include <cstrike> 
#include <hamsandwich> 
#include <fakemeta> 
#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"); 
     
    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"); 
     
//here you hook Ham_Spawn
    
RegisterHam(Ham_Spawn"player""fwdSpawn",1
    
register_event("CurWeapon""do_disarm""b""1=1")  

public 
fwdSpawnid ) {
    if( 
gbFreeRun ) {
        if( (
cs_get_user_teamid ) == CS_TEAM_CT) && is_user_aliveid ) ) {
            
strip_user_weaponsid )
            
give_item(id"weapon_knife")
        }
    }
    return 
HAM_IGNORED
}  
public 
do_disarm(id) {
    
    if( 
gbFreeRun ) {
        if( 
is_user_aliveid ) && (cs_get_user_team(id) == CS_TEAM_CT) ) {
            if(!(
get_user_weapon(id) == CSW_KNIFE)) {
                
client_cmd(id"drop")
            }
        }
    }
}  
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"[Bibita 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"[Bibita 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"[Bibita FreeRun]^x01 %L",id,"FREERUN_DISABLED"); 
        return 
PLUGIN_HANDLED
    } 
    if(
gbVote){ 
        
ColorChat(idGREEN"[Bibita 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"[Bibita 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"[Bibita FreeRun]^x01 %L",id,"FREERUN_NEXT_VOTE_TIME"iOffset/60iOffset%60); 
            return 
PLUGIN_HANDLED
        } 
    } 
    else{ 
        
iOffset =  min(MAX_ROUNDSiLimit) - giRounds
        if( 
iOffset ){ 
             
ColorChat(idGREEN"[Bibita 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"[Bibita 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"[Bibita FreeRun]^x01 %L",LANG_SERVER,"FREERUN_TIE"); 
        return; 
    } 
    
makeFreeRun((giVotesOn giVotesOff)); 
    
ColorChat(0,GREEN"[Bibita 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();
    new 
iPlayers[32], iCountidi
    
if(gbFreeRun){
        
set_hudmessage(02552550.02, -1.0);
        
show_hudmessage(0"FreeRun!");
        
get_playersiPlayersiCount )
        for( 
0iCounti++ ) {
            
id iPlayers[i]
            if( ( 
is_user_aliveid ) ) && ( cs_get_user_teamid ) == CS_TEAM_CT ) ) {
                
strip_user_weaponsid )
                
give_item(id"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

__________________
Feel the diference
iTouch 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:59.


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